|
@@ -1,3 +1,4 @@
|
|
|
+import 'package:cs_resources/theme/app_colors_theme.dart';
|
|
|
import 'package:flutter/material.dart';
|
|
|
import 'package:flutter/services.dart';
|
|
|
import 'package:wechat_assets_picker/wechat_assets_picker.dart';
|
|
@@ -16,6 +17,8 @@ class AlbumEngine {
|
|
|
int filterMinHeight = 100,
|
|
|
int filterMaxHeight = 100000,
|
|
|
}) async {
|
|
|
+ const Color themeColor = Color(0xff00bc56);
|
|
|
+
|
|
|
FilterOptionGroup filterOptions = FilterOptionGroup()
|
|
|
..setOption(
|
|
|
AssetType.image,
|
|
@@ -39,54 +42,12 @@ class AlbumEngine {
|
|
|
gridCount: 4,
|
|
|
pageSize: 40,
|
|
|
pickerTheme: ThemeData(
|
|
|
+ primaryColor: themeColor,
|
|
|
+ primaryColorDark: Colors.white,
|
|
|
+ primaryColorLight: themeColor,
|
|
|
brightness: Brightness.dark,
|
|
|
- appBarTheme: AppBarTheme(
|
|
|
- systemOverlayStyle: SystemUiOverlayStyle.dark.copyWith(
|
|
|
- statusBarColor: Colors.transparent,
|
|
|
- statusBarBrightness: Brightness.dark,
|
|
|
- statusBarIconBrightness: Brightness.light,
|
|
|
- ),
|
|
|
- ),
|
|
|
- ),
|
|
|
- ),
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- /// 选择视频
|
|
|
- static Future<List<AssetEntity>?> selectVideo(
|
|
|
- BuildContext context, {
|
|
|
- int maxAssets = 1,
|
|
|
- List<AssetEntity>? selected,
|
|
|
- int filterMinWidth = 100,
|
|
|
- int filterMaxWidth = 100000,
|
|
|
- int filterMinHeight = 100,
|
|
|
- int filterMaxHeight = 100000,
|
|
|
- int filterMaxSeconds = 60, //默认能选择60秒以内的视频
|
|
|
- }) async {
|
|
|
- FilterOptionGroup filterOptions = FilterOptionGroup()
|
|
|
- ..setOption(
|
|
|
- AssetType.video,
|
|
|
- FilterOption(
|
|
|
- sizeConstraint: SizeConstraint(
|
|
|
- minWidth: filterMinWidth,
|
|
|
- maxWidth: filterMaxWidth,
|
|
|
- minHeight: filterMinHeight,
|
|
|
- maxHeight: filterMaxHeight,
|
|
|
- ),
|
|
|
- durationConstraint: DurationConstraint(max: Duration(seconds: filterMaxSeconds))),
|
|
|
- );
|
|
|
-
|
|
|
- return AssetPicker.pickAssets(
|
|
|
- context,
|
|
|
- pickerConfig: AssetPickerConfig(
|
|
|
- requestType: RequestType.video,
|
|
|
- selectedAssets: selected,
|
|
|
- maxAssets: maxAssets,
|
|
|
- filterOptions: filterOptions,
|
|
|
- gridCount: 4,
|
|
|
- pageSize: 40,
|
|
|
- pickerTheme: ThemeData(
|
|
|
- brightness: Brightness.dark,
|
|
|
+ primarySwatch: _createMaterialColor(themeColor),
|
|
|
+ textSelectionTheme: const TextSelectionThemeData(cursorColor: themeColor),
|
|
|
appBarTheme: AppBarTheme(
|
|
|
systemOverlayStyle: SystemUiOverlayStyle.dark.copyWith(
|
|
|
statusBarColor: Colors.transparent,
|
|
@@ -98,4 +59,70 @@ class AlbumEngine {
|
|
|
),
|
|
|
);
|
|
|
}
|
|
|
+
|
|
|
+ static MaterialColor _createMaterialColor(Color color) {
|
|
|
+ final strengths = <double>[.05];
|
|
|
+ final swatch = <int, Color>{};
|
|
|
+ for (int i = 1; i < 10; i++) {
|
|
|
+ strengths.add(0.1 * i);
|
|
|
+ }
|
|
|
+
|
|
|
+ for (final strength in strengths) {
|
|
|
+ final double ds = 0.5 - strength;
|
|
|
+ swatch[(strength * 1000).round()] = Color.fromRGBO(
|
|
|
+ color.red + ((ds < 0 ? color.red : (255 - color.red)) * ds).round(),
|
|
|
+ color.green + ((ds < 0 ? color.green : (255 - color.green)) * ds).round(),
|
|
|
+ color.blue + ((ds < 0 ? color.blue : (255 - color.blue)) * ds).round(),
|
|
|
+ 1,
|
|
|
+ );
|
|
|
+ }
|
|
|
+ return MaterialColor(color.value, swatch);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// 选择视频
|
|
|
+// static Future<List<AssetEntity>?> selectVideo(
|
|
|
+// BuildContext context, {
|
|
|
+// int maxAssets = 1,
|
|
|
+// List<AssetEntity>? selected,
|
|
|
+// int filterMinWidth = 100,
|
|
|
+// int filterMaxWidth = 100000,
|
|
|
+// int filterMinHeight = 100,
|
|
|
+// int filterMaxHeight = 100000,
|
|
|
+// int filterMaxSeconds = 60, //默认能选择60秒以内的视频
|
|
|
+// }) async {
|
|
|
+// FilterOptionGroup filterOptions = FilterOptionGroup()
|
|
|
+// ..setOption(
|
|
|
+// AssetType.video,
|
|
|
+// FilterOption(
|
|
|
+// sizeConstraint: SizeConstraint(
|
|
|
+// minWidth: filterMinWidth,
|
|
|
+// maxWidth: filterMaxWidth,
|
|
|
+// minHeight: filterMinHeight,
|
|
|
+// maxHeight: filterMaxHeight,
|
|
|
+// ),
|
|
|
+// durationConstraint: DurationConstraint(max: Duration(seconds: filterMaxSeconds))),
|
|
|
+// );
|
|
|
+//
|
|
|
+// return AssetPicker.pickAssets(
|
|
|
+// context,
|
|
|
+// pickerConfig: AssetPickerConfig(
|
|
|
+// requestType: RequestType.video,
|
|
|
+// selectedAssets: selected,
|
|
|
+// maxAssets: maxAssets,
|
|
|
+// filterOptions: filterOptions,
|
|
|
+// gridCount: 4,
|
|
|
+// pageSize: 40,
|
|
|
+// pickerTheme: ThemeData(
|
|
|
+// brightness: Brightness.dark,
|
|
|
+// appBarTheme: AppBarTheme(
|
|
|
+// systemOverlayStyle: SystemUiOverlayStyle.dark.copyWith(
|
|
|
+// statusBarColor: Colors.transparent,
|
|
|
+// statusBarBrightness: Brightness.dark,
|
|
|
+// statusBarIconBrightness: Brightness.light,
|
|
|
+// ),
|
|
|
+// ),
|
|
|
+// ),
|
|
|
+// ),
|
|
|
+// );
|
|
|
+// }
|
|
|
}
|