flutter_desktop: show/hide menubar tooltip

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou 2022-08-28 21:55:16 +08:00
parent ea77d9284b
commit 55ba191ad9
23 changed files with 105 additions and 59 deletions

View File

@ -197,19 +197,19 @@ class _RemotePageState extends State<RemotePage>
return Scaffold(
backgroundColor: MyTheme.color(context).bg,
// resizeToAvoidBottomInset: true,
floatingActionButton: _showBar
? null
: FloatingActionButton(
mini: true,
child: Icon(Icons.expand_less),
backgroundColor: MyTheme.accent,
onPressed: () {
setState(() {
_showBar = !_showBar;
});
}),
bottomNavigationBar:
_showBar && hasDisplays ? getBottomAppBar(ffiModel) : null,
// floatingActionButton: _showBar
// ? null
// : FloatingActionButton(
// mini: true,
// child: Icon(Icons.expand_less),
// backgroundColor: MyTheme.accent,
// onPressed: () {
// setState(() {
// _showBar = !_showBar;
// });
// }),
// bottomNavigationBar:
// _showBar && hasDisplays ? getBottomAppBar(ffiModel) : null,
body: Overlay(
initialEntries: [
OverlayEntry(builder: (context) {

View File

@ -10,7 +10,7 @@ import '../../mobile/widgets/overlay.dart';
import '../../models/model.dart';
import '../../models/platform_model.dart';
import './popup_menu.dart';
import './material_mod_popup_menu.dart' as modMenu;
import './material_mod_popup_menu.dart' as mod_menu;
class _MenubarTheme {
static const Color commonColor = MyTheme.accent;
@ -50,19 +50,22 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
}
Widget _buildShowHide(BuildContext context) {
return SizedBox(
width: 100,
height: 5,
child: TextButton(
onHover: (bool v) {
_hideColor.value = v ? Colors.white60 : Colors.white24;
},
onPressed: () {
_show.value = !_show.value;
},
child: Obx(() => Container(
color: _hideColor.value,
))));
return Obx(() => Tooltip(
message: translate(_show.value ? "Hide Menubar" : "Show Menubar"),
child: SizedBox(
width: 100,
height: 5,
child: TextButton(
onHover: (bool v) {
_hideColor.value = v ? Colors.white60 : Colors.white24;
},
onPressed: () {
_show.value = !_show.value;
},
child: Obx(() => Container(
color: _hideColor.value,
)))),
));
}
Widget _buildMenubar(BuildContext context) {
@ -73,7 +76,7 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
menubarItems.add(IconButton(
tooltip: translate('Mobile Actions'),
color: _MenubarTheme.commonColor,
icon: Icon(Icons.build),
icon: const Icon(Icons.build),
onPressed: () {
if (mobileActionsOverlayEntry == null) {
showMobileActionsOverlay();
@ -92,7 +95,7 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
}
menubarItems.add(_buildClose(context));
return PopupMenuTheme(
data: PopupMenuThemeData(
data: const PopupMenuThemeData(
textStyle: TextStyle(color: _MenubarTheme.commonColor)),
child: Column(mainAxisSize: MainAxisSize.min, children: [
Container(
@ -112,11 +115,11 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
setFullscreen(!isFullscreen);
},
icon: Obx(() => isFullscreen
? Icon(
? const Icon(
Icons.fullscreen_exit,
color: _MenubarTheme.commonColor,
)
: Icon(
: const Icon(
Icons.fullscreen,
color: _MenubarTheme.commonColor,
)),
@ -130,7 +133,7 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
widget.ffi.chatModel.changeCurrentID(ChatModel.clientModeID);
widget.ffi.chatModel.toggleChatOverlay();
},
icon: Icon(
icon: const Icon(
Icons.message,
color: _MenubarTheme.commonColor,
),
@ -139,24 +142,25 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
Widget _buildMonitor(BuildContext context) {
final pi = widget.ffi.ffiModel.pi;
return modMenu.PopupMenuButton(
return mod_menu.PopupMenuButton(
tooltip: translate('Select Monitor'),
padding: EdgeInsets.zero,
position: modMenu.PopupMenuPosition.under,
position: mod_menu.PopupMenuPosition.under,
icon: Stack(
alignment: Alignment.center,
children: [
Icon(
const Icon(
Icons.personal_video,
color: _MenubarTheme.commonColor,
),
Padding(
padding: EdgeInsets.only(bottom: 3.9),
padding: const EdgeInsets.only(bottom: 3.9),
child: Obx(() {
RxInt display = CurrentDisplayState.find(widget.id);
return Text(
"${display.value + 1}/${pi.displays.length}",
style: TextStyle(color: _MenubarTheme.commonColor, fontSize: 8),
style: const TextStyle(
color: _MenubarTheme.commonColor, fontSize: 8),
);
}),
)
@ -164,14 +168,14 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
),
itemBuilder: (BuildContext context) {
final List<Widget> rowChildren = [];
final double selectorScale = 1.3;
const double selectorScale = 1.3;
for (int i = 0; i < pi.displays.length; i++) {
rowChildren.add(Transform.scale(
scale: selectorScale,
child: Stack(
alignment: Alignment.center,
children: [
Icon(
const Icon(
Icons.personal_video,
color: _MenubarTheme.commonColor,
),
@ -179,12 +183,13 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
child: Container(
alignment: AlignmentDirectional.center,
constraints:
BoxConstraints(minHeight: _MenubarTheme.height),
const BoxConstraints(minHeight: _MenubarTheme.height),
child: Padding(
padding: EdgeInsets.only(bottom: 2.5),
padding: const EdgeInsets.only(bottom: 2.5),
child: Text(
(i + 1).toString(),
style: TextStyle(color: _MenubarTheme.commonColor),
style:
const TextStyle(color: _MenubarTheme.commonColor),
),
)),
onPressed: () {
@ -200,8 +205,8 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
),
));
}
return <modMenu.PopupMenuEntry<String>>[
modMenu.PopupMenuItem<String>(
return <mod_menu.PopupMenuEntry<String>>[
mod_menu.PopupMenuItem<String>(
height: _MenubarTheme.height,
padding: EdgeInsets.zero,
child: Row(
@ -214,18 +219,18 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
}
Widget _buildControl(BuildContext context) {
return modMenu.PopupMenuButton(
return mod_menu.PopupMenuButton(
padding: EdgeInsets.zero,
icon: Icon(
icon: const Icon(
Icons.bolt,
color: _MenubarTheme.commonColor,
),
tooltip: translate('Control Actions'),
position: modMenu.PopupMenuPosition.under,
position: mod_menu.PopupMenuPosition.under,
itemBuilder: (BuildContext context) => _getControlMenu()
.map((entry) => entry.build(
context,
MenuConfig(
const MenuConfig(
commonColor: _MenubarTheme.commonColor,
secondMenuHeight: _MenubarTheme.height,
)))
@ -234,19 +239,19 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
}
Widget _buildDisplay(BuildContext context) {
return modMenu.PopupMenuButton(
return mod_menu.PopupMenuButton(
padding: EdgeInsets.zero,
icon: Icon(
icon: const Icon(
Icons.tv,
color: _MenubarTheme.commonColor,
),
tooltip: translate('Display Settings'),
position: modMenu.PopupMenuPosition.under,
position: mod_menu.PopupMenuPosition.under,
onSelected: (String item) {},
itemBuilder: (BuildContext context) => _getDisplayMenu()
.map((entry) => entry.build(
context,
MenuConfig(
const MenuConfig(
commonColor: _MenubarTheme.commonColor,
secondMenuHeight: _MenubarTheme.height,
)))
@ -260,7 +265,7 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
onPressed: () {
clientClose(widget.ffi.dialogManager);
},
icon: Icon(
icon: const Icon(
Icons.close,
color: _MenubarTheme.commonColor,
),
@ -332,7 +337,7 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
if (pi.platform == 'Linux' || pi.sasEnabled) {
displayMenu.add(MenuEntryButton<String>(
childBuilder: (TextStyle? style) => Text(
translate('Insert') + ' Ctrl + Alt + Del',
'${translate("Insert")} Ctrl + Alt + Del',
style: style,
),
proc: () {
@ -357,8 +362,7 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
displayMenu.add(MenuEntryButton<String>(
childBuilder: (TextStyle? style) => Obx(() => Text(
translate(
(BlockInputState.find(widget.id).value ? 'Unb' : 'B') +
'lock user input'),
'${BlockInputState.find(widget.id).value ? "Unb" : "B"}lock user input'),
style: style,
)),
proc: () {
@ -366,7 +370,7 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
RxBool blockInput = BlockInputState.find(widget.id);
bind.sessionToggleOption(
id: widget.id,
value: (blockInput.value ? 'un' : '') + 'block-input');
value: '${blockInput.value ? "un" : ""}block-input');
blockInput.value = !blockInput.value;
},
));
@ -447,7 +451,7 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
MenuEntrySwitch<String>(
text: translate('Show remote cursor'),
getter: () async {
return await bind.sessionGetToggleOptionSync(
return bind.sessionGetToggleOptionSync(
id: widget.id, arg: 'show-remote-cursor');
},
setter: (bool v) async {
@ -457,7 +461,7 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
MenuEntrySwitch<String>(
text: translate('Show quality monitor'),
getter: () async {
return await bind.sessionGetToggleOptionSync(
return bind.sessionGetToggleOptionSync(
id: widget.id, arg: 'show-quality-monitor');
},
setter: (bool v) async {

View File

@ -311,5 +311,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Ratio", "比例"),
("Image Quality", "画质"),
("Scroll Style", "滚屏方式"),
("Show Menubar", "显示菜单栏"),
("Hide Menubar", "隐藏菜单栏"),
].iter().cloned().collect();
}

View File

@ -311,5 +311,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Ratio", "Poměr"),
("Image Quality", "Kvalita obrazu"),
("Scroll Style", "Štýl posúvania"),
("Show Menubar", "Zobrazit panel nabídek"),
("Hide Menubar", "skrýt panel nabídek"),
].iter().cloned().collect();
}

View File

@ -311,5 +311,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Ratio", "Forhold"),
("Image Quality", "Billede kvalitet"),
("Scroll Style", "Rulstil"),
("Show Menubar", "Vis menulinje"),
("Hide Menubar", "skjul menulinjen"),
].iter().cloned().collect();
}

View File

@ -311,5 +311,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Ratio", "Verhältnis"),
("Image Quality", "Bildqualität"),
("Scroll Style", "Scroll-Stil"),
("Show Menubar", "Menüleiste anzeigen"),
("Hide Menubar", "Menüleiste ausblenden"),
].iter().cloned().collect();
}

View File

@ -311,5 +311,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Ratio", "Proporcio"),
("Image Quality", "Bilda Kvalito"),
("Scroll Style", "Ruluma Stilo"),
("Show Menubar", "Montru menubreton"),
("Hide Menubar", "kaŝi menubreton"),
].iter().cloned().collect();
}

View File

@ -311,5 +311,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Ratio", "Relación"),
("Image Quality", "La calidad de imagen"),
("Scroll Style", "Estilo de desplazamiento"),
("Show Menubar", "ajustes de pantalla"),
("Hide Menubar", "ocultar barra de menú"),
].iter().cloned().collect();
}

View File

@ -311,5 +311,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Ratio", "Rapport"),
("Image Quality", "Qualité d'image"),
("Scroll Style", "Style de défilement"),
("Show Menubar", "Afficher la barre de menus"),
("Hide Menubar", "masquer la barre de menus"),
].iter().cloned().collect();
}

View File

@ -311,5 +311,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Ratio", "Hányados"),
("Image Quality", "Képminőség"),
("Scroll Style", "Görgetési stílus"),
("Show Menubar", "Menüsor megjelenítése"),
("Hide Menubar", "menüsor elrejtése"),
].iter().cloned().collect();
}

View File

@ -311,5 +311,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Ratio", "Perbandingan"),
("Image Quality", "Kualitas gambar"),
("Scroll Style", "Gaya Gulir"),
("Show Menubar", "Tampilkan bilah menu"),
("Hide Menubar", "sembunyikan bilah menu"),
].iter().cloned().collect();
}

View File

@ -310,5 +310,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Ratio", "Rapporto"),
("Image Quality", "Qualità dell'immagine"),
("Scroll Style", "Stile di scorrimento"),
("Show Menubar", "Mostra la barra dei menu"),
("Hide Menubar", "nascondi la barra dei menu"),
].iter().cloned().collect();
}

View File

@ -308,5 +308,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Ratio", "比率"),
("Image Quality", "画質"),
("Scroll Style", "スクロール スタイル"),
("Show Menubar", "メニューバーを表示"),
("Hide Menubar", "メニューバーを隠す"),
].iter().cloned().collect();
}

View File

@ -308,5 +308,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Ratio", "비율"),
("Image Quality", "이미지 품질"),
("Scroll Style", "스크롤 스타일"),
("Show Menubar", "메뉴 표시줄 표시"),
("Hide Menubar", "메뉴 표시줄 숨기기"),
].iter().cloned().collect();
}

View File

@ -312,5 +312,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Ratio", "Stosunek"),
("Image Quality", "Jakość obrazu"),
("Scroll Style", "Styl przewijania"),
("Show Menubar", "Pokaż pasek menu"),
("Hide Menubar", "ukryj pasek menu"),
].iter().cloned().collect();
}

View File

@ -308,5 +308,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Ratio", "Razão"),
("Image Quality", "Qualidade da imagem"),
("Scroll Style", "Estilo de rolagem"),
("Show Menubar", "Mostrar barra de menus"),
("Hide Menubar", "ocultar barra de menu"),
].iter().cloned().collect();
}

View File

@ -311,5 +311,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Ratio", ""),
("Image Quality", ""),
("Scroll Style", ""),
("Show Menubar", ""),
("Hide Menubar", ""),
].iter().cloned().collect();
}

View File

@ -311,5 +311,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Ratio", "Соотношение"),
("Image Quality", "Качество изображения"),
("Scroll Style", "Стиль прокрутки"),
("Show Menubar", "Показать строку меню"),
("Hide Menubar", "скрыть строку меню"),
].iter().cloned().collect();
}

View File

@ -311,5 +311,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Ratio", "Pomer"),
("Image Quality", "Kvalita obrazu"),
("Scroll Style", "Štýl posúvania"),
("Show Menubar", "Zobraziť panel s ponukami"),
("Hide Menubar", "skryť panel s ponukami"),
].iter().cloned().collect();
}

View File

@ -311,5 +311,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Ratio", ""),
("Image Quality", ""),
("Scroll Style", ""),
("Show Menubar", ""),
("Hide Menubar", ""),
].iter().cloned().collect();
}

View File

@ -311,5 +311,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Ratio", "Oran"),
("Image Quality", "Görüntü kalitesi"),
("Scroll Style", "Kaydırma Stili"),
("Show Menubar", "Menü çubuğunu göster"),
("Hide Menubar", "menü çubuğunu gizle"),
].iter().cloned().collect();
}

View File

@ -311,5 +311,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Ratio", "比例"),
("Image Quality", "畫質"),
("Scroll Style", "滾動樣式"),
("Show Menubar", "顯示菜單欄"),
("Hide Menubar", "隱藏菜單欄"),
].iter().cloned().collect();
}

View File

@ -311,5 +311,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Ratio", "Tỉ lệ"),
("Image Quality", "Chất lượng hình ảnh"),
("Scroll Style", "Kiểu cuộn"),
("Show Menubar", "Hiển thị thanh menu"),
("Hide Menubar", "ẩn thanh menu"),
].iter().cloned().collect();
}