refactored broad range of the application, split files, modularized calendar and file views, centralized bottom sheets and clipboard handling, and implemented unit test coverage
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../api/marianumcloud/webdav/queries/list_files/cacheable_file.dart';
|
||||
|
||||
enum SortOption { name, date, size }
|
||||
|
||||
class BetterSortOption {
|
||||
final String displayName;
|
||||
final int Function(CacheableFile, CacheableFile) compare;
|
||||
final IconData icon;
|
||||
|
||||
BetterSortOption({required this.displayName, required this.icon, required this.compare});
|
||||
}
|
||||
|
||||
class SortOptions {
|
||||
static final Map<SortOption, BetterSortOption> options = {
|
||||
SortOption.name: BetterSortOption(
|
||||
displayName: 'Name',
|
||||
icon: Icons.sort_by_alpha_outlined,
|
||||
compare: (a, b) => a.name.compareTo(b.name),
|
||||
),
|
||||
SortOption.date: BetterSortOption(
|
||||
displayName: 'Datum',
|
||||
icon: Icons.history_outlined,
|
||||
compare: (a, b) => a.modifiedAt!.compareTo(b.modifiedAt!),
|
||||
),
|
||||
SortOption.size: BetterSortOption(
|
||||
displayName: 'Größe',
|
||||
icon: Icons.sd_card_outlined,
|
||||
compare: (a, b) {
|
||||
if (a.isDirectory || b.isDirectory) return a.isDirectory ? 1 : 0;
|
||||
if (a.size == null) return 0;
|
||||
if (b.size == null) return 1;
|
||||
return a.size!.compareTo(b.size!);
|
||||
},
|
||||
),
|
||||
};
|
||||
|
||||
static BetterSortOption getOption(SortOption option) => options[option]!;
|
||||
}
|
||||
Reference in New Issue
Block a user