2022-09-19 20:26:39 +08:00
|
|
|
import 'package:flutter/material.dart';
|
2022-11-27 12:16:45 +08:00
|
|
|
import 'package:flutter_hbb/common/formatter/id_formatter.dart';
|
2022-10-08 18:28:20 +08:00
|
|
|
import 'package:flutter_hbb/common/widgets/peer_card.dart';
|
2022-09-22 15:35:46 +08:00
|
|
|
import 'package:flutter_hbb/common/widgets/peers_view.dart';
|
2022-10-08 18:28:20 +08:00
|
|
|
import 'package:flutter_hbb/desktop/widgets/popup_menu.dart';
|
2023-07-26 19:53:57 +08:00
|
|
|
import 'package:flutter_hbb/models/ab_model.dart';
|
|
|
|
import 'package:flutter_hbb/models/platform_model.dart';
|
2022-10-08 18:28:20 +08:00
|
|
|
import '../../desktop/widgets/material_mod_popup_menu.dart' as mod_menu;
|
2022-09-19 20:26:39 +08:00
|
|
|
import 'package:get/get.dart';
|
|
|
|
|
|
|
|
import '../../common.dart';
|
2023-01-08 22:30:34 +08:00
|
|
|
import 'login.dart';
|
2022-09-19 20:26:39 +08:00
|
|
|
|
2023-06-29 15:18:35 +08:00
|
|
|
final hideAbTagsPanel = false.obs;
|
|
|
|
|
2022-09-19 20:26:39 +08:00
|
|
|
class AddressBook extends StatefulWidget {
|
2022-09-23 12:20:40 +08:00
|
|
|
final EdgeInsets? menuPadding;
|
|
|
|
const AddressBook({Key? key, this.menuPadding}) : super(key: key);
|
2022-09-19 20:26:39 +08:00
|
|
|
|
|
|
|
@override
|
|
|
|
State<StatefulWidget> createState() {
|
|
|
|
return _AddressBookState();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class _AddressBookState extends State<AddressBook> {
|
2022-10-10 17:27:26 +08:00
|
|
|
var menuPos = RelativeRect.fill;
|
|
|
|
|
2022-09-19 20:26:39 +08:00
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
2023-06-21 18:28:52 +08:00
|
|
|
Widget build(BuildContext context) => Obx(() {
|
|
|
|
if (gFFI.userModel.userName.value.isEmpty) {
|
|
|
|
return Center(
|
|
|
|
child: ElevatedButton(
|
|
|
|
onPressed: loginDialog, child: Text(translate("Login"))));
|
|
|
|
} else {
|
|
|
|
if (gFFI.abModel.abLoading.value) {
|
|
|
|
return const Center(
|
|
|
|
child: CircularProgressIndicator(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if (gFFI.abModel.abError.isNotEmpty) {
|
|
|
|
return _buildShowError(gFFI.abModel.abError.value);
|
|
|
|
}
|
|
|
|
return isDesktop
|
|
|
|
? _buildAddressBookDesktop()
|
|
|
|
: _buildAddressBookMobile();
|
2022-10-09 18:41:50 +08:00
|
|
|
}
|
2023-06-21 18:28:52 +08:00
|
|
|
});
|
2022-09-19 20:26:39 +08:00
|
|
|
|
2022-10-08 16:13:24 +08:00
|
|
|
Widget _buildShowError(String error) {
|
|
|
|
return Center(
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Text(translate(error)),
|
|
|
|
TextButton(
|
|
|
|
onPressed: () {
|
2022-11-30 11:13:02 +08:00
|
|
|
gFFI.abModel.pullAb();
|
2022-10-08 16:13:24 +08:00
|
|
|
},
|
|
|
|
child: Text(translate("Retry")))
|
|
|
|
],
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2022-10-10 17:27:26 +08:00
|
|
|
Widget _buildAddressBookDesktop() {
|
2022-10-08 16:13:24 +08:00
|
|
|
return Row(
|
|
|
|
children: [
|
2023-06-29 15:18:35 +08:00
|
|
|
Offstage(
|
2023-07-26 19:53:57 +08:00
|
|
|
offstage: hideAbTagsPanel.value,
|
|
|
|
child: Container(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius: BorderRadius.circular(12),
|
|
|
|
border: Border.all(
|
|
|
|
color: Theme.of(context).colorScheme.background)),
|
|
|
|
child: Container(
|
|
|
|
width: 150,
|
|
|
|
height: double.infinity,
|
|
|
|
padding: const EdgeInsets.all(8.0),
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
_buildTagHeader().marginOnly(left: 8.0, right: 0),
|
|
|
|
Expanded(
|
|
|
|
child: Container(
|
|
|
|
width: double.infinity,
|
|
|
|
height: double.infinity,
|
|
|
|
child: _buildTags(),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
).marginOnly(right: 12.0)),
|
2022-10-10 17:27:26 +08:00
|
|
|
_buildPeersViews()
|
2022-10-08 16:13:24 +08:00
|
|
|
],
|
|
|
|
);
|
2022-09-19 20:26:39 +08:00
|
|
|
}
|
|
|
|
|
2022-10-10 17:27:26 +08:00
|
|
|
Widget _buildAddressBookMobile() {
|
|
|
|
return Column(
|
|
|
|
children: [
|
2023-07-26 19:57:42 +08:00
|
|
|
Offstage(
|
|
|
|
offstage: hideAbTagsPanel.value,
|
|
|
|
child: Container(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius: BorderRadius.circular(6),
|
|
|
|
border: Border.all(
|
|
|
|
color: Theme.of(context).colorScheme.background)),
|
|
|
|
child: Container(
|
|
|
|
padding: const EdgeInsets.all(8.0),
|
|
|
|
child: Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
|
|
|
_buildTagHeader().marginOnly(left: 8.0, right: 0),
|
|
|
|
Container(
|
|
|
|
width: double.infinity,
|
|
|
|
child: _buildTags(),
|
|
|
|
),
|
|
|
|
],
|
2023-06-22 11:52:25 +08:00
|
|
|
),
|
2023-07-26 19:57:42 +08:00
|
|
|
),
|
|
|
|
).marginOnly(bottom: 12.0)),
|
2022-10-10 17:27:26 +08:00
|
|
|
_buildPeersViews()
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget _buildTagHeader() {
|
|
|
|
return Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Text(translate('Tags')),
|
2023-02-21 16:29:06 +08:00
|
|
|
Listener(
|
|
|
|
onPointerDown: (e) {
|
|
|
|
final x = e.position.dx;
|
|
|
|
final y = e.position.dy;
|
2022-10-10 17:27:26 +08:00
|
|
|
menuPos = RelativeRect.fromLTRB(x, y, x, y);
|
|
|
|
},
|
2023-02-21 16:29:06 +08:00
|
|
|
onPointerUp: (_) => _showMenu(menuPos),
|
2023-06-21 19:39:55 +08:00
|
|
|
child: build_more(context, invert: true)),
|
2022-10-10 17:27:26 +08:00
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget _buildTags() {
|
2023-07-26 19:53:57 +08:00
|
|
|
return Obx(() {
|
|
|
|
final List tags;
|
|
|
|
if (gFFI.abModel.sortTags.value) {
|
|
|
|
tags = gFFI.abModel.tags.toList();
|
|
|
|
tags.sort();
|
|
|
|
} else {
|
|
|
|
tags = gFFI.abModel.tags;
|
|
|
|
}
|
|
|
|
return Wrap(
|
|
|
|
children: tags
|
2022-10-10 17:27:26 +08:00
|
|
|
.map((e) => AddressBookTag(
|
|
|
|
name: e,
|
|
|
|
tags: gFFI.abModel.selectedTags,
|
|
|
|
onTap: () {
|
|
|
|
if (gFFI.abModel.selectedTags.contains(e)) {
|
|
|
|
gFFI.abModel.selectedTags.remove(e);
|
|
|
|
} else {
|
|
|
|
gFFI.abModel.selectedTags.add(e);
|
|
|
|
}
|
|
|
|
}))
|
|
|
|
.toList(),
|
2023-07-26 19:53:57 +08:00
|
|
|
);
|
|
|
|
});
|
2022-10-10 17:27:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Widget _buildPeersViews() {
|
|
|
|
return Expanded(
|
|
|
|
child: Align(
|
|
|
|
alignment: Alignment.topLeft,
|
|
|
|
child: Obx(() => AddressBookPeersView(
|
|
|
|
menuPadding: widget.menuPadding,
|
2023-06-23 17:05:48 +08:00
|
|
|
// ignore: invalid_use_of_protected_member
|
2022-10-10 17:27:26 +08:00
|
|
|
initPeers: gFFI.abModel.peers.value,
|
|
|
|
))),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-07-26 19:53:57 +08:00
|
|
|
@protected
|
|
|
|
MenuEntryBase<String> syncMenuItem() {
|
|
|
|
return MenuEntrySwitch<String>(
|
|
|
|
switchType: SwitchType.scheckbox,
|
|
|
|
text: translate('Sync with recent sessions'),
|
|
|
|
getter: () async {
|
|
|
|
return shouldSyncAb();
|
|
|
|
},
|
|
|
|
setter: (bool v) async {
|
|
|
|
bind.mainSetLocalOption(key: syncAbOption, value: v ? 'Y' : '');
|
|
|
|
},
|
|
|
|
dismissOnClicked: true,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
@protected
|
|
|
|
MenuEntryBase<String> sortMenuItem() {
|
|
|
|
return MenuEntrySwitch<String>(
|
|
|
|
switchType: SwitchType.scheckbox,
|
|
|
|
text: translate('Sort tags'),
|
|
|
|
getter: () async {
|
|
|
|
return shouldSortTags();
|
|
|
|
},
|
|
|
|
setter: (bool v) async {
|
|
|
|
bind.mainSetLocalOption(key: sortAbTagsOption, value: v ? 'Y' : '');
|
|
|
|
gFFI.abModel.sortTags.value = v;
|
|
|
|
},
|
|
|
|
dismissOnClicked: true,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-10-08 18:28:20 +08:00
|
|
|
void _showMenu(RelativeRect pos) {
|
|
|
|
final items = [
|
|
|
|
getEntry(translate("Add ID"), abAddId),
|
|
|
|
getEntry(translate("Add Tag"), abAddTag),
|
|
|
|
getEntry(translate("Unselect all tags"), gFFI.abModel.unsetSelectedTags),
|
2023-07-26 19:53:57 +08:00
|
|
|
sortMenuItem(),
|
|
|
|
syncMenuItem(),
|
2022-10-08 18:28:20 +08:00
|
|
|
];
|
|
|
|
|
|
|
|
mod_menu.showMenu(
|
|
|
|
context: context,
|
|
|
|
position: pos,
|
|
|
|
items: items
|
|
|
|
.map((e) => e.build(
|
|
|
|
context,
|
|
|
|
MenuConfig(
|
|
|
|
commonColor: CustomPopupMenuTheme.commonColor,
|
|
|
|
height: CustomPopupMenuTheme.height,
|
|
|
|
dividerHeight: CustomPopupMenuTheme.dividerHeight)))
|
|
|
|
.expand((i) => i)
|
|
|
|
.toList(),
|
|
|
|
elevation: 8,
|
|
|
|
);
|
2022-09-19 20:26:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void abAddId() async {
|
2023-07-26 20:43:18 +08:00
|
|
|
if (gFFI.abModel.isFull(true)) {
|
|
|
|
return;
|
|
|
|
}
|
2022-09-19 20:26:39 +08:00
|
|
|
var isInProgress = false;
|
2022-11-27 12:16:45 +08:00
|
|
|
IDTextEditingController idController = IDTextEditingController(text: '');
|
|
|
|
TextEditingController aliasController = TextEditingController(text: '');
|
|
|
|
final tags = List.of(gFFI.abModel.tags);
|
|
|
|
var selectedTag = List<dynamic>.empty(growable: true).obs;
|
|
|
|
final style = TextStyle(fontSize: 14.0);
|
|
|
|
String? errorMsg;
|
2022-09-19 20:26:39 +08:00
|
|
|
|
2023-05-08 12:34:19 +08:00
|
|
|
gFFI.dialogManager.show((setState, close, context) {
|
2022-09-19 20:26:39 +08:00
|
|
|
submit() async {
|
|
|
|
setState(() {
|
|
|
|
isInProgress = true;
|
2022-11-27 12:16:45 +08:00
|
|
|
errorMsg = null;
|
2022-09-19 20:26:39 +08:00
|
|
|
});
|
2022-11-27 12:16:45 +08:00
|
|
|
String id = idController.id;
|
|
|
|
if (id.isEmpty) {
|
2022-09-19 20:26:39 +08:00
|
|
|
// pass
|
|
|
|
} else {
|
2022-11-27 12:16:45 +08:00
|
|
|
if (gFFI.abModel.idContainBy(id)) {
|
|
|
|
setState(() {
|
|
|
|
isInProgress = false;
|
|
|
|
errorMsg = translate('ID already exists');
|
|
|
|
});
|
|
|
|
return;
|
2022-09-19 20:26:39 +08:00
|
|
|
}
|
2022-11-27 12:16:45 +08:00
|
|
|
gFFI.abModel.addId(id, aliasController.text.trim(), selectedTag);
|
2022-10-08 16:13:24 +08:00
|
|
|
await gFFI.abModel.pushAb();
|
2022-09-19 20:26:39 +08:00
|
|
|
this.setState(() {});
|
|
|
|
// final currentPeers
|
|
|
|
}
|
|
|
|
close();
|
|
|
|
}
|
|
|
|
|
|
|
|
return CustomAlertDialog(
|
|
|
|
title: Text(translate("Add ID")),
|
|
|
|
content: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
2022-11-27 12:16:45 +08:00
|
|
|
Column(
|
2022-09-19 20:26:39 +08:00
|
|
|
children: [
|
2022-11-27 12:16:45 +08:00
|
|
|
Align(
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
'*',
|
|
|
|
style: TextStyle(color: Colors.red, fontSize: 14),
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
'ID',
|
|
|
|
style: style,
|
2022-09-19 20:26:39 +08:00
|
|
|
),
|
2022-11-27 12:16:45 +08:00
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
TextField(
|
|
|
|
controller: idController,
|
|
|
|
inputFormatters: [IDTextInputFormatter()],
|
2023-03-18 02:05:43 +08:00
|
|
|
decoration: InputDecoration(errorText: errorMsg),
|
2022-11-27 12:16:45 +08:00
|
|
|
),
|
|
|
|
Align(
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: Text(
|
|
|
|
translate('Alias'),
|
|
|
|
style: style,
|
|
|
|
),
|
|
|
|
).marginOnly(top: 8, bottom: 2),
|
|
|
|
TextField(
|
|
|
|
controller: aliasController,
|
|
|
|
),
|
|
|
|
Align(
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: Text(
|
|
|
|
translate('Tags'),
|
|
|
|
style: style,
|
|
|
|
),
|
|
|
|
).marginOnly(top: 8),
|
|
|
|
Container(
|
|
|
|
child: Wrap(
|
|
|
|
children: tags
|
|
|
|
.map((e) => AddressBookTag(
|
|
|
|
name: e,
|
|
|
|
tags: selectedTag,
|
|
|
|
onTap: () {
|
|
|
|
if (selectedTag.contains(e)) {
|
|
|
|
selectedTag.remove(e);
|
|
|
|
} else {
|
|
|
|
selectedTag.add(e);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
showActionMenu: false))
|
|
|
|
.toList(growable: false),
|
|
|
|
),
|
2022-09-19 20:26:39 +08:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 4.0,
|
|
|
|
),
|
|
|
|
Offstage(
|
|
|
|
offstage: !isInProgress, child: const LinearProgressIndicator())
|
|
|
|
],
|
|
|
|
),
|
|
|
|
actions: [
|
2023-01-15 19:46:16 +08:00
|
|
|
dialogButton("Cancel", onPressed: close, isOutline: true),
|
|
|
|
dialogButton("OK", onPressed: submit),
|
2022-09-19 20:26:39 +08:00
|
|
|
],
|
|
|
|
onSubmit: submit,
|
|
|
|
onCancel: close,
|
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
void abAddTag() async {
|
|
|
|
var field = "";
|
|
|
|
var msg = "";
|
|
|
|
var isInProgress = false;
|
|
|
|
TextEditingController controller = TextEditingController(text: field);
|
2023-05-08 12:34:19 +08:00
|
|
|
gFFI.dialogManager.show((setState, close, context) {
|
2022-09-19 20:26:39 +08:00
|
|
|
submit() async {
|
|
|
|
setState(() {
|
|
|
|
msg = "";
|
|
|
|
isInProgress = true;
|
|
|
|
});
|
|
|
|
field = controller.text.trim();
|
|
|
|
if (field.isEmpty) {
|
|
|
|
// pass
|
|
|
|
} else {
|
|
|
|
final tags = field.trim().split(RegExp(r"[\s,;\n]+"));
|
|
|
|
field = tags.join(',');
|
|
|
|
for (final tag in tags) {
|
|
|
|
gFFI.abModel.addTag(tag);
|
|
|
|
}
|
2022-10-08 16:13:24 +08:00
|
|
|
await gFFI.abModel.pushAb();
|
2022-09-19 20:26:39 +08:00
|
|
|
// final currentPeers
|
|
|
|
}
|
|
|
|
close();
|
|
|
|
}
|
|
|
|
|
|
|
|
return CustomAlertDialog(
|
|
|
|
title: Text(translate("Add Tag")),
|
|
|
|
content: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Text(translate("whitelist_sep")),
|
|
|
|
const SizedBox(
|
|
|
|
height: 8.0,
|
|
|
|
),
|
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: TextField(
|
|
|
|
maxLines: null,
|
|
|
|
decoration: InputDecoration(
|
|
|
|
errorText: msg.isEmpty ? null : translate(msg),
|
|
|
|
),
|
|
|
|
controller: controller,
|
2023-02-12 09:03:13 +08:00
|
|
|
autofocus: true,
|
2022-09-19 20:26:39 +08:00
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 4.0,
|
|
|
|
),
|
|
|
|
Offstage(
|
|
|
|
offstage: !isInProgress, child: const LinearProgressIndicator())
|
|
|
|
],
|
|
|
|
),
|
|
|
|
actions: [
|
2023-01-15 19:46:16 +08:00
|
|
|
dialogButton("Cancel", onPressed: close, isOutline: true),
|
|
|
|
dialogButton("OK", onPressed: submit),
|
2022-09-19 20:26:39 +08:00
|
|
|
],
|
|
|
|
onSubmit: submit,
|
|
|
|
onCancel: close,
|
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|
2022-10-08 16:39:05 +08:00
|
|
|
}
|
2022-09-19 20:26:39 +08:00
|
|
|
|
2022-10-08 16:39:05 +08:00
|
|
|
class AddressBookTag extends StatelessWidget {
|
|
|
|
final String name;
|
|
|
|
final RxList<dynamic> tags;
|
|
|
|
final Function()? onTap;
|
2022-10-08 18:52:02 +08:00
|
|
|
final bool showActionMenu;
|
2022-09-19 20:26:39 +08:00
|
|
|
|
2022-10-08 16:39:05 +08:00
|
|
|
const AddressBookTag(
|
|
|
|
{Key? key,
|
|
|
|
required this.name,
|
|
|
|
required this.tags,
|
|
|
|
this.onTap,
|
2022-10-08 18:52:02 +08:00
|
|
|
this.showActionMenu = true})
|
2022-10-08 16:39:05 +08:00
|
|
|
: super(key: key);
|
2022-09-19 20:26:39 +08:00
|
|
|
|
2022-10-08 16:39:05 +08:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2022-10-08 18:52:02 +08:00
|
|
|
var pos = RelativeRect.fill;
|
|
|
|
|
|
|
|
void setPosition(TapDownDetails e) {
|
|
|
|
final x = e.globalPosition.dx;
|
|
|
|
final y = e.globalPosition.dy;
|
|
|
|
pos = RelativeRect.fromLTRB(x, y, x, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
return GestureDetector(
|
2022-10-08 16:39:05 +08:00
|
|
|
onTap: onTap,
|
2022-10-08 18:52:02 +08:00
|
|
|
onTapDown: showActionMenu ? setPosition : null,
|
|
|
|
onSecondaryTapDown: showActionMenu ? setPosition : null,
|
|
|
|
onSecondaryTap: showActionMenu ? () => _showMenu(context, pos) : null,
|
|
|
|
onLongPress: showActionMenu ? () => _showMenu(context, pos) : null,
|
2022-10-08 16:39:05 +08:00
|
|
|
child: Obx(
|
|
|
|
() => Container(
|
|
|
|
decoration: BoxDecoration(
|
2023-06-21 19:39:55 +08:00
|
|
|
color: tags.contains(name)
|
|
|
|
? Colors.blue
|
|
|
|
: Theme.of(context).colorScheme.background,
|
2022-10-08 16:39:05 +08:00
|
|
|
borderRadius: BorderRadius.circular(6)),
|
|
|
|
margin: const EdgeInsets.symmetric(horizontal: 4.0, vertical: 8.0),
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 2.0, horizontal: 8.0),
|
|
|
|
child: Text(name,
|
|
|
|
style:
|
|
|
|
TextStyle(color: tags.contains(name) ? Colors.white : null)),
|
2022-09-19 20:26:39 +08:00
|
|
|
),
|
2022-10-08 16:39:05 +08:00
|
|
|
),
|
|
|
|
);
|
2022-09-19 20:26:39 +08:00
|
|
|
}
|
2022-10-08 18:52:02 +08:00
|
|
|
|
|
|
|
void _showMenu(BuildContext context, RelativeRect pos) {
|
|
|
|
final items = [
|
|
|
|
getEntry(translate("Delete"), () {
|
|
|
|
gFFI.abModel.deleteTag(name);
|
|
|
|
gFFI.abModel.pushAb();
|
|
|
|
Future.delayed(Duration.zero, () => Get.back());
|
|
|
|
}),
|
|
|
|
];
|
|
|
|
|
|
|
|
mod_menu.showMenu(
|
|
|
|
context: context,
|
|
|
|
position: pos,
|
|
|
|
items: items
|
|
|
|
.map((e) => e.build(
|
|
|
|
context,
|
|
|
|
MenuConfig(
|
|
|
|
commonColor: CustomPopupMenuTheme.commonColor,
|
|
|
|
height: CustomPopupMenuTheme.height,
|
|
|
|
dividerHeight: CustomPopupMenuTheme.dividerHeight)))
|
|
|
|
.expand((i) => i)
|
|
|
|
.toList(),
|
|
|
|
elevation: 8,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MenuEntryButton<String> getEntry(String title, VoidCallback proc) {
|
|
|
|
return MenuEntryButton<String>(
|
|
|
|
childBuilder: (TextStyle? style) => Text(
|
|
|
|
title,
|
|
|
|
style: style,
|
|
|
|
),
|
|
|
|
proc: proc,
|
|
|
|
dismissOnClicked: true,
|
|
|
|
);
|
2022-09-19 20:26:39 +08:00
|
|
|
}
|