1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- part of ct_assets_picker;
-
- // TODO(lucky1213): 此处需修改翻译
- class CustomSortPathDelegate extends SortPathDelegate {
- const CustomSortPathDelegate();
-
- @override
- void sort(List<AssetPathEntity> list) {
- for (final AssetPathEntity entity in list) {
- if (entity.isAll) {
- entity.name = '图片和视频';
- } else if (_isVideo(entity)) {
- entity.name = '全部视频';
- } else if (_isCamera(entity)) {
- entity.name = '相机';
- } else if (_isScreenShot(entity)) {
- entity.name = '截图';
- }
- }
- list.sort((AssetPathEntity path1, AssetPathEntity path2) {
- if (path1.isAll) {
- return -1;
- }
- if (path2.isAll) {
- return 1;
- }
- if (_isCamera(path1)) {
- return -1;
- }
- if (_isCamera(path2)) {
- return 1;
- }
- if (_isVideo(path1)) {
- return -1;
- }
- if (_isVideo(path2)) {
- return 1;
- }
- if (_isScreenShot(path1)) {
- return -1;
- }
- if (_isScreenShot(path2)) {
- return 1;
- }
- return otherSort(path1, path2);
- });
- }
-
- int otherSort(AssetPathEntity path1, AssetPathEntity path2) {
- return path1.name.compareTo(path2.name);
- }
-
- bool _isCamera(AssetPathEntity entity) {
- return entity.name.toUpperCase() == 'camera'.toUpperCase();
- }
-
- bool _isScreenShot(AssetPathEntity entity) {
- return entity.name.toUpperCase() == 'screenshots'.toUpperCase() ||
- entity.name.toUpperCase() == 'screenshot'.toUpperCase();
- }
-
- bool _isVideo(AssetPathEntity entity) {
- return entity.name.toUpperCase() == 'Videos'.toUpperCase();
- }
- }
|