cm tabs add tooltips and selected color
This commit is contained in:
parent
6e6a359809
commit
ee744d7de3
@ -126,6 +126,20 @@ class ConnectionManagerState extends State<ConnectionManager> {
|
|||||||
controller: serverModel.tabController,
|
controller: serverModel.tabController,
|
||||||
maxLabelWidth: 100,
|
maxLabelWidth: 100,
|
||||||
tail: buildScrollJumper(),
|
tail: buildScrollJumper(),
|
||||||
|
selectedTabBackgroundColor:
|
||||||
|
Theme.of(context).hintColor.withOpacity(0.2),
|
||||||
|
tabBuilder: (key, icon, label, themeConf) {
|
||||||
|
return Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
icon,
|
||||||
|
Tooltip(
|
||||||
|
message: key,
|
||||||
|
waitDuration: Duration(seconds: 1),
|
||||||
|
child: label),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
pageViewBuilder: (pageView) => Row(children: [
|
pageViewBuilder: (pageView) => Row(children: [
|
||||||
Expanded(child: pageView),
|
Expanded(child: pageView),
|
||||||
Consumer<ChatModel>(
|
Consumer<ChatModel>(
|
||||||
|
@ -178,6 +178,9 @@ typedef TabBuilder = Widget Function(
|
|||||||
String key, Widget icon, Widget label, TabThemeConf themeConf);
|
String key, Widget icon, Widget label, TabThemeConf themeConf);
|
||||||
typedef LabelGetter = Rx<String> Function(String key);
|
typedef LabelGetter = Rx<String> Function(String key);
|
||||||
|
|
||||||
|
/// [_lastClickTime], help to handle double click
|
||||||
|
int _lastClickTime = DateTime.now().millisecondsSinceEpoch;
|
||||||
|
|
||||||
class DesktopTab extends StatelessWidget {
|
class DesktopTab extends StatelessWidget {
|
||||||
final Function(String)? onTabClose;
|
final Function(String)? onTabClose;
|
||||||
final bool showTabBar;
|
final bool showTabBar;
|
||||||
@ -192,15 +195,14 @@ class DesktopTab extends StatelessWidget {
|
|||||||
final TabBuilder? tabBuilder;
|
final TabBuilder? tabBuilder;
|
||||||
final LabelGetter? labelGetter;
|
final LabelGetter? labelGetter;
|
||||||
final double? maxLabelWidth;
|
final double? maxLabelWidth;
|
||||||
|
final Color? selectedTabBackgroundColor;
|
||||||
|
final Color? unSelectedTabBackgroundColor;
|
||||||
|
|
||||||
final DesktopTabController controller;
|
final DesktopTabController controller;
|
||||||
Rx<DesktopTabState> get state => controller.state;
|
Rx<DesktopTabState> get state => controller.state;
|
||||||
final isMaximized = false.obs;
|
final isMaximized = false.obs;
|
||||||
final _scrollDebounce = Debouncer(delay: Duration(milliseconds: 50));
|
final _scrollDebounce = Debouncer(delay: Duration(milliseconds: 50));
|
||||||
|
|
||||||
/// [_lastClickTime], help to handle double click
|
|
||||||
int _lastClickTime = DateTime.now().millisecondsSinceEpoch;
|
|
||||||
|
|
||||||
late final DesktopTabType tabType;
|
late final DesktopTabType tabType;
|
||||||
late final bool isMainWindow;
|
late final bool isMainWindow;
|
||||||
|
|
||||||
@ -220,6 +222,8 @@ class DesktopTab extends StatelessWidget {
|
|||||||
this.tabBuilder,
|
this.tabBuilder,
|
||||||
this.labelGetter,
|
this.labelGetter,
|
||||||
this.maxLabelWidth,
|
this.maxLabelWidth,
|
||||||
|
this.selectedTabBackgroundColor,
|
||||||
|
this.unSelectedTabBackgroundColor,
|
||||||
}) : super(key: key) {
|
}) : super(key: key) {
|
||||||
tabType = controller.tabType;
|
tabType = controller.tabType;
|
||||||
isMainWindow =
|
isMainWindow =
|
||||||
@ -364,7 +368,11 @@ class DesktopTab extends StatelessWidget {
|
|||||||
onTabClose: onTabClose,
|
onTabClose: onTabClose,
|
||||||
tabBuilder: tabBuilder,
|
tabBuilder: tabBuilder,
|
||||||
labelGetter: labelGetter,
|
labelGetter: labelGetter,
|
||||||
maxLabelWidth: maxLabelWidth))),
|
maxLabelWidth: maxLabelWidth,
|
||||||
|
selectedTabBackgroundColor:
|
||||||
|
selectedTabBackgroundColor,
|
||||||
|
unSelectedTabBackgroundColor:
|
||||||
|
unSelectedTabBackgroundColor))),
|
||||||
],
|
],
|
||||||
))),
|
))),
|
||||||
WindowActionPanel(
|
WindowActionPanel(
|
||||||
@ -617,6 +625,8 @@ class _ListView extends StatelessWidget {
|
|||||||
final TabBuilder? tabBuilder;
|
final TabBuilder? tabBuilder;
|
||||||
final LabelGetter? labelGetter;
|
final LabelGetter? labelGetter;
|
||||||
final double? maxLabelWidth;
|
final double? maxLabelWidth;
|
||||||
|
final Color? selectedTabBackgroundColor;
|
||||||
|
final Color? unSelectedTabBackgroundColor;
|
||||||
|
|
||||||
Rx<DesktopTabState> get state => controller.state;
|
Rx<DesktopTabState> get state => controller.state;
|
||||||
|
|
||||||
@ -625,7 +635,9 @@ class _ListView extends StatelessWidget {
|
|||||||
required this.onTabClose,
|
required this.onTabClose,
|
||||||
this.tabBuilder,
|
this.tabBuilder,
|
||||||
this.labelGetter,
|
this.labelGetter,
|
||||||
this.maxLabelWidth});
|
this.maxLabelWidth,
|
||||||
|
this.selectedTabBackgroundColor,
|
||||||
|
this.unSelectedTabBackgroundColor});
|
||||||
|
|
||||||
/// Check whether to show ListView
|
/// Check whether to show ListView
|
||||||
///
|
///
|
||||||
@ -667,7 +679,7 @@ class _ListView extends StatelessWidget {
|
|||||||
onSelected: () => controller.jumpTo(index),
|
onSelected: () => controller.jumpTo(index),
|
||||||
tabBuilder: tabBuilder == null
|
tabBuilder: tabBuilder == null
|
||||||
? null
|
? null
|
||||||
: (Widget icon, Widget labelWidget,
|
: (String key, Widget icon, Widget labelWidget,
|
||||||
TabThemeConf themeConf) {
|
TabThemeConf themeConf) {
|
||||||
return tabBuilder!(
|
return tabBuilder!(
|
||||||
tab.label,
|
tab.label,
|
||||||
@ -677,6 +689,8 @@ class _ListView extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
maxLabelWidth: maxLabelWidth,
|
maxLabelWidth: maxLabelWidth,
|
||||||
|
selectedTabBackgroundColor: selectedTabBackgroundColor,
|
||||||
|
unSelectedTabBackgroundColor: unSelectedTabBackgroundColor,
|
||||||
);
|
);
|
||||||
}).toList()));
|
}).toList()));
|
||||||
}
|
}
|
||||||
@ -691,9 +705,10 @@ class _Tab extends StatefulWidget {
|
|||||||
final int selected;
|
final int selected;
|
||||||
final Function() onClose;
|
final Function() onClose;
|
||||||
final Function() onSelected;
|
final Function() onSelected;
|
||||||
final Widget Function(Widget icon, Widget label, TabThemeConf themeConf)?
|
final TabBuilder? tabBuilder;
|
||||||
tabBuilder;
|
|
||||||
final double? maxLabelWidth;
|
final double? maxLabelWidth;
|
||||||
|
final Color? selectedTabBackgroundColor;
|
||||||
|
final Color? unSelectedTabBackgroundColor;
|
||||||
|
|
||||||
const _Tab({
|
const _Tab({
|
||||||
Key? key,
|
Key? key,
|
||||||
@ -707,6 +722,8 @@ class _Tab extends StatefulWidget {
|
|||||||
required this.onClose,
|
required this.onClose,
|
||||||
required this.onSelected,
|
required this.onSelected,
|
||||||
this.maxLabelWidth,
|
this.maxLabelWidth,
|
||||||
|
this.selectedTabBackgroundColor,
|
||||||
|
this.unSelectedTabBackgroundColor,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -753,8 +770,8 @@ class _TabState extends State<_Tab> with RestorationMixin {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return widget.tabBuilder!(
|
return widget.tabBuilder!(widget.label.value, icon, labelWidget,
|
||||||
icon, labelWidget, TabThemeConf(iconSize: _kIconSize));
|
TabThemeConf(iconSize: _kIconSize));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -771,6 +788,10 @@ class _TabState extends State<_Tab> with RestorationMixin {
|
|||||||
restoreHover.value = value;
|
restoreHover.value = value;
|
||||||
},
|
},
|
||||||
onTap: () => widget.onSelected(),
|
onTap: () => widget.onSelected(),
|
||||||
|
child: Container(
|
||||||
|
color: isSelected
|
||||||
|
? widget.selectedTabBackgroundColor
|
||||||
|
: widget.unSelectedTabBackgroundColor,
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
SizedBox(
|
SizedBox(
|
||||||
@ -796,7 +817,7 @@ class _TabState extends State<_Tab> with RestorationMixin {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
)),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user