update file transfer pop menu style / fixed file name width

This commit is contained in:
csf 2022-10-13 20:22:11 +09:00
parent eaf7fd320c
commit da18e69258
3 changed files with 59 additions and 38 deletions

View File

@ -12,13 +12,6 @@ import '../../models/platform_model.dart';
import '../../desktop/widgets/material_mod_popup_menu.dart' as mod_menu;
import '../../desktop/widgets/popup_menu.dart';
class CustomPopupMenuTheme {
static const Color commonColor = MyTheme.accent;
// kMinInteractiveDimension
static const double height = 20.0;
static const double dividerHeight = 3.0;
}
typedef PopupMenuEntryBuilder = Future<List<mod_menu.PopupMenuEntry<String>>>
Function(BuildContext);

View File

@ -9,10 +9,13 @@ import 'package:flutter_hbb/models/file_model.dart';
import 'package:get/get.dart';
import 'package:provider/provider.dart';
import 'package:wakelock/wakelock.dart';
import '../../consts.dart';
import '../../desktop/widgets/material_mod_popup_menu.dart' as mod_menu;
import '../../common.dart';
import '../../models/model.dart';
import '../../models/platform_model.dart';
import '../widgets/popup_menu.dart';
/// status of location bar
enum LocationStatus {
@ -124,32 +127,47 @@ class _FileManagerPageState extends State<FileManagerPage>
}
Widget menu({bool isLocal = false}) {
return PopupMenuButton<String>(
icon: const Icon(Icons.more_vert),
splashRadius: 20,
itemBuilder: (context) {
return [
PopupMenuItem(
child: Row(
children: [
Icon(
model.getCurrentShowHidden(isLocal)
? Icons.check_box_outlined
: Icons.check_box_outline_blank,
color: Colors.black),
SizedBox(width: 5),
Text(translate("Show Hidden Files"))
],
),
value: "hidden",
)
];
var menuPos = RelativeRect.fill;
final items = [
MenuEntrySwitch<String>(
switchType: SwitchType.scheckbox,
text: translate("Show Hidden Files"),
getter: () async {
return model.getCurrentShowHidden(isLocal);
},
onSelected: (v) {
if (v == "hidden") {
model.toggleShowHidden(local: isLocal);
}
});
setter: (bool v) async {
model.toggleShowHidden(local: isLocal);
},
padding: kDesktopMenuPadding,
dismissOnClicked: true,
),
];
return Listener(
onPointerDown: (e) {
final x = e.position.dx;
final y = e.position.dy;
menuPos = RelativeRect.fromLTRB(x, y, x, y);
},
child: IconButton(
icon: const Icon(Icons.more_vert),
splashRadius: 20,
onPressed: () => mod_menu.showMenu(
context: context,
position: menuPos,
items: items
.map((e) => e.build(
context,
MenuConfig(
commonColor: CustomPopupMenuTheme.commonColor,
height: CustomPopupMenuTheme.height,
dividerHeight: CustomPopupMenuTheme.dividerHeight)))
.expand((i) => i)
.toList(),
elevation: 8,
),
));
}
Widget body({bool isLocal = false}) {
@ -252,9 +270,8 @@ class _FileManagerPageState extends State<FileManagerPage>
getSelectedItem(isLocal).contains(entry),
cells: [
DataCell(
ConstrainedBox(
constraints:
BoxConstraints(maxWidth: 180),
Container(
width: 180,
child: Tooltip(
message: entry.name,
child: Row(children: [
@ -724,9 +741,12 @@ class _FileManagerPageState extends State<FileManagerPage>
breadCrumbScrollToEnd(bool isLocal) {
Future.delayed(Duration(milliseconds: 200), () {
final breadCrumbScroller = getBreadCrumbScrollController(isLocal);
breadCrumbScroller.animateTo(breadCrumbScroller.position.maxScrollExtent,
duration: Duration(milliseconds: 200),
curve: Curves.fastLinearToSlowEaseIn);
if (breadCrumbScroller.hasClients) {
breadCrumbScroller.animateTo(
breadCrumbScroller.position.maxScrollExtent,
duration: Duration(milliseconds: 200),
curve: Curves.fastLinearToSlowEaseIn);
}
});
}

View File

@ -3,6 +3,7 @@ import 'dart:core';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../common.dart';
import './material_mod_popup_menu.dart' as mod_menu;
// https://stackoverflow.com/questions/68318314/flutter-popup-menu-inside-popup-menu
@ -637,3 +638,10 @@ class MenuEntryButton<T> extends MenuEntryBase<T> {
];
}
}
class CustomPopupMenuTheme {
static const Color commonColor = MyTheme.accent;
// kMinInteractiveDimension
static const double height = 20.0;
static const double dividerHeight = 3.0;
}