Skip to content

Commit 4f80aa5

Browse files
committed
💄 Update widgets style on iOS. Fix #14 .
1 parent 6253bfe commit 4f80aa5

File tree

2 files changed

+79
-47
lines changed

2 files changed

+79
-47
lines changed

lib/src/widget/asset_picker.dart

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ class AssetPicker extends StatelessWidget {
227227
splashFactory: InkSplash.splashFactory,
228228
onTap: () => provider.switchPath(pathEntity),
229229
child: SizedBox(
230-
height: 50.0,
230+
height: isIOS ? 64.0 : 52.0,
231231
child: Row(
232232
children: <Widget>[
233233
RepaintBoundary(
@@ -419,7 +419,13 @@ class AssetPicker extends StatelessWidget {
419419
color:
420420
provider.isSelectedNotEmpty ? themeColor : theme.dividerColor,
421421
shape: RoundedRectangleBorder(
422-
borderRadius: BorderRadius.circular(3.0)),
422+
borderRadius: BorderRadius.circular(3.0),
423+
),
424+
elevation: 0.0,
425+
disabledElevation: 0.0,
426+
focusElevation: 0.0,
427+
highlightElevation: 0.0,
428+
hoverElevation: 0.0,
423429
child: Text(
424430
provider.isSelectedNotEmpty
425431
? '${Constants.textDelegate.confirm}'
@@ -465,13 +471,21 @@ class AssetPicker extends StatelessWidget {
465471
horizontal: 2.0,
466472
vertical: 2.0,
467473
),
468-
decoration: BoxDecoration(
469-
borderRadius: BorderRadius.circular(2.0),
470-
color: theme.iconTheme.color.withOpacity(0.75),
471-
),
474+
decoration: !isIOS
475+
? BoxDecoration(
476+
borderRadius: BorderRadius.circular(2.0),
477+
color: theme.iconTheme.color.withOpacity(0.75),
478+
)
479+
: null,
472480
child: Text(
473481
Constants.textDelegate.gifIndicator,
474-
style: TextStyle(color: theme.primaryColor, fontSize: 12.0),
482+
style: TextStyle(
483+
color: isIOS
484+
? theme.textTheme.bodyText2.color
485+
: theme.primaryColor,
486+
fontSize: isIOS ? 14.0 : 12.0,
487+
fontWeight: isIOS ? FontWeight.w500 : FontWeight.normal,
488+
),
475489
),
476490
),
477491
),
@@ -563,9 +577,9 @@ class AssetPicker extends StatelessWidget {
563577
},
564578
child: AnimatedContainer(
565579
duration: switchingPathDuration,
566-
margin: const EdgeInsets.all(6.0),
567-
width: 20.0,
568-
height: 20.0,
580+
margin: EdgeInsets.all(isIOS ? 10.0 : 6.0),
581+
width: isIOS ? 28.0 : 20.0,
582+
height: isIOS ? 28.0 : 20.0,
569583
decoration: BoxDecoration(
570584
border: !selected
571585
? Border.all(color: Colors.white, width: 2.0)
@@ -579,8 +593,12 @@ class AssetPicker extends StatelessWidget {
579593
child: selected
580594
? Text(
581595
'${selectedAssets.toList().indexOf(asset) + 1}',
582-
style:
583-
TextStyle(color: Colors.white, fontSize: 14.0),
596+
style: TextStyle(
597+
color: Colors.white,
598+
fontSize: isIOS ? 16.0 : 14.0,
599+
fontWeight:
600+
isIOS ? FontWeight.w600 : FontWeight.normal,
601+
),
584602
)
585603
: const SizedBox.shrink(),
586604
),
@@ -768,12 +786,16 @@ class AssetPicker extends StatelessWidget {
768786
child: isIOS
769787
? GestureDetector(
770788
onTap: Navigator.of(context).maybePop,
771-
child: SizedBox(
772-
width: 60.0,
773-
child: Center(
774-
child: Text(
775-
Constants.textDelegate.cancel,
776-
style: const TextStyle(fontSize: 18.0),
789+
child: Container(
790+
margin: isIOS
791+
? const EdgeInsets.symmetric(horizontal: 20.0)
792+
: null,
793+
child: IntrinsicWidth(
794+
child: Center(
795+
child: Text(
796+
Constants.textDelegate.cancel,
797+
style: const TextStyle(fontSize: 18.0),
798+
),
777799
),
778800
),
779801
),

lib/src/widget/asset_picker_viewer.dart

Lines changed: 39 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ class AssetPickerViewerState extends State<AssetPickerViewer>
141141
/// 底部详情部件的高度
142142
double get bottomDetailHeight => 140.0;
143143

144+
/// Whether the current platform is iOS.
145+
/// 当前平台是否iOS
146+
bool get isIOS => Platform.isIOS;
147+
144148
@override
145149
void initState() {
146150
super.initState();
@@ -329,37 +333,43 @@ class AssetPickerViewerState extends State<AssetPickerViewer>
329333
/// 资源选择器将识别并一同返回。
330334
Widget confirmButton(BuildContext context) =>
331335
Consumer<AssetPickerViewerProvider>(
332-
builder:
333-
(BuildContext _, AssetPickerViewerProvider provider, Widget __) {
334-
return MaterialButton(
335-
minWidth: provider.isSelectedNotEmpty ? 48.0 : 20.0,
336-
height: 32.0,
337-
padding: const EdgeInsets.symmetric(horizontal: 12.0),
338-
color: provider.isSelectedNotEmpty
339-
? widget.themeData.buttonColor
340-
: widget.themeData.dividerColor,
341-
shape: RoundedRectangleBorder(
342-
borderRadius: BorderRadius.circular(3.0)),
343-
child: Text(
344-
provider.isSelectedNotEmpty
345-
? '${Constants.textDelegate.confirm}(${provider.currentlySelectedAssets.length}'
346-
'/'
347-
'${widget.selectorProvider.maxAssets})'
348-
: Constants.textDelegate.confirm,
349-
style: TextStyle(
350-
color: provider.isSelectedNotEmpty
351-
? Colors.white
352-
: Colors.grey[600],
353-
fontSize: 17.0,
354-
fontWeight: FontWeight.normal,
336+
builder: (
337+
BuildContext _,
338+
AssetPickerViewerProvider provider,
339+
Widget __,
340+
) {
341+
return Container(
342+
margin: isIOS ? const EdgeInsets.only(right: 10.0) : null,
343+
child: MaterialButton(
344+
minWidth: provider.isSelectedNotEmpty ? 48.0 : 20.0,
345+
height: 32.0,
346+
padding: const EdgeInsets.symmetric(horizontal: 12.0),
347+
color: provider.isSelectedNotEmpty
348+
? widget.themeData.buttonColor
349+
: widget.themeData.dividerColor,
350+
shape: RoundedRectangleBorder(
351+
borderRadius: BorderRadius.circular(3.0)),
352+
child: Text(
353+
provider.isSelectedNotEmpty
354+
? '${Constants.textDelegate.confirm}(${provider.currentlySelectedAssets.length}'
355+
'/'
356+
'${widget.selectorProvider.maxAssets})'
357+
: Constants.textDelegate.confirm,
358+
style: TextStyle(
359+
color: provider.isSelectedNotEmpty
360+
? Colors.white
361+
: Colors.grey[600],
362+
fontSize: 17.0,
363+
fontWeight: FontWeight.normal,
364+
),
355365
),
366+
onPressed: () {
367+
if (provider.isSelectedNotEmpty) {
368+
Navigator.of(context).pop(provider.currentlySelectedAssets);
369+
}
370+
},
371+
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
356372
),
357-
onPressed: () {
358-
if (provider.isSelectedNotEmpty) {
359-
Navigator.of(context).pop(provider.currentlySelectedAssets);
360-
}
361-
},
362-
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
363373
);
364374
},
365375
);

0 commit comments

Comments
 (0)