Browse Source

fix theme && locale text

lucky1213 4 years ago
parent
commit
bd230c30f0

+ 18
- 9
packages/zefyr/lib/src/widgets/buttons.dart View File

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

+ 9
- 1
packages/zefyr/lib/src/widgets/theme.dart View File

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