浏览代码

fix theme && locale text

lucky1213 4 年前
父节点
当前提交
bd230c30f0
共有 2 个文件被更改,包括 27 次插入10 次删除
  1. 18
    9
      packages/zefyr/lib/src/widgets/buttons.dart
  2. 9
    1
      packages/zefyr/lib/src/widgets/theme.dart

+ 18
- 9
packages/zefyr/lib/src/widgets/buttons.dart 查看文件

@@ -560,6 +560,13 @@ class _ImageButtonState extends State<ImageButton> {
560 560
     }
561 561
   }
562 562
 
563
+  String get uploadText => Localizations.localeOf(context) == Locale('zh', 'CN') ? '上传' : 'Upload';
564
+  String get fullImageText => Localizations.localeOf(context) == Locale('zh', 'CN') ? '原图' : 'Full image';
565
+  String get camera => Localizations.localeOf(context) == Locale('zh', 'CN') ? '拍照' : 'Camera';
566
+  String get album => Localizations.localeOf(context) == Locale('zh', 'CN') ? '相册' : 'Album';
567
+  I18nProvider get locale => Localizations.localeOf(context) == Locale('zh', 'CN') ? I18nProvider.chinese : I18nProvider.english;
568
+
569
+
563 570
   Widget buildOverlay(BuildContext context) {
564 571
     final theme = ZefyrTheme.of(context).toolbarTheme;
565 572
     final toolbar = ZefyrToolbar.of(context);
@@ -586,7 +593,8 @@ class _ImageButtonState extends State<ImageButton> {
586 593
                           Expanded(
587 594
                             child: FlatButton(
588 595
                                 shape: RoundedRectangleBorder(),
589
-                                color: Color(0xFFF6F6F6),
596
+                                color: theme.captionColor,
597
+                                padding: EdgeInsets.zero,
590 598
                                 onPressed: () async {
591 599
                                   // toolbar.editor.tapHandle =
592 600
                                   //     TapHandle.takePhoto;
@@ -594,7 +602,7 @@ class _ImageButtonState extends State<ImageButton> {
594 602
                                       source: ImageSource.camera);
595 603
                                   if (file != null) {
596 604
                                     toolbar.closeOverlay();
597
-                                    final image = await toolbar
605
+                                    await toolbar
598 606
                                         .editor.imageDelegate
599 607
                                         .picked(file, true);
600 608
                                   }
@@ -612,7 +620,7 @@ class _ImageButtonState extends State<ImageButton> {
612 620
                                       Padding(
613 621
                                         padding: EdgeInsets.only(top: 6),
614 622
                                         child: Text(
615
-                                          '拍照',
623
+                                          camera,
616 624
                                           style: TextStyle(
617 625
                                             fontSize: 12,
618 626
                                             color: Color(0xFF8C8C8C),
@@ -626,7 +634,8 @@ class _ImageButtonState extends State<ImageButton> {
626 634
                           Expanded(
627 635
                             child: FlatButton(
628 636
                                 shape: RoundedRectangleBorder(),
629
-                                color: Color(0xFFF6F6F6),
637
+                                color: theme.captionColor,
638
+                                padding: EdgeInsets.zero,
630 639
                                 onPressed: () {
631 640
                                   final editor =
632 641
                                       ZefyrToolbar.of(context).editor;
@@ -637,7 +646,7 @@ class _ImageButtonState extends State<ImageButton> {
637 646
                                     rowCount: 4,
638 647
                                     itemRadio: 1,
639 648
                                     padding: 4,
640
-                                    provider: I18nProvider.chinese,
649
+                                    provider: locale,
641 650
                                     sortDelegate: SortDelegate.common,
642 651
                                     pickType: PickType.onlyImage,
643 652
                                     photoPathList: null,
@@ -670,7 +679,7 @@ class _ImageButtonState extends State<ImageButton> {
670 679
                                       Padding(
671 680
                                         padding: EdgeInsets.only(top: 6),
672 681
                                         child: Text(
673
-                                          '相册',
682
+                                          album,
674 683
                                           style: TextStyle(
675 684
                                             fontSize: 12,
676 685
                                             color: Color(0xFF8C8C8C),
@@ -699,7 +708,7 @@ class _ImageButtonState extends State<ImageButton> {
699 708
                               padding: 4,
700 709
                               thumbSize: 300,
701 710
                               itemRadio: 0.5,
702
-                              provider: I18nProvider.chinese,
711
+                              provider: locale,
703 712
                               sortDelegate: SortDelegate.common,
704 713
                               pickType: PickType.onlyImage,
705 714
                               photoPathList: null,
@@ -743,7 +752,7 @@ class _ImageButtonState extends State<ImageButton> {
743 752
                                     padding:
744 753
                                         EdgeInsets.symmetric(horizontal: 8),
745 754
                                     child: Text(
746
-                                      '原图',
755
+                                      fullImageText,
747 756
                                       style: TextStyle(
748 757
                                           color: theme.iconColor, fontSize: 16),
749 758
                                     ),
@@ -800,7 +809,7 @@ class _ImageButtonState extends State<ImageButton> {
800 809
                           alignment: Alignment.center,
801 810
                           padding: EdgeInsets.symmetric(horizontal: 20),
802 811
                           child: Text(
803
-                            '上传 ${snapshot.data.asset.isNotEmpty ? "(${snapshot.data.asset.length})" : ''}',
812
+                            '$uploadText ${snapshot.data.asset.isNotEmpty ? "(${snapshot.data.asset.length})" : ''}',
804 813
                             style: TextStyle(
805 814
                               color: Colors.white,
806 815
                               fontSize: 14,

+ 9
- 1
packages/zefyr/lib/src/widgets/theme.dart 查看文件

@@ -595,6 +595,8 @@ class ToolbarTheme {
595 595
   
596 596
   final Color dividerColor;
597 597
 
598
+  final Color captionColor;
599
+
598 600
   /// Creates default theme for editor toolbar.
599 601
   factory ToolbarTheme.fallback(BuildContext context) {
600 602
     final theme = Theme.of(context);
@@ -605,6 +607,7 @@ class ToolbarTheme {
605 607
       iconFillColor: theme.brightness == Brightness.light ? Color(0xFFF2F2F2) : Color(0xFF1F1F1F),
606 608
       iconColor: Color(0xFF595959),
607 609
       disabledIconColor: theme.brightness == Brightness.light ? Color(0xFFBFBFBF) : Color(0xFF363636),
610
+      captionColor: theme.brightness == Brightness.light ? Color(0xFFF6F6F6) : Color(0xFF1B1B1B),
608 611
       dividerColor: theme.brightness == Brightness.light ? Color(0x0D1C202B) : Color(0xFF3B3B3B),
609 612
     );
610 613
   }
@@ -617,6 +620,7 @@ class ToolbarTheme {
617 620
     @required this.iconColor,
618 621
     @required this.disabledIconColor,
619 622
     @required this.dividerColor,
623
+    @required this.captionColor,
620 624
   });
621 625
 
622 626
   /// Creates a new [ToolbarTheme] where each property from this object has
@@ -629,6 +633,7 @@ class ToolbarTheme {
629 633
     Color iconColor,
630 634
     Color disabledIconColor,
631 635
     Color dividerColor,
636
+    Color captionColor,
632 637
   }) {
633 638
     return ToolbarTheme._(
634 639
       color: color ?? this.color,
@@ -638,6 +643,7 @@ class ToolbarTheme {
638 643
       iconColor: iconColor ?? this.iconColor,
639 644
       disabledIconColor: disabledIconColor ?? this.disabledIconColor,
640 645
       dividerColor: dividerColor ?? this.dividerColor,
646
+      captionColor: captionColor ?? this.captionColor,
641 647
     );
642 648
   }
643 649
 
@@ -653,6 +659,7 @@ class ToolbarTheme {
653 659
       iconColor: other.iconColor ?? iconColor,
654 660
       disabledIconColor: other.disabledIconColor ?? disabledIconColor,
655 661
       dividerColor: other.dividerColor ?? dividerColor,
662
+      captionColor: other.captionColor ?? captionColor,
656 663
     );
657 664
   }
658 665
 
@@ -666,10 +673,11 @@ class ToolbarTheme {
666 673
         (otherTheme.iconFillColor == iconFillColor) &&
667 674
         (otherTheme.iconColor == iconColor) &&
668 675
         (otherTheme.disabledIconColor == disabledIconColor) &&
676
+        (otherTheme.captionColor == captionColor) &&
669 677
         (otherTheme.dividerColor == dividerColor);
670 678
   }
671 679
 
672 680
   @override
673 681
   int get hashCode =>
674
-      hashValues(color, surfaceColor, toggleColor, iconFillColor, iconColor, disabledIconColor, dividerColor);
682
+      hashValues(color, surfaceColor, toggleColor, iconFillColor, iconColor, disabledIconColor, dividerColor, captionColor);
675 683
 }