Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
Expand Down
2 changes: 1 addition & 1 deletion example/lib/customs/pickers/insta_asset_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 6 additions & 5 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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,
),
);
}

Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
10 changes: 5 additions & 5 deletions lib/src/delegates/asset_picker_builder_delegate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -564,7 +564,7 @@ abstract class AssetPickerBuilderDelegate<Asset, Path> {
builder: (_, AssetPickerProvider<Asset, Path> 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();
Expand Down Expand Up @@ -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,
),
),
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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,
Expand Down
113 changes: 4 additions & 109 deletions lib/src/delegates/asset_picker_delegate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion lib/src/provider/asset_picker_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion lib/src/widget/asset_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion lib/src/widget/asset_picker_app_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/widget/asset_picker_viewer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion lib/src/widget/builder/audio_page_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class _AudioPageBuilderState extends State<AudioPageBuilder> {
onLongPressHint:
Singleton.textDelegate.semanticsTextDelegate.sActionPlayHint,
child: ColoredBox(
color: context.theme.colorScheme.background,
color: context.theme.colorScheme.surface,
child: isLoaded
? Column(
mainAxisAlignment: MainAxisAlignment.center,
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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
Expand Down
Loading