Skip to content

Commit fb5c6ec

Browse files
committed
💄 Introduce ColorScheme for theme details.
Related to #32 , but this needs further tests.
1 parent e99eee5 commit fb5c6ec

File tree

5 files changed

+81
-41
lines changed

5 files changed

+81
-41
lines changed

lib/src/widget/asset_picker.dart

Lines changed: 42 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,21 @@ class AssetPicker extends StatelessWidget {
210210
brightness: Brightness.dark,
211211
elevation: 0,
212212
),
213+
colorScheme: ColorScheme(
214+
primary: Colors.grey[900],
215+
primaryVariant: Colors.grey[900],
216+
secondary: themeColor,
217+
secondaryVariant: themeColor,
218+
background: Colors.grey[900],
219+
surface: Colors.grey[900],
220+
brightness: Brightness.dark,
221+
error: const Color(0xffcf6679),
222+
onPrimary: Colors.black,
223+
onSecondary: Colors.black,
224+
onSurface: Colors.white,
225+
onBackground: Colors.white,
226+
onError: Colors.black,
227+
),
213228
);
214229

215230
/// [ThemeData] for picker.
@@ -260,15 +275,15 @@ class AssetPicker extends StatelessWidget {
260275
child: Container(
261276
decoration: BoxDecoration(
262277
shape: BoxShape.circle,
263-
color: theme.dividerColor.withAlpha(150),
278+
color: theme.iconTheme.color.withOpacity(0.5),
264279
),
265280
child: Transform.rotate(
266281
angle: provider.isSwitchingPath ? math.pi : 0.0,
267282
alignment: Alignment.center,
268-
child: const Icon(
283+
child: Icon(
269284
Icons.keyboard_arrow_down,
270-
color: Colors.black,
271285
size: 20.0,
286+
color: theme.colorScheme.primary,
272287
),
273288
),
274289
),
@@ -492,20 +507,15 @@ class AssetPicker extends StatelessWidget {
492507
shape: RoundedRectangleBorder(
493508
borderRadius: BorderRadius.circular(3.0),
494509
),
495-
elevation: 0.0,
496-
disabledElevation: 0.0,
497-
focusElevation: 0.0,
498-
highlightElevation: 0.0,
499-
hoverElevation: 0.0,
500510
child: Text(
501511
provider.isSelectedNotEmpty && !isSingleAssetMode
502512
? '${Constants.textDelegate.confirm}'
503513
'(${provider.selectedAssets.length}/${provider.maxAssets})'
504514
: Constants.textDelegate.confirm,
505515
style: TextStyle(
506516
color: provider.isSelectedNotEmpty
507-
? Colors.white
508-
: Colors.grey[600],
517+
? theme.textTheme.bodyText1.color
518+
: theme.textTheme.caption.color,
509519
fontSize: 17.0,
510520
fontWeight: FontWeight.normal,
511521
),
@@ -575,7 +585,7 @@ class AssetPicker extends StatelessWidget {
575585
gradient: LinearGradient(
576586
begin: AlignmentDirectional.bottomCenter,
577587
end: AlignmentDirectional.topCenter,
578-
colors: <Color>[Colors.black45, Colors.transparent],
588+
colors: <Color>[theme.dividerColor, Colors.transparent],
579589
),
580590
),
581591
child: Padding(
@@ -592,6 +602,12 @@ class AssetPicker extends StatelessWidget {
592602

593603
/// Video asset type indicator.
594604
/// 视频类型资源指示
605+
///
606+
/// Videos often contains various of color in the cover,
607+
/// so in order to keep the content visible in most cases,
608+
/// the color of the indicator has been set to [Colors.white].
609+
/// 视频封面通常包含各种颜色,为了保证内容在一般情况下可见,此处
610+
/// 将指示器的图标和文字设置为 [Colors.white]
595611
Widget videoIndicator(AssetEntity asset) {
596612
return Align(
597613
alignment: AlignmentDirectional.bottomStart,
@@ -608,13 +624,20 @@ class AssetPicker extends StatelessWidget {
608624
),
609625
child: Row(
610626
children: <Widget>[
611-
Icon(Icons.videocam, size: 24.0),
627+
Icon(
628+
Icons.videocam,
629+
size: 24.0,
630+
color: Colors.white,
631+
),
612632
Padding(
613633
padding: const EdgeInsets.only(left: 4.0),
614634
child: Text(
615635
Constants.textDelegate.durationIndicatorBuilder(
616636
Duration(seconds: asset.duration)),
617-
style: const TextStyle(fontSize: 16.0),
637+
style: const TextStyle(
638+
color: Colors.white,
639+
fontSize: 16.0,
640+
),
618641
),
619642
),
620643
],
@@ -655,7 +678,7 @@ class AssetPicker extends StatelessWidget {
655678
);
656679
}
657680

658-
/// Indicator for asset selected status.
681+
/// Indicator for assets selected status.
659682
/// 资源是否已选的指示器
660683
Widget _selectIndicator(AssetEntity asset) {
661684
return Selector<AssetPickerProvider, List<AssetEntity>>(
@@ -719,7 +742,10 @@ class AssetPicker extends StatelessWidget {
719742
child: Text(
720743
Constants.textDelegate.loadFailed,
721744
textAlign: TextAlign.center,
722-
style: TextStyle(color: Colors.white, fontSize: 18.0),
745+
style: const TextStyle(
746+
color: Colors.white,
747+
fontSize: 18.0,
748+
),
723749
),
724750
);
725751

@@ -797,7 +823,7 @@ class AssetPicker extends StatelessWidget {
797823
gradient: LinearGradient(
798824
begin: AlignmentDirectional.topCenter,
799825
end: AlignmentDirectional.bottomCenter,
800-
colors: <Color>[Colors.black45, Colors.transparent],
826+
colors: <Color>[theme.dividerColor, Colors.transparent],
801827
),
802828
),
803829
child: Padding(

lib/src/widget/asset_picker_viewer.dart

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ class AssetPickerViewerState extends State<AssetPickerViewer>
298298
height: Screens.topSafeHeight + kToolbarHeight,
299299
child: Container(
300300
padding: EdgeInsets.only(top: Screens.topSafeHeight, right: 12.0),
301-
color: Colors.grey[850].withOpacity(0.95),
301+
color: widget.themeData.canvasColor.withOpacity(0.85),
302302
child: Row(
303303
children: <Widget>[
304304
const BackButton(),
@@ -310,7 +310,6 @@ class AssetPickerViewerState extends State<AssetPickerViewer>
310310
return Text(
311311
'${snapshot.data + 1}/${widget.assets.length}',
312312
style: TextStyle(
313-
color: Colors.grey[200],
314313
fontSize: 18.0,
315314
fontWeight: FontWeight.bold,
316315
),
@@ -346,7 +345,7 @@ class AssetPickerViewerState extends State<AssetPickerViewer>
346345
height: 32.0,
347346
padding: const EdgeInsets.symmetric(horizontal: 12.0),
348347
color: provider.isSelectedNotEmpty
349-
? widget.themeData.buttonColor
348+
? widget.themeData.colorScheme.secondary
350349
: widget.themeData.dividerColor,
351350
shape: RoundedRectangleBorder(
352351
borderRadius: BorderRadius.circular(3.0),
@@ -396,9 +395,11 @@ class AssetPickerViewerState extends State<AssetPickerViewer>
396395
}
397396
},
398397
child: Selector<AssetPickerViewerProvider, List<AssetEntity>>(
399-
selector:
400-
(BuildContext _, AssetPickerViewerProvider provider) =>
401-
provider.currentlySelectedAssets,
398+
selector: (
399+
BuildContext _,
400+
AssetPickerViewerProvider provider,
401+
) =>
402+
provider.currentlySelectedAssets,
402403
builder: (
403404
BuildContext _,
404405
List<AssetEntity> currentlySelectedAssets,
@@ -432,7 +433,7 @@ class AssetPickerViewerState extends State<AssetPickerViewer>
432433
decoration: BoxDecoration(
433434
border: isViewing
434435
? Border.all(
435-
color: widget.themeData.buttonColor,
436+
color: widget.themeData.colorScheme.secondary,
436437
width: 2.0,
437438
)
438439
: null,
@@ -482,7 +483,12 @@ class AssetPickerViewerState extends State<AssetPickerViewer>
482483
child: Stack(
483484
children: <Widget>[
484485
_imagePreviewItem(asset),
485-
Center(child: Icon(Icons.video_library)),
486+
Center(
487+
child: Icon(
488+
Icons.video_library,
489+
color: Colors.white54,
490+
),
491+
),
486492
],
487493
),
488494
);
@@ -609,7 +615,7 @@ class AssetPickerViewerState extends State<AssetPickerViewer>
609615
height: Screens.bottomSafeHeight + bottomDetailHeight,
610616
child: Container(
611617
padding: EdgeInsets.only(bottom: Screens.bottomSafeHeight),
612-
color: widget.themeData.canvasColor.withOpacity(0.95),
618+
color: widget.themeData.canvasColor.withOpacity(0.85),
613619
child: Column(
614620
children: <Widget>[
615621
ChangeNotifierProvider<AssetPickerViewerProvider>.value(
@@ -668,7 +674,9 @@ class AssetPickerViewerState extends State<AssetPickerViewer>
668674
child: Theme(
669675
data: widget.themeData,
670676
child: AnnotatedRegion<SystemUiOverlayStyle>(
671-
value: SystemUiOverlayStyle.light,
677+
value: widget.themeData.brightness.isDark
678+
? SystemUiOverlayStyle.light
679+
: SystemUiOverlayStyle.dark,
672680
child: Material(
673681
color: Colors.black,
674682
child: Stack(

lib/src/widget/builder/audio_page_builder.dart

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -147,19 +147,22 @@ class _AudioPageBuilderState extends State<AudioPageBuilder> {
147147

148148
@override
149149
Widget build(BuildContext context) {
150-
return isLoaded
151-
? AudioWidget(
152-
audio: audio,
153-
play: audioPlayer.isPlaying.value,
154-
child: Column(
155-
mainAxisAlignment: MainAxisAlignment.center,
156-
children: <Widget>[
157-
titleWidget,
158-
audioControlButton,
159-
durationIndicator,
160-
],
161-
),
162-
)
163-
: const SizedBox.shrink();
150+
return ColoredBox(
151+
color: context.themeData.backgroundColor,
152+
child: isLoaded
153+
? AudioWidget(
154+
audio: audio,
155+
play: audioPlayer.isPlaying.value,
156+
child: Column(
157+
mainAxisAlignment: MainAxisAlignment.center,
158+
children: <Widget>[
159+
titleWidget,
160+
audioControlButton,
161+
durationIndicator,
162+
],
163+
),
164+
)
165+
: const SizedBox.shrink(),
166+
);
164167
}
165168
}

lib/src/widget/builder/video_page_builder.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ class _VideoPageBuilderState extends State<VideoPageBuilder> {
151151
? Icons.pause_circle_outline
152152
: Icons.play_circle_filled,
153153
size: 70.0,
154+
color: Colors.white,
154155
),
155156
),
156157
),

lib/src/widget/fixed_appbar.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,9 @@ class FixedAppBar extends StatelessWidget {
143143
type: color.isTransparent
144144
? MaterialType.transparency
145145
: MaterialType.canvas,
146-
color: (backgroundColor ?? Theme.of(context).primaryColor)
146+
color: (backgroundColor ??
147+
context.themeData.appBarTheme.color ??
148+
context.themeData.primaryColor)
147149
.withOpacity(blurRadius > 0.0 ? 0.90 : 1.0),
148150
elevation: elevation ?? context.themeData.appBarTheme.elevation ?? 4.0,
149151
child: child,

0 commit comments

Comments
 (0)