mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-06-10 20:23:07 +08:00
mobile tag actions
This commit is contained in:
parent
715d837f54
commit
1ce8b1fee5
@ -21,6 +21,8 @@ class AddressBook extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _AddressBookState extends State<AddressBook> {
|
class _AddressBookState extends State<AddressBook> {
|
||||||
|
var menuPos = RelativeRect.fill;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@ -72,7 +74,9 @@ class _AddressBookState extends State<AddressBook> {
|
|||||||
if (gFFI.abModel.abError.isNotEmpty) {
|
if (gFFI.abModel.abError.isNotEmpty) {
|
||||||
return _buildShowError(gFFI.abModel.abError.value);
|
return _buildShowError(gFFI.abModel.abError.value);
|
||||||
}
|
}
|
||||||
return _buildAddressBook(context);
|
return isDesktop
|
||||||
|
? _buildAddressBookDesktop()
|
||||||
|
: _buildAddressBookMobile();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -92,8 +96,7 @@ class _AddressBookState extends State<AddressBook> {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildAddressBook(BuildContext context) {
|
Widget _buildAddressBookDesktop() {
|
||||||
var pos = RelativeRect.fill;
|
|
||||||
return Row(
|
return Row(
|
||||||
children: [
|
children: [
|
||||||
Card(
|
Card(
|
||||||
@ -109,20 +112,7 @@ class _AddressBookState extends State<AddressBook> {
|
|||||||
const EdgeInsets.symmetric(horizontal: 12.0, vertical: 8.0),
|
const EdgeInsets.symmetric(horizontal: 12.0, vertical: 8.0),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Row(
|
_buildTagHeader(),
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Text(translate('Tags')),
|
|
||||||
GestureDetector(
|
|
||||||
onTapDown: (e) {
|
|
||||||
final x = e.globalPosition.dx;
|
|
||||||
final y = e.globalPosition.dy;
|
|
||||||
pos = RelativeRect.fromLTRB(x, y, x, y);
|
|
||||||
},
|
|
||||||
onTap: () => _showMenu(pos),
|
|
||||||
child: ActionMore()),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Container(
|
child: Container(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
@ -130,40 +120,98 @@ class _AddressBookState extends State<AddressBook> {
|
|||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
border: Border.all(color: MyTheme.darkGray),
|
border: Border.all(color: MyTheme.darkGray),
|
||||||
borderRadius: BorderRadius.circular(2)),
|
borderRadius: BorderRadius.circular(2)),
|
||||||
child: Obx(
|
child: _buildTags(),
|
||||||
() => Wrap(
|
|
||||||
children: gFFI.abModel.tags
|
|
||||||
.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(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
).marginSymmetric(vertical: 8.0),
|
).marginSymmetric(vertical: 8.0),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
).marginOnly(right: 8.0),
|
).marginOnly(right: 8.0),
|
||||||
Expanded(
|
_buildPeersViews()
|
||||||
child: Align(
|
|
||||||
alignment: Alignment.topLeft,
|
|
||||||
child: Obx(() => AddressBookPeersView(
|
|
||||||
menuPadding: widget.menuPadding,
|
|
||||||
initPeers: gFFI.abModel.peers.value,
|
|
||||||
))),
|
|
||||||
)
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget _buildAddressBookMobile() {
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
Card(
|
||||||
|
margin: EdgeInsets.symmetric(horizontal: 1.0),
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(6),
|
||||||
|
side:
|
||||||
|
BorderSide(color: Theme.of(context).scaffoldBackgroundColor)),
|
||||||
|
child: Container(
|
||||||
|
padding:
|
||||||
|
const EdgeInsets.symmetric(horizontal: 12.0, vertical: 8.0),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
_buildTagHeader(),
|
||||||
|
Container(
|
||||||
|
width: double.infinity,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border: Border.all(color: MyTheme.darkGray),
|
||||||
|
borderRadius: BorderRadius.circular(4)),
|
||||||
|
child: _buildTags(),
|
||||||
|
).marginSymmetric(vertical: 8.0),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Divider(),
|
||||||
|
_buildPeersViews()
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildTagHeader() {
|
||||||
|
return Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(translate('Tags')),
|
||||||
|
GestureDetector(
|
||||||
|
onTapDown: (e) {
|
||||||
|
final x = e.globalPosition.dx;
|
||||||
|
final y = e.globalPosition.dy;
|
||||||
|
menuPos = RelativeRect.fromLTRB(x, y, x, y);
|
||||||
|
},
|
||||||
|
onTap: () => _showMenu(menuPos),
|
||||||
|
child: ActionMore()),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildTags() {
|
||||||
|
return Obx(
|
||||||
|
() => Wrap(
|
||||||
|
children: gFFI.abModel.tags
|
||||||
|
.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(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildPeersViews() {
|
||||||
|
return Expanded(
|
||||||
|
child: Align(
|
||||||
|
alignment: Alignment.topLeft,
|
||||||
|
child: Obx(() => AddressBookPeersView(
|
||||||
|
menuPadding: widget.menuPadding,
|
||||||
|
initPeers: gFFI.abModel.peers.value,
|
||||||
|
))),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
void _showMenu(RelativeRect pos) {
|
void _showMenu(RelativeRect pos) {
|
||||||
final items = [
|
final items = [
|
||||||
getEntry(translate("Add ID"), abAddId),
|
getEntry(translate("Add ID"), abAddId),
|
||||||
|
Loading…
Reference in New Issue
Block a user