diff --git a/CHANGELOG.md b/CHANGELOG.md index e3484c4a..52b84fe6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,11 +11,24 @@ that can be found in the LICENSE file. --> *None.* +## 9.8.0 + +> [!NOTE] +> Be aware of potential minor theme changes since the base theme has taken place in the picker's theme. + +**Improvements** + +- Improve themes by inheriting the base theme rather than standalone constructors. + +**Fixes** + +- Enabling using the package on Flutter 3.35. + ## 9.7.0 **Improvements** -- Allows to specify the fallback text delegate through `assetPickerTextDelegateFromLocale`. +- Allows specifying the fallback text delegate through `assetPickerTextDelegateFromLocale`. ## 9.6.0 diff --git a/analysis_options.yaml b/analysis_options.yaml index 2377709b..8e4effd3 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -3,6 +3,7 @@ include: package:flutter_lints/flutter.yaml analyzer: errors: deprecated_member_use: ignore + deprecated_member_use_from_same_package: ignore linter: rules: diff --git a/example/lib/customs/pickers/directory_file_asset_picker.dart b/example/lib/customs/pickers/directory_file_asset_picker.dart index 1b2654d7..da8dd8b2 100644 --- a/example/lib/customs/pickers/directory_file_asset_picker.dart +++ b/example/lib/customs/pickers/directory_file_asset_picker.dart @@ -806,7 +806,7 @@ class FileAssetPickerBuilder borderRadius: isAppleOS(context) ? const BorderRadius.vertical(bottom: Radius.circular(10.0)) : null, - color: theme.colorScheme.background, + color: theme.colorScheme.surface, ), child: w, ), diff --git a/example/lib/customs/pickers/insta_asset_picker.dart b/example/lib/customs/pickers/insta_asset_picker.dart index 879fd87d..4b90059a 100644 --- a/example/lib/customs/pickers/insta_asset_picker.dart +++ b/example/lib/customs/pickers/insta_asset_picker.dart @@ -743,7 +743,7 @@ class InstaAssetPickerBuilder extends DefaultAssetPickerBuilderDelegate { padding: const EdgeInsets.all(4), color: isPreview ? theme.unselectedWidgetColor.withOpacity(.5) - : theme.colorScheme.background.withOpacity(.1), + : theme.colorScheme.surface.withOpacity(.1), child: Align( alignment: AlignmentDirectional.topEnd, child: isSelected && !isSingleAssetMode diff --git a/example/lib/main.dart b/example/lib/main.dart index 8dcc30a8..c76d45f6 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -5,9 +5,9 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:wechat_assets_picker/wechat_assets_picker.dart'; -import 'package:wechat_assets_picker_demo/l10n/gen/app_localizations.dart'; import 'constants/extensions.dart'; +import 'l10n/gen/app_localizations.dart'; import 'pages/splash_page.dart'; const Color themeColor = Color(0xff00bc56); @@ -28,10 +28,11 @@ class MyApp extends StatelessWidget { const MyApp({super.key}); ThemeData _buildTheme(Brightness brightness) { - return ThemeData( - brightness: brightness, - primarySwatch: themeColor.swatch, - textSelectionTheme: const TextSelectionThemeData(cursorColor: themeColor), + return ThemeData.from( + colorScheme: ColorScheme.fromSwatch( + primarySwatch: themeColor.swatch, + brightness: brightness, + ), ); } diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 653ee6a3..b3a4077f 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -1,6 +1,6 @@ name: wechat_assets_picker_demo description: The demo project for the wechat_assets_picker package. -version: 9.7.0+68 +version: 9.8.0+69 publish_to: none environment: diff --git a/lib/src/delegates/asset_picker_builder_delegate.dart b/lib/src/delegates/asset_picker_builder_delegate.dart index e16ef52d..1237a62d 100644 --- a/lib/src/delegates/asset_picker_builder_delegate.dart +++ b/lib/src/delegates/asset_picker_builder_delegate.dart @@ -7,7 +7,7 @@ import 'dart:math' as math; import 'dart:ui' as ui; import 'package:flutter/gestures.dart'; -import 'package:flutter/material.dart'; +import 'package:flutter/material.dart' hide Path; import 'package:flutter/semantics.dart'; import 'package:flutter/services.dart'; import 'package:photo_manager/photo_manager.dart'; @@ -564,7 +564,7 @@ abstract class AssetPickerBuilderDelegate { builder: (_, AssetPickerProvider p, __) { if (!p.selectedAssets.contains(asset) && p.selectedMaximumAssets) { return Container( - color: theme.colorScheme.background.withOpacity(.85), + color: theme.colorScheme.surface.withOpacity(.85), ); } return const SizedBox.shrink(); @@ -2006,7 +2006,7 @@ class DefaultAssetPickerBuilderDelegate maxHeight: MediaQuery.sizeOf(context).height * (isAppleOS(context) ? .6 : .8), ), - color: theme.colorScheme.background, + color: theme.colorScheme.surface, child: child, ), ), @@ -2343,7 +2343,7 @@ class DefaultAssetPickerBuilderDelegate p.selectedAssets.isNotEmpty); if (isDisabled) { return Container( - color: theme.colorScheme.background.withOpacity(.85), + color: theme.colorScheme.surface.withOpacity(.85), ); } return const SizedBox.shrink(); @@ -2431,7 +2431,7 @@ class DefaultAssetPickerBuilderDelegate padding: EdgeInsets.all(indicatorSize * .35), color: selected ? theme.colorScheme.primary.withOpacity(.45) - : theme.colorScheme.background.withOpacity(.1), + : theme.colorScheme.surface.withOpacity(.1), child: selected && !isSingleAssetMode ? Align( alignment: AlignmentDirectional.topStart, diff --git a/lib/src/delegates/asset_picker_delegate.dart b/lib/src/delegates/asset_picker_delegate.dart index 56e31f78..5bdf59d8 100644 --- a/lib/src/delegates/asset_picker_delegate.dart +++ b/lib/src/delegates/asset_picker_delegate.dart @@ -2,10 +2,11 @@ // Use of this source code is governed by an Apache license that can be found // in the LICENSE file. -import 'package:flutter/material.dart'; +import 'package:flutter/material.dart' hide Path; import 'package:flutter/services.dart'; import 'package:photo_manager/photo_manager.dart'; -import 'package:wechat_picker_library/wechat_picker_library.dart'; +import 'package:wechat_picker_library/wechat_picker_library.dart' + show buildTheme; import '../constants/config.dart'; import '../constants/constants.dart'; @@ -243,112 +244,6 @@ class AssetPickerDelegate { /// 设置 [light] 为 true 时可以获取浅色版本的主题。 /// {@endtemplate} ThemeData themeData(Color? themeColor, {bool light = false}) { - themeColor ??= defaultThemeColorWeChat; - if (light) { - return ThemeData.light().copyWith( - primaryColor: Colors.grey[50], - primaryColorLight: Colors.grey[50], - primaryColorDark: Colors.grey[50], - canvasColor: Colors.grey[100], - scaffoldBackgroundColor: Colors.grey[50], - cardColor: Colors.grey[50], - highlightColor: Colors.transparent, - textSelectionTheme: TextSelectionThemeData( - cursorColor: themeColor, - selectionColor: themeColor.withAlpha(100), - selectionHandleColor: themeColor, - ), - indicatorColor: themeColor, - appBarTheme: AppBarTheme( - backgroundColor: Colors.grey[100], - systemOverlayStyle: const SystemUiOverlayStyle( - statusBarBrightness: Brightness.light, - statusBarIconBrightness: Brightness.dark, - ), - iconTheme: IconThemeData(color: Colors.grey[900]), - elevation: 0, - ), - bottomAppBarTheme: BottomAppBarTheme( - color: Colors.grey[100], - ), - buttonTheme: ButtonThemeData(buttonColor: themeColor), - iconTheme: IconThemeData(color: Colors.grey[900]), - checkboxTheme: CheckboxThemeData( - checkColor: MaterialStateProperty.all(Colors.black), - fillColor: MaterialStateProperty.resolveWith((states) { - if (states.contains(MaterialState.selected)) { - return themeColor; - } - return null; - }), - side: const BorderSide(color: Colors.black), - ), - colorScheme: ColorScheme( - primary: Colors.grey[50]!, - secondary: themeColor, - background: Colors.grey[50]!, - surface: Colors.grey[50]!, - brightness: Brightness.light, - error: const Color(0xffcf6679), - onPrimary: Colors.white, - onSecondary: Colors.grey[100]!, - onSurface: Colors.black, - onBackground: Colors.black, - onError: Colors.white, - ), - ); - } - return ThemeData.dark().copyWith( - primaryColor: Colors.grey[900], - primaryColorLight: Colors.grey[900], - primaryColorDark: Colors.grey[900], - canvasColor: Colors.grey[850], - scaffoldBackgroundColor: Colors.grey[900], - cardColor: Colors.grey[900], - highlightColor: Colors.transparent, - textSelectionTheme: TextSelectionThemeData( - cursorColor: themeColor, - selectionColor: themeColor.withAlpha(100), - selectionHandleColor: themeColor, - ), - indicatorColor: themeColor, - appBarTheme: AppBarTheme( - backgroundColor: Colors.grey[850], - systemOverlayStyle: const SystemUiOverlayStyle( - statusBarBrightness: Brightness.dark, - statusBarIconBrightness: Brightness.light, - ), - iconTheme: const IconThemeData(color: Colors.white), - elevation: 0, - ), - bottomAppBarTheme: BottomAppBarTheme( - color: Colors.grey[850], - ), - buttonTheme: ButtonThemeData(buttonColor: themeColor), - iconTheme: const IconThemeData(color: Colors.white), - checkboxTheme: CheckboxThemeData( - checkColor: MaterialStateProperty.all(Colors.white), - fillColor: MaterialStateProperty.resolveWith((states) { - if (states.contains(MaterialState.selected)) { - return themeColor; - } - return null; - }), - side: const BorderSide(color: Colors.white), - ), - colorScheme: ColorScheme( - primary: Colors.grey[900]!, - secondary: themeColor, - background: Colors.grey[900]!, - surface: Colors.grey[900]!, - brightness: Brightness.dark, - error: const Color(0xffcf6679), - onPrimary: Colors.black, - onSecondary: Colors.grey[850]!, - onSurface: Colors.white, - onBackground: Colors.white, - onError: Colors.black, - ), - ); + return buildTheme(themeColor, light: light); } } diff --git a/lib/src/delegates/asset_picker_viewer_builder_delegate.dart b/lib/src/delegates/asset_picker_viewer_builder_delegate.dart index 6b61daac..e2106343 100644 --- a/lib/src/delegates/asset_picker_viewer_builder_delegate.dart +++ b/lib/src/delegates/asset_picker_viewer_builder_delegate.dart @@ -6,7 +6,7 @@ import 'dart:async'; import 'dart:math' as math; import 'package:extended_image/extended_image.dart'; -import 'package:flutter/material.dart'; +import 'package:flutter/material.dart' hide Path; import 'package:flutter/semantics.dart'; import 'package:flutter/services.dart'; import 'package:photo_manager/photo_manager.dart'; diff --git a/lib/src/provider/asset_picker_provider.dart b/lib/src/provider/asset_picker_provider.dart index 043e5670..e3dae85e 100644 --- a/lib/src/provider/asset_picker_provider.dart +++ b/lib/src/provider/asset_picker_provider.dart @@ -7,7 +7,7 @@ import 'dart:io'; import 'dart:math' as math; import 'dart:typed_data'; -import 'package:flutter/material.dart'; +import 'package:flutter/material.dart' hide Path; import 'package:photo_manager/photo_manager.dart'; import 'package:provider/provider.dart'; diff --git a/lib/src/widget/asset_picker.dart b/lib/src/widget/asset_picker.dart index 3db19a60..f23d5673 100644 --- a/lib/src/widget/asset_picker.dart +++ b/lib/src/widget/asset_picker.dart @@ -5,7 +5,7 @@ import 'dart:async'; import 'dart:io'; -import 'package:flutter/material.dart'; +import 'package:flutter/material.dart' hide Path; import 'package:flutter/services.dart'; import 'package:photo_manager/photo_manager.dart'; import 'package:wechat_picker_library/wechat_picker_library.dart'; diff --git a/lib/src/widget/asset_picker_app_bar.dart b/lib/src/widget/asset_picker_app_bar.dart index 3f1c51b8..a79daea7 100644 --- a/lib/src/widget/asset_picker_app_bar.dart +++ b/lib/src/widget/asset_picker_app_bar.dart @@ -105,7 +105,7 @@ class AssetPickerAppBar extends StatelessWidget implements PreferredSizeWidget { @override Widget build(BuildContext context) { final ThemeData theme = Theme.of(context); - final AppBarTheme appBarTheme = theme.appBarTheme; + final appBarTheme = theme.appBarTheme; final Widget? titleWidget; if (centerTitle) { diff --git a/lib/src/widget/asset_picker_viewer.dart b/lib/src/widget/asset_picker_viewer.dart index b01744f7..42853440 100644 --- a/lib/src/widget/asset_picker_viewer.dart +++ b/lib/src/widget/asset_picker_viewer.dart @@ -4,7 +4,7 @@ import 'dart:async'; -import 'package:flutter/material.dart'; +import 'package:flutter/material.dart' hide Path; import 'package:photo_manager/photo_manager.dart'; import '../constants/constants.dart'; diff --git a/lib/src/widget/builder/audio_page_builder.dart b/lib/src/widget/builder/audio_page_builder.dart index 5dc43ef1..b8ff3dfd 100644 --- a/lib/src/widget/builder/audio_page_builder.dart +++ b/lib/src/widget/builder/audio_page_builder.dart @@ -201,7 +201,7 @@ class _AudioPageBuilderState extends State { onLongPressHint: Singleton.textDelegate.semanticsTextDelegate.sActionPlayHint, child: ColoredBox( - color: context.theme.colorScheme.background, + color: context.theme.colorScheme.surface, child: isLoaded ? Column( mainAxisAlignment: MainAxisAlignment.center, diff --git a/pubspec.yaml b/pubspec.yaml index 139b96b1..6a9037f9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: wechat_assets_picker -version: 9.7.0 +version: 9.8.0 description: | An image picker (also with videos and audio) for Flutter projects based on WeChat's UI, @@ -22,7 +22,7 @@ dependencies: flutter: sdk: flutter - wechat_picker_library: ^1.0.5 + wechat_picker_library: ^1.0.7 extended_image: '>=8.3.0 <11.0.0' photo_manager: ^3.5.0