add tabbar theme extension to fix theme update failure after overlay

added

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages 2022-09-04 11:03:16 +08:00
parent a553334157
commit 62870e453c
7 changed files with 162 additions and 138 deletions

View File

@ -155,7 +155,7 @@ class MyTheme {
brightness: Brightness.light, brightness: Brightness.light,
primarySwatch: Colors.blue, primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity, visualDensity: VisualDensity.adaptivePlatformDensity,
tabBarTheme: TabBarTheme( tabBarTheme: const TabBarTheme(
labelColor: Colors.black87, labelColor: Colors.black87,
), ),
splashColor: Colors.transparent, splashColor: Colors.transparent,
@ -163,13 +163,14 @@ class MyTheme {
).copyWith( ).copyWith(
extensions: <ThemeExtension<dynamic>>[ extensions: <ThemeExtension<dynamic>>[
ColorThemeExtension.light, ColorThemeExtension.light,
TabbarTheme.light,
], ],
); );
static ThemeData darkTheme = ThemeData( static ThemeData darkTheme = ThemeData(
brightness: Brightness.dark, brightness: Brightness.dark,
primarySwatch: Colors.blue, primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity, visualDensity: VisualDensity.adaptivePlatformDensity,
tabBarTheme: TabBarTheme( tabBarTheme: const TabBarTheme(
labelColor: Colors.white70, labelColor: Colors.white70,
), ),
splashColor: Colors.transparent, splashColor: Colors.transparent,
@ -177,12 +178,17 @@ class MyTheme {
).copyWith( ).copyWith(
extensions: <ThemeExtension<dynamic>>[ extensions: <ThemeExtension<dynamic>>[
ColorThemeExtension.dark, ColorThemeExtension.dark,
TabbarTheme.dark,
], ],
); );
static ColorThemeExtension color(BuildContext context) { static ColorThemeExtension color(BuildContext context) {
return Theme.of(context).extension<ColorThemeExtension>()!; return Theme.of(context).extension<ColorThemeExtension>()!;
} }
static TabbarTheme tabbar(BuildContext context) {
return Theme.of(context).extension<TabbarTheme>()!;
}
} }
bool isDarkTheme() { bool isDarkTheme() {

View File

@ -83,7 +83,6 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final theme = isDarkTheme() ? TarBarTheme.dark() : TarBarTheme.light();
final RxBool fullscreen = Get.find(tag: 'fullscreen'); final RxBool fullscreen = Get.find(tag: 'fullscreen');
return Obx(() => SubWindowDragToResizeArea( return Obx(() => SubWindowDragToResizeArea(
resizeEdgeSize: fullscreen.value ? 1.0 : 8.0, resizeEdgeSize: fullscreen.value ? 1.0 : 8.0,
@ -95,14 +94,11 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
backgroundColor: MyTheme.color(context).bg, backgroundColor: MyTheme.color(context).bg,
body: Obx(() => DesktopTab( body: Obx(() => DesktopTab(
controller: tabController, controller: tabController,
theme: theme,
showTabBar: fullscreen.isFalse, showTabBar: fullscreen.isFalse,
onClose: () { onClose: () {
tabController.clear(); tabController.clear();
}, },
tail: AddButton( tail: AddButton().paddingOnly(left: 10),
theme: theme,
).paddingOnly(left: 10),
pageViewBuilder: (pageView) { pageViewBuilder: (pageView) {
WindowController.fromWindowId(windowId()) WindowController.fromWindowId(windowId())
.setFullscreen(fullscreen.isTrue); .setFullscreen(fullscreen.isTrue);

View File

@ -48,17 +48,11 @@ class _DesktopTabPageState extends State<DesktopTabPage> {
backgroundColor: MyTheme.color(context).bg, backgroundColor: MyTheme.color(context).bg,
body: DesktopTab( body: DesktopTab(
controller: tabController, controller: tabController,
theme: dark
? const TarBarTheme.dark()
: const TarBarTheme.light(),
tail: ActionIcon( tail: ActionIcon(
message: 'Settings', message: 'Settings',
icon: IconFont.menu, icon: IconFont.menu,
theme: dark
? const TarBarTheme.dark()
: const TarBarTheme.light(),
onTap: onAddSetting, onTap: onAddSetting,
is_close: false, isClose: false,
), ),
)); ));
}) })

View File

@ -62,8 +62,6 @@ class _FileManagerTabPageState extends State<FileManagerTabPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final theme =
isDarkTheme() ? const TarBarTheme.dark() : const TarBarTheme.light();
return SubWindowDragToResizeArea( return SubWindowDragToResizeArea(
windowId: windowId(), windowId: windowId(),
child: Container( child: Container(
@ -73,13 +71,10 @@ class _FileManagerTabPageState extends State<FileManagerTabPage> {
backgroundColor: MyTheme.color(context).bg, backgroundColor: MyTheme.color(context).bg,
body: DesktopTab( body: DesktopTab(
controller: tabController, controller: tabController,
theme: theme,
onClose: () { onClose: () {
tabController.clear(); tabController.clear();
}, },
tail: AddButton( tail: AddButton().paddingOnly(left: 10),
theme: theme,
).paddingOnly(left: 10),
)), )),
), ),
); );

View File

@ -69,7 +69,6 @@ class _PortForwardTabPageState extends State<PortForwardTabPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final theme = isDarkTheme() ? TarBarTheme.dark() : TarBarTheme.light();
return SubWindowDragToResizeArea( return SubWindowDragToResizeArea(
windowId: windowId(), windowId: windowId(),
child: Container( child: Container(
@ -79,13 +78,10 @@ class _PortForwardTabPageState extends State<PortForwardTabPage> {
backgroundColor: MyTheme.color(context).bg, backgroundColor: MyTheme.color(context).bg,
body: DesktopTab( body: DesktopTab(
controller: tabController, controller: tabController,
theme: theme,
onClose: () { onClose: () {
tabController.clear(); tabController.clear();
}, },
tail: AddButton( tail: AddButton().paddingOnly(left: 10),
theme: theme,
).paddingOnly(left: 10),
)), )),
), ),
); );

View File

@ -118,7 +118,6 @@ class ConnectionManagerState extends State<ConnectionManager> {
], ],
) )
: DesktopTab( : DesktopTab(
theme: isDarkTheme() ? TarBarTheme.dark() : TarBarTheme.light(),
showTitle: false, showTitle: false,
showMaximize: false, showMaximize: false,
showMinimize: true, showMinimize: true,

View File

@ -3,7 +3,7 @@ import 'dart:async';
import 'dart:math'; import 'dart:math';
import 'package:desktop_multi_window/desktop_multi_window.dart'; import 'package:desktop_multi_window/desktop_multi_window.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart' hide TabBarTheme;
import 'package:flutter_hbb/common.dart'; import 'package:flutter_hbb/common.dart';
import 'package:flutter_hbb/consts.dart'; import 'package:flutter_hbb/consts.dart';
import 'package:flutter_hbb/main.dart'; import 'package:flutter_hbb/main.dart';
@ -158,8 +158,7 @@ class DesktopTabController {
class TabThemeConf { class TabThemeConf {
double iconSize; double iconSize;
TarBarTheme theme; TabThemeConf({required this.iconSize});
TabThemeConf({required this.iconSize, required this.theme});
} }
typedef TabBuilder = Widget Function( typedef TabBuilder = Widget Function(
@ -168,7 +167,6 @@ typedef LabelGetter = Rx<String> Function(String key);
class DesktopTab extends StatelessWidget { class DesktopTab extends StatelessWidget {
final Function(String)? onTabClose; final Function(String)? onTabClose;
final TarBarTheme theme;
final bool showTabBar; final bool showTabBar;
final bool showLogo; final bool showLogo;
final bool showTitle; final bool showTitle;
@ -189,7 +187,6 @@ class DesktopTab extends StatelessWidget {
DesktopTab({ DesktopTab({
Key? key, Key? key,
required this.controller, required this.controller,
this.theme = const TarBarTheme.light(),
this.onTabClose, this.onTabClose,
this.showTabBar = true, this.showTabBar = true,
this.showLogo = true, this.showLogo = true,
@ -213,15 +210,15 @@ class DesktopTab extends StatelessWidget {
return Column(children: [ return Column(children: [
Offstage( Offstage(
offstage: !showTabBar, offstage: !showTabBar,
child: Container( child: SizedBox(
height: _kTabBarHeight, height: _kTabBarHeight,
child: Column( child: Column(
children: [ children: [
Container( SizedBox(
height: _kTabBarHeight - 1, height: _kTabBarHeight - 1,
child: _buildBar(), child: _buildBar(),
), ),
Divider( const Divider(
height: 1, height: 1,
thickness: 1, thickness: 1,
), ),
@ -300,7 +297,7 @@ class DesktopTab extends StatelessWidget {
)), )),
Offstage( Offstage(
offstage: !showTitle, offstage: !showTitle,
child: Text( child: const Text(
"RustDesk", "RustDesk",
style: TextStyle(fontSize: 13), style: TextStyle(fontSize: 13),
).marginOnly(left: 2)) ).marginOnly(left: 2))
@ -321,7 +318,6 @@ class DesktopTab extends StatelessWidget {
child: _ListView( child: _ListView(
controller: controller, controller: controller,
onTabClose: onTabClose, onTabClose: onTabClose,
theme: theme,
tabBuilder: tabBuilder, tabBuilder: tabBuilder,
labelGetter: labelGetter, labelGetter: labelGetter,
)), )),
@ -334,7 +330,6 @@ class DesktopTab extends StatelessWidget {
mainTab: isMainWindow, mainTab: isMainWindow,
tabType: tabType, tabType: tabType,
state: state, state: state,
theme: theme,
showMinimize: showMinimize, showMinimize: showMinimize,
showMaximize: showMaximize, showMaximize: showMaximize,
showClose: showClose, showClose: showClose,
@ -349,7 +344,6 @@ class WindowActionPanel extends StatelessWidget {
final bool mainTab; final bool mainTab;
final DesktopTabType tabType; final DesktopTabType tabType;
final Rx<DesktopTabState> state; final Rx<DesktopTabState> state;
final TarBarTheme theme;
final bool showMinimize; final bool showMinimize;
final bool showMaximize; final bool showMaximize;
@ -361,7 +355,6 @@ class WindowActionPanel extends StatelessWidget {
required this.mainTab, required this.mainTab,
required this.tabType, required this.tabType,
required this.state, required this.state,
required this.theme,
this.showMinimize = true, this.showMinimize = true,
this.showMaximize = true, this.showMaximize = true,
this.showClose = true, this.showClose = true,
@ -377,7 +370,6 @@ class WindowActionPanel extends StatelessWidget {
child: ActionIcon( child: ActionIcon(
message: 'Minimize', message: 'Minimize',
icon: IconFont.min, icon: IconFont.min,
theme: theme,
onTap: () { onTap: () {
if (mainTab) { if (mainTab) {
windowManager.minimize(); windowManager.minimize();
@ -385,31 +377,30 @@ class WindowActionPanel extends StatelessWidget {
WindowController.fromWindowId(windowId!).minimize(); WindowController.fromWindowId(windowId!).minimize();
} }
}, },
is_close: false, isClose: false,
)), )),
// TODO: drag makes window restore // TODO: drag makes window restore
Offstage( Offstage(
offstage: !showMaximize, offstage: !showMaximize,
child: FutureBuilder(builder: (context, snapshot) { child: FutureBuilder(builder: (context, snapshot) {
RxBool is_maximized = false.obs; RxBool isMaximized = false.obs;
if (mainTab) { if (mainTab) {
windowManager.isMaximized().then((maximized) { windowManager.isMaximized().then((maximized) {
is_maximized.value = maximized; isMaximized.value = maximized;
}); });
} else { } else {
final wc = WindowController.fromWindowId(windowId!); final wc = WindowController.fromWindowId(windowId!);
wc.isMaximized().then((maximized) { wc.isMaximized().then((maximized) {
is_maximized.value = maximized; isMaximized.value = maximized;
}); });
} }
return Obx( return Obx(
() => ActionIcon( () => ActionIcon(
message: is_maximized.value ? "Restore" : "Maximize", message: isMaximized.value ? "Restore" : "Maximize",
icon: is_maximized.value ? IconFont.restore : IconFont.max, icon: isMaximized.value ? IconFont.restore : IconFont.max,
theme: theme,
onTap: () { onTap: () {
if (mainTab) { if (mainTab) {
if (is_maximized.value) { if (isMaximized.value) {
windowManager.unmaximize(); windowManager.unmaximize();
} else { } else {
windowManager.maximize(); windowManager.maximize();
@ -417,15 +408,15 @@ class WindowActionPanel extends StatelessWidget {
} else { } else {
// TODO: subwindow is maximized but first query result is not maximized. // TODO: subwindow is maximized but first query result is not maximized.
final wc = WindowController.fromWindowId(windowId!); final wc = WindowController.fromWindowId(windowId!);
if (is_maximized.value) { if (isMaximized.value) {
wc.unmaximize(); wc.unmaximize();
} else { } else {
wc.maximize(); wc.maximize();
} }
} }
is_maximized.value = !is_maximized.value; isMaximized.value = !isMaximized.value;
}, },
is_close: false, isClose: false,
), ),
); );
})), })),
@ -434,7 +425,6 @@ class WindowActionPanel extends StatelessWidget {
child: ActionIcon( child: ActionIcon(
message: 'Close', message: 'Close',
icon: IconFont.close, icon: IconFont.close,
theme: theme,
onTap: () async { onTap: () async {
action() { action() {
if (mainTab) { if (mainTab) {
@ -455,7 +445,7 @@ class WindowActionPanel extends StatelessWidget {
action(); action();
} }
}, },
is_close: true, isClose: true,
)), )),
], ],
); );
@ -490,17 +480,15 @@ class WindowActionPanel extends StatelessWidget {
class _ListView extends StatelessWidget { class _ListView extends StatelessWidget {
final DesktopTabController controller; final DesktopTabController controller;
final Function(String key)? onTabClose; final Function(String key)? onTabClose;
final TarBarTheme theme;
final TabBuilder? tabBuilder; final TabBuilder? tabBuilder;
final LabelGetter? labelGetter; final LabelGetter? labelGetter;
Rx<DesktopTabState> get state => controller.state; Rx<DesktopTabState> get state => controller.state;
_ListView( const _ListView(
{required this.controller, {required this.controller,
required this.onTabClose, required this.onTabClose,
required this.theme,
this.tabBuilder, this.tabBuilder,
this.labelGetter}); this.labelGetter});
@ -510,7 +498,7 @@ class _ListView extends StatelessWidget {
controller: state.value.scrollController, controller: state.value.scrollController,
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
shrinkWrap: true, shrinkWrap: true,
physics: BouncingScrollPhysics(), physics: const BouncingScrollPhysics(),
children: state.value.tabs.asMap().entries.map((e) { children: state.value.tabs.asMap().entries.map((e) {
final index = e.key; final index = e.key;
final tab = e.value; final tab = e.value;
@ -525,7 +513,6 @@ class _ListView extends StatelessWidget {
selected: state.value.selected, selected: state.value.selected,
onClose: () => controller.remove(index), onClose: () => controller.remove(index),
onSelected: () => controller.jumpTo(index), onSelected: () => controller.jumpTo(index),
theme: theme,
tabBuilder: tabBuilder == null tabBuilder: tabBuilder == null
? null ? null
: (Widget icon, Widget labelWidget, TabThemeConf themeConf) { : (Widget icon, Widget labelWidget, TabThemeConf themeConf) {
@ -542,20 +529,19 @@ class _ListView extends StatelessWidget {
} }
class _Tab extends StatefulWidget { class _Tab extends StatefulWidget {
late final int index; final int index;
late final Rx<String> label; final Rx<String> label;
late final IconData? selectedIcon; final IconData? selectedIcon;
late final IconData? unselectedIcon; final IconData? unselectedIcon;
late final bool closable; final bool closable;
late final int selected; final int selected;
late final Function() onClose; final Function() onClose;
late final Function() onSelected; final Function() onSelected;
late final TarBarTheme theme;
final Widget Function(Widget icon, Widget label, TabThemeConf themeConf)? final Widget Function(Widget icon, Widget label, TabThemeConf themeConf)?
tabBuilder; tabBuilder;
_Tab( const _Tab({
{Key? key, Key? key,
required this.index, required this.index,
required this.label, required this.label,
this.selectedIcon, this.selectedIcon,
@ -565,8 +551,7 @@ class _Tab extends StatefulWidget {
required this.selected, required this.selected,
required this.onClose, required this.onClose,
required this.onSelected, required this.onSelected,
required this.theme}) }) : super(key: key);
: super(key: key);
@override @override
State<_Tab> createState() => _TabState(); State<_Tab> createState() => _TabState();
@ -586,8 +571,8 @@ class _TabState extends State<_Tab> with RestorationMixin {
isSelected ? widget.selectedIcon : widget.unselectedIcon, isSelected ? widget.selectedIcon : widget.unselectedIcon,
size: _kIconSize, size: _kIconSize,
color: isSelected color: isSelected
? widget.theme.selectedtabIconColor ? MyTheme.tabbar(context).selectedTabIconColor
: widget.theme.unSelectedtabIconColor, : MyTheme.tabbar(context).unSelectedTabIconColor,
).paddingOnly(right: 5)); ).paddingOnly(right: 5));
final labelWidget = Obx(() { final labelWidget = Obx(() {
return Text( return Text(
@ -595,8 +580,8 @@ class _TabState extends State<_Tab> with RestorationMixin {
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
color: isSelected color: isSelected
? widget.theme.selectedTextColor ? MyTheme.tabbar(context).selectedTextColor
: widget.theme.unSelectedTextColor), : MyTheme.tabbar(context).unSelectedTextColor),
); );
}); });
@ -609,8 +594,8 @@ class _TabState extends State<_Tab> with RestorationMixin {
], ],
); );
} else { } else {
return widget.tabBuilder!(icon, labelWidget, return widget.tabBuilder!(
TabThemeConf(iconSize: _kIconSize, theme: widget.theme)); icon, labelWidget, TabThemeConf(iconSize: _kIconSize));
} }
} }
@ -639,7 +624,6 @@ class _TabState extends State<_Tab> with RestorationMixin {
visiable: hover.value && widget.closable, visiable: hover.value && widget.closable,
tabSelected: isSelected, tabSelected: isSelected,
onClose: () => widget.onClose(), onClose: () => widget.onClose(),
theme: widget.theme,
))) )))
])).paddingSymmetric(horizontal: 10), ])).paddingSymmetric(horizontal: 10),
Offstage( Offstage(
@ -648,7 +632,7 @@ class _TabState extends State<_Tab> with RestorationMixin {
width: 1, width: 1,
indent: _kDividerIndent, indent: _kDividerIndent,
endIndent: _kDividerIndent, endIndent: _kDividerIndent,
color: widget.theme.dividerColor, color: MyTheme.tabbar(context).dividerColor,
thickness: 1, thickness: 1,
), ),
) )
@ -671,14 +655,12 @@ class _CloseButton extends StatelessWidget {
final bool visiable; final bool visiable;
final bool tabSelected; final bool tabSelected;
final Function onClose; final Function onClose;
late final TarBarTheme theme;
_CloseButton({ const _CloseButton({
Key? key, Key? key,
required this.visiable, required this.visiable,
required this.tabSelected, required this.tabSelected,
required this.onClose, required this.onClose,
required this.theme,
}) : super(key: key); }) : super(key: key);
@override @override
@ -694,8 +676,8 @@ class _CloseButton extends StatelessWidget {
Icons.close, Icons.close,
size: _kIconSize, size: _kIconSize,
color: tabSelected color: tabSelected
? theme.selectedIconColor ? MyTheme.tabbar(context).selectedIconColor
: theme.unSelectedIconColor, : MyTheme.tabbar(context).unSelectedIconColor,
), ),
), ),
)).paddingOnly(left: 5); )).paddingOnly(left: 5);
@ -705,16 +687,14 @@ class _CloseButton extends StatelessWidget {
class ActionIcon extends StatelessWidget { class ActionIcon extends StatelessWidget {
final String message; final String message;
final IconData icon; final IconData icon;
final TarBarTheme theme;
final Function() onTap; final Function() onTap;
final bool is_close; final bool isClose;
const ActionIcon({ const ActionIcon({
Key? key, Key? key,
required this.message, required this.message,
required this.icon, required this.icon,
required this.theme,
required this.onTap, required this.onTap,
required this.is_close, required this.isClose,
}) : super(key: key); }) : super(key: key);
@override @override
@ -722,34 +702,32 @@ class ActionIcon extends StatelessWidget {
RxBool hover = false.obs; RxBool hover = false.obs;
return Obx(() => Tooltip( return Obx(() => Tooltip(
message: translate(message), message: translate(message),
waitDuration: Duration(seconds: 1), waitDuration: const Duration(seconds: 1),
child: InkWell( child: InkWell(
hoverColor: hoverColor: isClose
is_close ? Color.fromARGB(255, 196, 43, 28) : theme.hoverColor, ? const Color.fromARGB(255, 196, 43, 28)
: MyTheme.tabbar(context).hoverColor,
onHover: (value) => hover.value = value, onHover: (value) => hover.value = value,
child: Container( onTap: onTap,
child: SizedBox(
height: _kTabBarHeight - 1, height: _kTabBarHeight - 1,
width: _kTabBarHeight - 1, width: _kTabBarHeight - 1,
child: Icon( child: Icon(
icon, icon,
color: hover.value && is_close color: hover.value && isClose
? Colors.white ? Colors.white
: theme.unSelectedIconColor, : MyTheme.tabbar(context).unSelectedIconColor,
size: _kActionIconSize, size: _kActionIconSize,
), ),
), ),
onTap: onTap,
), ),
)); ));
} }
} }
class AddButton extends StatelessWidget { class AddButton extends StatelessWidget {
late final TarBarTheme theme; const AddButton({
AddButton({
Key? key, Key? key,
required this.theme,
}) : super(key: key); }) : super(key: key);
@override @override
@ -757,41 +735,101 @@ class AddButton extends StatelessWidget {
return ActionIcon( return ActionIcon(
message: 'New Connection', message: 'New Connection',
icon: IconFont.add, icon: IconFont.add,
theme: theme,
onTap: () => onTap: () =>
rustDeskWinManager.call(WindowType.Main, "main_window_on_top", ""), rustDeskWinManager.call(WindowType.Main, "main_window_on_top", ""),
is_close: false); isClose: false);
} }
} }
class TarBarTheme { class TabbarTheme extends ThemeExtension<TabbarTheme> {
final Color unSelectedtabIconColor; final Color? selectedTabIconColor;
final Color selectedtabIconColor; final Color? unSelectedTabIconColor;
final Color selectedTextColor; final Color? selectedTextColor;
final Color unSelectedTextColor; final Color? unSelectedTextColor;
final Color selectedIconColor; final Color? selectedIconColor;
final Color unSelectedIconColor; final Color? unSelectedIconColor;
final Color dividerColor; final Color? dividerColor;
final Color hoverColor; final Color? hoverColor;
const TarBarTheme.light() const TabbarTheme(
: unSelectedtabIconColor = const Color.fromARGB(255, 162, 203, 241), {required this.selectedTabIconColor,
selectedtabIconColor = MyTheme.accent, required this.unSelectedTabIconColor,
selectedTextColor = const Color.fromARGB(255, 26, 26, 26), required this.selectedTextColor,
unSelectedTextColor = const Color.fromARGB(255, 96, 96, 96), required this.unSelectedTextColor,
selectedIconColor = const Color.fromARGB(255, 26, 26, 26), required this.selectedIconColor,
unSelectedIconColor = const Color.fromARGB(255, 96, 96, 96), required this.unSelectedIconColor,
dividerColor = const Color.fromARGB(255, 238, 238, 238), required this.dividerColor,
hoverColor = const Color.fromARGB( required this.hoverColor});
51, 158, 158, 158); // Colors.grey; //0xFF9E9E9E
const TarBarTheme.dark() static const light = TabbarTheme(
: unSelectedtabIconColor = const Color.fromARGB(255, 30, 65, 98), selectedTabIconColor: MyTheme.accent,
selectedtabIconColor = MyTheme.accent, unSelectedTabIconColor: Color.fromARGB(255, 162, 203, 241),
selectedTextColor = const Color.fromARGB(255, 255, 255, 255), selectedTextColor: Color.fromARGB(255, 26, 26, 26),
unSelectedTextColor = const Color.fromARGB(255, 207, 207, 207), unSelectedTextColor: Color.fromARGB(255, 96, 96, 96),
selectedIconColor = const Color.fromARGB(255, 215, 215, 215), selectedIconColor: Color.fromARGB(255, 26, 26, 26),
unSelectedIconColor = const Color.fromARGB(255, 255, 255, 255), unSelectedIconColor: Color.fromARGB(255, 96, 96, 96),
dividerColor = const Color.fromARGB(255, 64, 64, 64), dividerColor: Color.fromARGB(255, 238, 238, 238),
hoverColor = Colors.black26; hoverColor: Color.fromARGB(51, 158, 158, 158));
static const dark = TabbarTheme(
selectedTabIconColor: MyTheme.accent,
unSelectedTabIconColor: Color.fromARGB(255, 30, 65, 98),
selectedTextColor: Color.fromARGB(255, 255, 255, 255),
unSelectedTextColor: Color.fromARGB(255, 207, 207, 207),
selectedIconColor: Color.fromARGB(255, 215, 215, 215),
unSelectedIconColor: Color.fromARGB(255, 255, 255, 255),
dividerColor: Color.fromARGB(255, 64, 64, 64),
hoverColor: Colors.black26);
@override
ThemeExtension<TabbarTheme> copyWith({
Color? selectedTabIconColor,
Color? unSelectedTabIconColor,
Color? selectedTextColor,
Color? unSelectedTextColor,
Color? selectedIconColor,
Color? unSelectedIconColor,
Color? dividerColor,
Color? hoverColor,
}) {
return TabbarTheme(
selectedTabIconColor: selectedTabIconColor ?? this.selectedTabIconColor,
unSelectedTabIconColor:
unSelectedTabIconColor ?? this.unSelectedTabIconColor,
selectedTextColor: selectedTextColor ?? this.selectedTextColor,
unSelectedTextColor: unSelectedTextColor ?? this.unSelectedTextColor,
selectedIconColor: selectedIconColor ?? this.selectedIconColor,
unSelectedIconColor: unSelectedIconColor ?? this.unSelectedIconColor,
dividerColor: dividerColor ?? this.dividerColor,
hoverColor: hoverColor ?? this.hoverColor,
);
}
@override
ThemeExtension<TabbarTheme> lerp(
ThemeExtension<TabbarTheme>? other, double t) {
if (other is! TabbarTheme) {
return this;
}
return TabbarTheme(
selectedTabIconColor:
Color.lerp(selectedTabIconColor, other.selectedTabIconColor, t),
unSelectedTabIconColor:
Color.lerp(unSelectedTabIconColor, other.unSelectedTabIconColor, t),
selectedTextColor:
Color.lerp(selectedTextColor, other.selectedTextColor, t),
unSelectedTextColor:
Color.lerp(unSelectedTextColor, other.unSelectedTextColor, t),
selectedIconColor:
Color.lerp(selectedIconColor, other.selectedIconColor, t),
unSelectedIconColor:
Color.lerp(unSelectedIconColor, other.unSelectedIconColor, t),
dividerColor: Color.lerp(dividerColor, other.dividerColor, t),
hoverColor: Color.lerp(hoverColor, other.hoverColor, t),
);
}
static color(BuildContext context) {
return Theme.of(context).extension<ColorThemeExtension>()!;
}
} }