|
| 1 | +import 'package:flutter/material.dart'; |
| 2 | +import 'package:syncfusion_flutter_core/theme.dart'; |
| 3 | + |
| 4 | +/// [SfDateRangePickerThemeDataM2] this class provides material2 themeData. |
| 5 | +/// SfDateRangePickerThemeDataM2 class extends the 'SfDateRangePickerThemeData' |
| 6 | +/// class and customize the appearance of a mapping component based on th color |
| 7 | +/// scheme obtained from the provided [BuildContext]. |
| 8 | +class SfDateRangePickerThemeDataM2 extends SfDateRangePickerThemeData { |
| 9 | + /// This a constructor that takes a [BuildContext] as a parameter.This context |
| 10 | + /// is used for obtaining the color scheme of the current theme. |
| 11 | + SfDateRangePickerThemeDataM2(this.context); |
| 12 | + |
| 13 | + /// Property that stores the provided [BuildContext] |
| 14 | + /// context is later used to obtain the color scheme. |
| 15 | + final BuildContext context; |
| 16 | + |
| 17 | + /// A late-initialized property representing the color scheme obtained from |
| 18 | + /// the current theme using the provided [BuildContext] |
| 19 | + late final ColorScheme colorScheme = Theme.of(context).colorScheme; |
| 20 | + |
| 21 | + @override |
| 22 | + Color? get backgroundColor => Colors.transparent; |
| 23 | + |
| 24 | + @override |
| 25 | + Color? get headerBackgroundColor => colorScheme.brightness == Brightness.light |
| 26 | + ? Colors.white |
| 27 | + : Colors.grey[850]; |
| 28 | + |
| 29 | + @override |
| 30 | + Color? get viewHeaderBackgroundColor => Colors.transparent; |
| 31 | + |
| 32 | + @override |
| 33 | + Color? get weekNumberBackgroundColor => |
| 34 | + colorScheme.onSurface.withOpacity(0.08); |
| 35 | + |
| 36 | + @override |
| 37 | + Color? get selectionColor => colorScheme.primary; |
| 38 | + |
| 39 | + @override |
| 40 | + Color? get startRangeSelectionColor => colorScheme.primary; |
| 41 | + |
| 42 | + @override |
| 43 | + Color? get rangeSelectionColor => colorScheme.primary.withOpacity(0.1); |
| 44 | + |
| 45 | + @override |
| 46 | + Color? get endRangeSelectionColor => colorScheme.primary; |
| 47 | + |
| 48 | + @override |
| 49 | + Color? get todayHighlightColor => colorScheme.primary; |
| 50 | +} |
| 51 | + |
| 52 | +/// [SfDateRangePickerThemeDataM3] this class provides material3 themeData. |
| 53 | +/// SfDateRangePickerThemeDataM3 class extends the 'SfDateRangePickerThemeData' |
| 54 | +/// class and customize the appearance of a mapping component based on th color |
| 55 | +/// scheme obtained from the provided [BuildContext]. |
| 56 | +class SfDateRangePickerThemeDataM3 extends SfDateRangePickerThemeData { |
| 57 | + /// This a constructor that takes a [BuildContext] as a parameter.This context |
| 58 | + /// is used for obtaining the color scheme of the current theme. |
| 59 | + SfDateRangePickerThemeDataM3(this.context); |
| 60 | + |
| 61 | + /// Property that stores the provided [BuildContext] |
| 62 | + /// context is later used to obtain the color scheme. |
| 63 | + final BuildContext context; |
| 64 | + |
| 65 | + /// A late-initialized property representing the color scheme obtained from |
| 66 | + /// the current theme using the provided [BuildContext] |
| 67 | + late final ColorScheme colorScheme = Theme.of(context).colorScheme; |
| 68 | + |
| 69 | + @override |
| 70 | + Color? get backgroundColor => colorScheme.brightness == Brightness.light |
| 71 | + ? const Color.fromRGBO(238, 232, 244, 1) |
| 72 | + : const Color.fromRGBO(48, 45, 56, 1); |
| 73 | + |
| 74 | + @override |
| 75 | + Color? get headerBackgroundColor => colorScheme.brightness == Brightness.light |
| 76 | + ? const Color.fromRGBO(238, 232, 244, 1) |
| 77 | + : const Color.fromRGBO(48, 45, 56, 1); |
| 78 | + |
| 79 | + @override |
| 80 | + Color? get viewHeaderBackgroundColor => Colors.transparent; |
| 81 | + |
| 82 | + @override |
| 83 | + Color? get weekNumberBackgroundColor => colorScheme.surfaceVariant; |
| 84 | + |
| 85 | + @override |
| 86 | + Color? get selectionColor => colorScheme.primary; |
| 87 | + |
| 88 | + @override |
| 89 | + Color? get startRangeSelectionColor => colorScheme.primary; |
| 90 | + |
| 91 | + @override |
| 92 | + Color? get rangeSelectionColor => colorScheme.primary.withOpacity(0.12); |
| 93 | + |
| 94 | + @override |
| 95 | + Color? get endRangeSelectionColor => colorScheme.primary; |
| 96 | + |
| 97 | + @override |
| 98 | + Color? get todayHighlightColor => colorScheme.primary; |
| 99 | +} |
0 commit comments