-
Notifications
You must be signed in to change notification settings - Fork 120
Expand file tree
/
Copy paththeme_data.dart
More file actions
1401 lines (1318 loc) · 51.9 KB
/
theme_data.dart
File metadata and controls
1401 lines (1318 loc) · 51.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:collection/collection.dart';
import 'package:meta/meta.dart';
import 'package:forui/forui.dart';
part 'theme_data.design.dart';
/// Defines the configuration of the overall visual [FTheme] for a widget subtree.
///
/// A [FThemeData] is composed of [colors], [typography], [style], widget styles, and [extensions].
///
/// * [colors] is a set of colors.
/// * [typography] contains font and typography information.
/// * [style] is a set of miscellaneous properties.
/// * widget styles are used to style individual Forui widgets.
/// * [extensions] are arbitrary additions to this theme. They are typically used to define properties specific to your
/// application.
///
/// Widget styles provide an `inherit(...)` constructor. The constructor configures the widget style using the defaults
/// provided by the [colors], [typography], and [style].
final class FThemeData with Diagnosticable, _$FThemeDataFunctions {
/// A label that is used in the [toString] output. Intended to aid with identifying themes in debug output.
@override
final String? debugLabel;
/// The responsive breakpoints.
@override
final FBreakpoints breakpoints;
/// The color scheme. It is used to configure the colors of Forui widgets.
@override
final FColors colors;
/// The typography data. It is used to configure the [TextStyle]s of Forui widgets.
@override
final FTypography typography;
/// The style. It is used to configure the miscellaneous properties, such as border radii, of Forui widgets.
@override
final FStyle style;
/// The accordion style.
///
/// ## CLI
/// To generate and customize this style:
///
/// ```shell
/// dart run forui style create accordion
/// ```
@override
final FAccordionStyle accordionStyle;
/// The autocomplete style.
///
/// ## CLI
/// To generate and customize this style:
///
/// ```shell
/// dart run forui style create autocomplete
/// ```
@override
final FAutocompleteStyle autocompleteStyle;
/// The alert styles.
///
/// ## CLI
/// To generate and customize this style:
///
/// ```shell
/// dart run forui style create alerts
/// ```
@override
final FAlertStyles alertStyles;
/// The avatar style.
///
/// ## CLI
/// To generate and customize this style:
///
/// ```shell
/// dart run forui style create avatar
/// ```
@override
final FAvatarStyle avatarStyle;
/// The badge styles.
///
/// ## CLI
/// To generate and customize this style:
///
/// ```shell
/// dart run forui style create badges
/// ```
@override
final FBadgeStyles badgeStyles;
/// The bottom navigation bar style.
///
/// ## CLI
/// To generate and customize this style:
///
/// ```shell
/// dart run forui style create bottom-navigation-bar
/// ```
@override
final FBottomNavigationBarStyle bottomNavigationBarStyle;
/// The breadcrumb style.
///
/// ## CLI
/// To generate and customize this style:
///
/// ```shell
/// dart run forui style create breadcrumb
/// ```
@override
final FBreadcrumbStyle breadcrumbStyle;
/// The button styles.
///
/// ## CLI
/// To generate and customize this style:
///
/// ```shell
/// dart run forui style create buttons
/// ```
@override
final FButtonStyles buttonStyles;
/// The calendar style.
///
/// ## CLI
/// To generate and customize this style:
///
/// ```shell
/// dart run forui style create calendar
/// ```
@override
final FCalendarStyle calendarStyle;
/// The card style.
///
/// ## CLI
/// To generate and customize this style:
///
/// ```shell
/// dart run forui style create card
/// ```
@override
final FCardStyle cardStyle;
/// The checkbox style.
///
/// ## CLI
/// To generate and customize this style:
///
/// ```shell
/// dart run forui style create checkbox
/// ```
@override
final FCheckboxStyle checkboxStyle;
/// The circular progress style.
///
/// ## CLI
/// To generate and customize this style:
///
/// ```shell
/// dart run forui style create circular-progress
/// ```
@override
final FCircularProgressStyle circularProgressStyle;
/// The date field style.
///
/// ## CLI
/// To generate and customize this style:
///
/// ```shell
/// dart run forui style create date-field
/// ```
@override
final FDateFieldStyle dateFieldStyle;
/// The determinate progress style.
///
/// ## CLI
/// To generate and customize this style:
///
/// ```shell
/// dart run forui style create determinate-progress
/// ```
@override
final FDeterminateProgressStyle determinateProgressStyle;
/// The dialog route's style.
///
/// ## CLI
/// To generate and customize this style:
///
/// ```shell
/// dart run forui style create dialog-route
/// ```
@override
final FDialogRouteStyle dialogRouteStyle;
/// The dialog style.
///
/// ## CLI
/// To generate and customize this style:
///
/// ```shell
/// dart run forui style create dialog
/// ```
@override
final FDialogStyle dialogStyle;
/// The divider styles.
///
/// ## CLI
/// To generate and customize this style:
///
/// ```shell
/// dart run forui style create dividers
/// ```
@override
final FDividerStyles dividerStyles;
/// The header styles.
///
/// ## CLI
/// To generate and customize this style:
///
/// ```shell
/// dart run forui style create headers
/// ```
@override
final FHeaderStyles headerStyles;
/// The item style.
///
/// ## CLI
/// To generate and customize this style:
/// ```shell
/// dart run forui style create item
/// ```
@override
final FItemStyle itemStyle;
/// The item group style.
///
/// ## CLI
/// To generate and customize this style:
/// ```shell
/// dart run forui style create item-group
/// ```
@override
final FItemGroupStyle itemGroupStyle;
/// The label styles.
///
/// ## CLI
/// To generate and customize this style:
///
/// ```shell
/// dart run forui style create labels
/// ```
@override
final FLabelStyles labelStyles;
/// The line calendar style.
///
/// ## CLI
/// To generate and customize this style:
///
/// ```shell
/// dart run forui style create line-calendar
/// ```
@override
final FLineCalendarStyle lineCalendarStyle;
/// The multi-select style.
///
/// ## CLI
/// To generate and customize this style:
/// ```shell
/// dart run forui style create multi-select
/// ```
@override
final FMultiSelectStyle multiSelectStyle;
/// The modal sheet style.
///
/// ## CLI
/// To generate and customize this style:
///
/// ```shell
/// dart run forui style create modal-sheet
/// ```
@override
final FModalSheetStyle modalSheetStyle;
/// The pagination style.
///
/// ## CLI
/// To generate and customize this style:
///
/// ```shell
/// dart run forui style create pagination
/// ```
@override
final FPaginationStyle paginationStyle;
/// The persistent sheet style.
///
/// ## CLI
/// To generate and customize this style:
///
/// ```shell
/// dart run forui style create persistent-sheet
/// ```
@override
final FPersistentSheetStyle persistentSheetStyle;
/// The picker's style.
///
/// ## CLI
/// To generate and customize this style:
///
/// ```shell
/// dart run forui style create picker
/// ```
@override
final FPickerStyle pickerStyle;
/// The popover's style.
///
/// ## CLI
/// To generate and customize this style:
///
/// ```shell
/// dart run forui style create popover
/// ```
@override
final FPopoverStyle popoverStyle;
/// The popover menu's style.
///
/// ## CLI
/// To generate and customize this style:
///
/// ```shell
/// dart run forui style create popover-menu
/// ```
@override
final FPopoverMenuStyle popoverMenuStyle;
/// The progress style.
///
/// ## CLI
/// To generate and customize this style:
///
/// ```shell
/// dart run forui style create progress
/// ```
@override
final FProgressStyle progressStyle;
/// The radio style.
///
/// ## CLI
/// To generate and customize this style:
///
/// ```shell
/// dart run forui style create radio
/// ```
@override
final FRadioStyle radioStyle;
/// The resizable style.
///
/// ## CLI
/// To generate and customize this style:
///
/// ```shell
/// dart run forui style create resizable
/// ```
@override
final FResizableStyle resizableStyle;
/// The scaffold style.
///
/// ## CLI
/// To generate and customize this style:
///
/// ```shell
/// dart run forui style create scaffold
/// ```
@override
final FScaffoldStyle scaffoldStyle;
/// The select style.
///
/// ## CLI
/// To generate and customize this style:
///
/// ```shell
/// dart run forui style create select
/// ```
@override
final FSelectStyle selectStyle;
/// The select group style.
///
/// ## CLI
/// To generate and customize this style:
///
/// ```shell
/// dart run forui style create select-group
/// ```
@override
final FSelectGroupStyle selectGroupStyle;
/// The select menu tile style.
///
/// ## CLI
/// To generate and customize this style:
///
/// ```shell
/// dart run forui style create select-menu-tile
/// ```
@override
final FSelectMenuTileStyle selectMenuTileStyle;
/// The sidebar style.
///
/// ## CLI
/// To generate and customize this style:
///
/// ```shell
/// dart run forui style create sidebar
/// ```
@override
final FSidebarStyle sidebarStyle;
/// The slider styles.
///
/// ## CLI
/// To generate and customize this style:
///
/// ```shell
/// dart run forui style create sliders
/// ```
@override
final FSliderStyles sliderStyles;
/// The toaster style.
///
/// ## CLI
/// To generate and customize this style:
///
/// ```shell
/// dart run forui style create toaster
/// ```
@override
final FToasterStyle toasterStyle;
/// The switch style.
///
/// ## CLI
/// To generate and customize this style:
///
/// ```shell
/// dart run forui style create switch
/// ```
@override
final FSwitchStyle switchStyle;
/// The tabs styles.
///
/// ## CLI
/// To generate and customize this style:
///
/// ```shell
/// dart run forui style create tabs
/// ```
@override
final FTabsStyle tabsStyle;
/// The tappable style.
///
/// ## CLI
/// To generate and customize this style:
///
/// ```shell
/// dart run forui style create tappable
/// ```
@override
final FTappableStyle tappableStyle;
/// The text field style.
///
/// ## CLI
/// To generate and customize this style:
///
/// ```shell
/// dart run forui style create text-field
/// ```
@override
final FTextFieldStyle textFieldStyle;
/// The tile's style.
///
/// ## CLI
/// To generate and customize this style:
///
/// ```shell
/// dart run forui style create tile
/// ```
@override
final FTileStyle tileStyle;
/// The tile group's style.
///
/// ## CLI
/// To generate and customize this style:
///
/// ```shell
/// dart run forui style create tile-group
/// ```
@override
final FTileGroupStyle tileGroupStyle;
/// The tree style.
///
/// ## CLI
/// To generate and customize this style:
///
/// ```shell
/// dart run forui style create tree
/// ```
@override
final FTreeStyle treeStyle;
/// The time field's style.
///
/// ## CLI
/// To generate and customize this style:
///
/// ```shell
/// dart run forui style create time-field
/// ```
@override
final FTimeFieldStyle timeFieldStyle;
/// The time picker style.
///
/// ## CLI
/// To generate and customize this style:
///
/// ```shell
/// dart run forui style create time-picker
/// ```
@override
final FTimePickerStyle timePickerStyle;
/// The tooltip style.
///
/// ## CLI
/// To generate and customize this style:
///
/// ```shell
/// dart run forui style create tooltip
/// ```
@override
final FTooltipStyle tooltipStyle;
final Map<Object, ThemeExtension<dynamic>> _extensions;
/// Creates a [FThemeData] that configures the widget styles using the given properties if not given.
factory FThemeData({
required FColors colors,
String? debugLabel,
FBreakpoints breakpoints = const FBreakpoints(),
FTypography? typography,
FStyle? style,
FAccordionStyle? accordionStyle,
FAutocompleteStyle? autocompleteStyle,
FAlertStyles? alertStyles,
FAvatarStyle? avatarStyle,
FBadgeStyles? badgeStyles,
FBottomNavigationBarStyle? bottomNavigationBarStyle,
FBreadcrumbStyle? breadcrumbStyle,
FButtonStyles? buttonStyles,
FCalendarStyle? calendarStyle,
FCardStyle? cardStyle,
FCheckboxStyle? checkboxStyle,
FCircularProgressStyle? circularProgressStyle,
FDateFieldStyle? dateFieldStyle,
FDeterminateProgressStyle? determinateProgressStyle,
FDialogRouteStyle? dialogRouteStyle,
FDialogStyle? dialogStyle,
FDividerStyles? dividerStyles,
FHeaderStyles? headerStyles,
FItemStyle? itemStyle,
FItemGroupStyle? itemGroupStyle,
FLabelStyles? labelStyles,
FLineCalendarStyle? lineCalendarStyle,
FMultiSelectStyle? multiSelectStyle,
FModalSheetStyle? modalSheetStyle,
FPaginationStyle? paginationStyle,
FPersistentSheetStyle? persistentSheetStyle,
FPickerStyle? pickerStyle,
FPopoverStyle? popoverStyle,
FPopoverMenuStyle? popoverMenuStyle,
FProgressStyle? progressStyle,
FRadioStyle? radioStyle,
FResizableStyle? resizableStyle,
FScaffoldStyle? scaffoldStyle,
FSelectStyle? selectStyle,
FSelectGroupStyle? selectGroupStyle,
FSelectMenuTileStyle? selectMenuTileStyle,
FSidebarStyle? sidebarStyle,
FSliderStyles? sliderStyles,
FToasterStyle? toasterStyle,
FSwitchStyle? switchStyle,
FTabsStyle? tabsStyle,
FTappableStyle? tappableStyle,
FTextFieldStyle? textFieldStyle,
FTileStyle? tileStyle,
FTileGroupStyle? tileGroupStyle,
FTreeStyle? treeStyle,
FTimeFieldStyle? timeFieldStyle,
FTimePickerStyle? timePickerStyle,
FTooltipStyle? tooltipStyle,
Iterable<ThemeExtension<dynamic>> extensions = const [],
}) {
typography ??= FTypography.inherit(colors: colors);
style ??= FStyle.inherit(colors: colors, typography: typography);
return FThemeData._(
debugLabel: debugLabel,
breakpoints: breakpoints,
colors: colors,
typography: typography,
style: style,
accordionStyle: accordionStyle ?? FAccordionStyle.inherit(colors: colors, typography: typography, style: style),
autocompleteStyle:
autocompleteStyle ?? FAutocompleteStyle.inherit(colors: colors, typography: typography, style: style),
alertStyles: alertStyles ?? FAlertStyles.inherit(colors: colors, typography: typography, style: style),
avatarStyle: avatarStyle ?? FAvatarStyle.inherit(colors: colors, typography: typography),
badgeStyles: badgeStyles ?? FBadgeStyles.inherit(colors: colors, typography: typography, style: style),
bottomNavigationBarStyle:
bottomNavigationBarStyle ??
FBottomNavigationBarStyle.inherit(colors: colors, typography: typography, style: style),
breadcrumbStyle:
breadcrumbStyle ?? FBreadcrumbStyle.inherit(colors: colors, typography: typography, style: style),
buttonStyles: buttonStyles ?? FButtonStyles.inherit(colors: colors, typography: typography, style: style),
calendarStyle: calendarStyle ?? FCalendarStyle.inherit(colors: colors, typography: typography, style: style),
cardStyle: cardStyle ?? FCardStyle.inherit(colors: colors, typography: typography, style: style),
checkboxStyle: checkboxStyle ?? FCheckboxStyle.inherit(colors: colors, style: style),
circularProgressStyle: circularProgressStyle ?? FCircularProgressStyle.inherit(colors: colors),
dateFieldStyle: dateFieldStyle ?? FDateFieldStyle.inherit(colors: colors, typography: typography, style: style),
determinateProgressStyle:
determinateProgressStyle ?? FDeterminateProgressStyle.inherit(colors: colors, style: style),
dialogRouteStyle: dialogRouteStyle ?? FDialogRouteStyle.inherit(colors: colors),
dialogStyle: dialogStyle ?? FDialogStyle.inherit(colors: colors, typography: typography, style: style),
dividerStyles: dividerStyles ?? FDividerStyles.inherit(colors: colors, style: style),
headerStyles: headerStyles ?? FHeaderStyles.inherit(colors: colors, typography: typography, style: style),
itemStyle: itemStyle ?? FItemStyle.inherit(colors: colors, typography: typography, style: style),
itemGroupStyle: itemGroupStyle ?? FItemGroupStyle.inherit(colors: colors, typography: typography, style: style),
labelStyles: labelStyles ?? FLabelStyles.inherit(style: style),
lineCalendarStyle:
lineCalendarStyle ?? FLineCalendarStyle.inherit(colors: colors, typography: typography, style: style),
multiSelectStyle:
multiSelectStyle ?? FMultiSelectStyle.inherit(colors: colors, typography: typography, style: style),
modalSheetStyle: modalSheetStyle ?? FModalSheetStyle.inherit(colors: colors),
paginationStyle:
paginationStyle ?? FPaginationStyle.inherit(colors: colors, typography: typography, style: style),
persistentSheetStyle: persistentSheetStyle ?? const FPersistentSheetStyle(),
pickerStyle: pickerStyle ?? FPickerStyle.inherit(colors: colors, style: style, typography: typography),
popoverStyle: popoverStyle ?? FPopoverStyle.inherit(colors: colors, style: style),
popoverMenuStyle:
popoverMenuStyle ?? FPopoverMenuStyle.inherit(colors: colors, style: style, typography: typography),
progressStyle: progressStyle ?? FProgressStyle.inherit(colors: colors, style: style),
radioStyle: radioStyle ?? FRadioStyle.inherit(colors: colors, style: style),
resizableStyle: resizableStyle ?? FResizableStyle.inherit(colors: colors, style: style),
scaffoldStyle: scaffoldStyle ?? FScaffoldStyle.inherit(colors: colors, style: style),
selectStyle: selectStyle ?? FSelectStyle.inherit(colors: colors, typography: typography, style: style),
selectGroupStyle:
selectGroupStyle ?? FSelectGroupStyle.inherit(colors: colors, typography: typography, style: style),
selectMenuTileStyle:
selectMenuTileStyle ?? FSelectMenuTileStyle.inherit(colors: colors, typography: typography, style: style),
sidebarStyle: sidebarStyle ?? FSidebarStyle.inherit(colors: colors, typography: typography, style: style),
sliderStyles: sliderStyles ?? FSliderStyles.inherit(colors: colors, typography: typography, style: style),
toasterStyle: toasterStyle ?? FToasterStyle.inherit(colors: colors, typography: typography, style: style),
switchStyle: switchStyle ?? FSwitchStyle.inherit(colors: colors, style: style),
tabsStyle: tabsStyle ?? FTabsStyle.inherit(colors: colors, typography: typography, style: style),
tappableStyle: tappableStyle ?? FTappableStyle(),
textFieldStyle: textFieldStyle ?? FTextFieldStyle.inherit(colors: colors, typography: typography, style: style),
tileStyle: tileStyle ?? FTileStyle.inherit(colors: colors, typography: typography, style: style),
tileGroupStyle: tileGroupStyle ?? FTileGroupStyle.inherit(colors: colors, typography: typography, style: style),
treeStyle: treeStyle ?? FTreeStyle.inherit(colors: colors, typography: typography, style: style),
timeFieldStyle: timeFieldStyle ?? FTimeFieldStyle.inherit(colors: colors, typography: typography, style: style),
timePickerStyle:
timePickerStyle ?? FTimePickerStyle.inherit(colors: colors, typography: typography, style: style),
tooltipStyle: tooltipStyle ?? FTooltipStyle.inherit(colors: colors, typography: typography, style: style),
extensions: Map.unmodifiable({for (final extension in extensions) extension.type: extension}),
);
}
/// Creates a linear interpolation between two [FThemeData] using the given factor [t].
factory FThemeData.lerp(FThemeData a, FThemeData b, double t) => FThemeData(
debugLabel: t < 0.5 ? a.debugLabel : b.debugLabel,
breakpoints: t < 0.5 ? a.breakpoints : b.breakpoints,
colors: FColors.lerp(a.colors, b.colors, t),
typography: FTypography.lerp(a.typography, b.typography, t),
style: a.style.lerp(b.style, t),
accordionStyle: a.accordionStyle.lerp(b.accordionStyle, t),
autocompleteStyle: a.autocompleteStyle.lerp(b.autocompleteStyle, t),
alertStyles: a.alertStyles.lerp(b.alertStyles, t),
avatarStyle: a.avatarStyle.lerp(b.avatarStyle, t),
badgeStyles: a.badgeStyles.lerp(b.badgeStyles, t),
bottomNavigationBarStyle: a.bottomNavigationBarStyle.lerp(b.bottomNavigationBarStyle, t),
breadcrumbStyle: a.breadcrumbStyle.lerp(b.breadcrumbStyle, t),
buttonStyles: a.buttonStyles.lerp(b.buttonStyles, t),
calendarStyle: a.calendarStyle.lerp(b.calendarStyle, t),
cardStyle: a.cardStyle.lerp(b.cardStyle, t),
checkboxStyle: a.checkboxStyle.lerp(b.checkboxStyle, t),
circularProgressStyle: a.circularProgressStyle.lerp(b.circularProgressStyle, t),
dateFieldStyle: a.dateFieldStyle.lerp(b.dateFieldStyle, t),
determinateProgressStyle: a.determinateProgressStyle.lerp(b.determinateProgressStyle, t),
dialogRouteStyle: a.dialogRouteStyle.lerp(b.dialogRouteStyle, t),
dialogStyle: a.dialogStyle.lerp(b.dialogStyle, t),
dividerStyles: a.dividerStyles.lerp(b.dividerStyles, t),
headerStyles: a.headerStyles.lerp(b.headerStyles, t),
itemStyle: a.itemStyle.lerp(b.itemStyle, t),
itemGroupStyle: a.itemGroupStyle.lerp(b.itemGroupStyle, t),
labelStyles: a.labelStyles.lerp(b.labelStyles, t),
lineCalendarStyle: a.lineCalendarStyle.lerp(b.lineCalendarStyle, t),
multiSelectStyle: a.multiSelectStyle.lerp(b.multiSelectStyle, t),
modalSheetStyle: a.modalSheetStyle.lerp(b.modalSheetStyle, t),
paginationStyle: a.paginationStyle.lerp(b.paginationStyle, t),
persistentSheetStyle: a.persistentSheetStyle.lerp(b.persistentSheetStyle, t),
pickerStyle: a.pickerStyle.lerp(b.pickerStyle, t),
popoverStyle: a.popoverStyle.lerp(b.popoverStyle, t),
popoverMenuStyle: a.popoverMenuStyle.lerp(b.popoverMenuStyle, t),
progressStyle: a.progressStyle.lerp(b.progressStyle, t),
radioStyle: a.radioStyle.lerp(b.radioStyle, t),
resizableStyle: a.resizableStyle.lerp(b.resizableStyle, t),
scaffoldStyle: a.scaffoldStyle.lerp(b.scaffoldStyle, t),
selectStyle: a.selectStyle.lerp(b.selectStyle, t),
selectGroupStyle: a.selectGroupStyle.lerp(b.selectGroupStyle, t),
selectMenuTileStyle: a.selectMenuTileStyle.lerp(b.selectMenuTileStyle, t),
sidebarStyle: a.sidebarStyle.lerp(b.sidebarStyle, t),
sliderStyles: a.sliderStyles.lerp(b.sliderStyles, t),
toasterStyle: a.toasterStyle.lerp(b.toasterStyle, t),
switchStyle: a.switchStyle.lerp(b.switchStyle, t),
tabsStyle: a.tabsStyle.lerp(b.tabsStyle, t),
tappableStyle: a.tappableStyle.lerp(b.tappableStyle, t),
textFieldStyle: a.textFieldStyle.lerp(b.textFieldStyle, t),
tileStyle: a.tileStyle.lerp(b.tileStyle, t),
tileGroupStyle: a.tileGroupStyle.lerp(b.tileGroupStyle, t),
treeStyle: a.treeStyle.lerp(b.treeStyle, t),
timeFieldStyle: a.timeFieldStyle.lerp(b.timeFieldStyle, t),
timePickerStyle: a.timePickerStyle.lerp(b.timePickerStyle, t),
tooltipStyle: a.tooltipStyle.lerp(b.tooltipStyle, t),
// Copied from Flutter's [ThemeData].
extensions: (a._extensions.map(
(id, extensionA) => MapEntry(id, extensionA.lerp(b._extensions[id], t)),
)..addEntries(b._extensions.entries.where((entry) => !a._extensions.containsKey(entry.key)))).values,
);
FThemeData._({
required this.debugLabel,
required this.breakpoints,
required this.colors,
required this.typography,
required this.style,
required this.accordionStyle,
required this.autocompleteStyle,
required this.alertStyles,
required this.avatarStyle,
required this.badgeStyles,
required this.bottomNavigationBarStyle,
required this.breadcrumbStyle,
required this.buttonStyles,
required this.calendarStyle,
required this.cardStyle,
required this.checkboxStyle,
required this.circularProgressStyle,
required this.dateFieldStyle,
required this.determinateProgressStyle,
required this.dialogRouteStyle,
required this.dialogStyle,
required this.dividerStyles,
required this.headerStyles,
required this.itemStyle,
required this.itemGroupStyle,
required this.labelStyles,
required this.lineCalendarStyle,
required this.multiSelectStyle,
required this.modalSheetStyle,
required this.paginationStyle,
required this.persistentSheetStyle,
required this.pickerStyle,
required this.popoverStyle,
required this.popoverMenuStyle,
required this.progressStyle,
required this.radioStyle,
required this.resizableStyle,
required this.scaffoldStyle,
required this.selectStyle,
required this.selectGroupStyle,
required this.selectMenuTileStyle,
required this.sidebarStyle,
required this.sliderStyles,
required this.toasterStyle,
required this.switchStyle,
required this.tabsStyle,
required this.tappableStyle,
required this.textFieldStyle,
required this.tileStyle,
required this.tileGroupStyle,
required this.treeStyle,
required this.timeFieldStyle,
required this.timePickerStyle,
required this.tooltipStyle,
required Map<Object, ThemeExtension<dynamic>> extensions,
}) : _extensions = extensions;
/// Obtains a particular [ThemeExtension].
///
/// {@template forui.theme.FThemeData.extension}
/// ## Creating and passing a [ThemeExtension] to [FThemeData]
/// ```dart
/// class BrandColor extends ThemeExtension<BrandColor> {
/// final Color color;
///
/// BrandColor(this.color);
///
/// @override
/// BrandColor copyWith({Color? color}) => BrandColor(color ?? this.color);
///
/// @override
/// BrandColor lerp(BrandColor? other, double t) {
/// if (other is! BrandColor) return this;
///
/// return BrandColor(Color.lerp(color, other.color, t)!);
/// }
/// }
/// ```
///
/// Passing it via constructor:
/// ```dart
/// final theme = FThemeData(
/// extensions: [BrandColor(Colors.blue)],
/// ... // other fields omitted for brevity
/// );
/// ```
///
/// Passing it via [copyWith]:
/// ```dart
/// theme.copyWith(extensions: [BrandColor(Colors.blue)]);
/// ```
///
/// ## Accessing the extension
/// ```dart
/// final brandColor = context.theme.extension<BrandColor>();
/// ```
///
/// It is recommended to define a getter for your [ThemeExtension]:
/// ```extension FThemeDataBrandColor on FThemeData {
/// BrandColor get brandColor => extension<BrandColor>();
/// }
/// ```
/// {@endtemplate}
T extension<T extends Object>() => _extensions[T]! as T;
/// All [ThemeExtension]s defined in this theme.
///
/// {@macro forui.theme.FThemeData.extension}
@override
Set<ThemeExtension<dynamic>> get extensions => _extensions.values.toSet();
/// Converts this [FThemeData] to a Material [ThemeData] on a best-effort basis.
///
/// This method enables interoperability between Forui and Material Design widgets by mapping
/// Forui's theme properties to their closest Material equivalents. Use this when you need to:
///
/// * Use Material widgets within a Forui application
/// * Apply your Forui theme consistently to both Forui and Material widgets
/// * Create a gradual migration path from Material Design to Forui
///
/// Note that this conversion is approximate and experimental. Some styling properties may not map
/// perfectly between the two design systems, and the resulting Material theme might not capture
/// all the nuances of your Forui theme.
///
/// ```dart
/// // Apply a Forui theme to Material widgets
/// MaterialApp(
/// theme: FThemes.zinc.light.toApproximateMaterialTheme(),
/// // ...
/// )
/// ```
///
/// This method can be generated inside projects and directly modified by running:
/// ```shell
/// dart run forui snippet create material-mapping
/// ```
@experimental
ThemeData toApproximateMaterialTheme() {
// Material requires height to be 1, certain widgets will overflow without it.
// TextBaseline.alphabetic is required as TextField requires it.
final textTheme = TextTheme(
displayLarge: typography.xl4.copyWith(
height: 1,
textBaseline: typography.xl4.textBaseline ?? TextBaseline.alphabetic,
),
displayMedium: typography.xl3.copyWith(
height: 1,
textBaseline: typography.xl3.textBaseline ?? TextBaseline.alphabetic,
),
displaySmall: typography.xl2.copyWith(
height: 1,
textBaseline: typography.xl2.textBaseline ?? TextBaseline.alphabetic,
),
headlineLarge: typography.xl3.copyWith(
height: 1,
textBaseline: typography.xl3.textBaseline ?? TextBaseline.alphabetic,
),
headlineMedium: typography.xl2.copyWith(
height: 1,
textBaseline: typography.xl2.textBaseline ?? TextBaseline.alphabetic,
),
headlineSmall: typography.xl.copyWith(
height: 1,
textBaseline: typography.xl.textBaseline ?? TextBaseline.alphabetic,
),
titleLarge: typography.lg.copyWith(
height: 1,
textBaseline: typography.lg.textBaseline ?? TextBaseline.alphabetic,
),
titleMedium: typography.base.copyWith(
height: 1,
textBaseline: typography.base.textBaseline ?? TextBaseline.alphabetic,
),
titleSmall: typography.sm.copyWith(
height: 1,
textBaseline: typography.sm.textBaseline ?? TextBaseline.alphabetic,
),
labelLarge: typography.base.copyWith(
height: 1,
textBaseline: typography.base.textBaseline ?? TextBaseline.alphabetic,
),
labelMedium: typography.sm.copyWith(
height: 1,
textBaseline: typography.sm.textBaseline ?? TextBaseline.alphabetic,
),
labelSmall: typography.xs.copyWith(
height: 1,
textBaseline: typography.xs.textBaseline ?? TextBaseline.alphabetic,
),
bodyLarge: typography.base.copyWith(
height: 1,
textBaseline: typography.base.textBaseline ?? TextBaseline.alphabetic,
),
bodyMedium: typography.sm.copyWith(
height: 1,
textBaseline: typography.sm.textBaseline ?? TextBaseline.alphabetic,
),
bodySmall: typography.xs.copyWith(height: 1, textBaseline: typography.xs.textBaseline ?? TextBaseline.alphabetic),
)..apply(fontFamily: typography.defaultFontFamily, bodyColor: colors.foreground, displayColor: colors.foreground);
return ThemeData(
colorScheme: ColorScheme(
brightness: colors.brightness,
primary: colors.primary,
onPrimary: colors.primaryForeground,
secondary: colors.secondary,
onSecondary: colors.secondaryForeground,
error: colors.error,
onError: colors.errorForeground,
surface: colors.background,
onSurface: colors.foreground,
secondaryContainer: colors.secondary,
onSecondaryContainer: colors.secondaryForeground,
),
fontFamily: typography.defaultFontFamily,
typography: Typography(
black: textTheme,
white: textTheme,
englishLike: textTheme,
dense: textTheme,
tall: textTheme,
),
textTheme: textTheme,