mirror of
https://github.com/rustdesk/rustdesk.git
synced 2024-11-24 20:59:37 +08:00
fix ab tag selection state and opt ab style
This commit is contained in:
parent
ff9c3bccb5
commit
9449e50ba4
@ -113,8 +113,9 @@ class _AddressBookState extends State<AddressBook> {
|
||||
builder: (context, model, child) => Row(
|
||||
children: [
|
||||
Card(
|
||||
margin: EdgeInsets.symmetric(horizontal: 4.0),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
side: BorderSide(
|
||||
color: Theme.of(context).scaffoldBackgroundColor)),
|
||||
child: Container(
|
||||
@ -127,6 +128,7 @@ class _AddressBookState extends State<AddressBook> {
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
// TODO same style as peer
|
||||
Text(translate('Tags')),
|
||||
InkWell(
|
||||
child: PopupMenuButton(
|
||||
@ -155,7 +157,8 @@ class _AddressBookState extends State<AddressBook> {
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: MyTheme.darkGray)),
|
||||
border: Border.all(color: MyTheme.darkGray),
|
||||
borderRadius: BorderRadius.circular(2)),
|
||||
child: Obx(
|
||||
() => Wrap(
|
||||
children: gFFI.abModel.tags
|
||||
@ -210,7 +213,7 @@ class _AddressBookState extends State<AddressBook> {
|
||||
decoration: BoxDecoration(
|
||||
color: rxTags.contains(tagName) ? Colors.blue : null,
|
||||
border: Border.all(color: MyTheme.darkGray),
|
||||
borderRadius: BorderRadius.circular(10)),
|
||||
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(
|
||||
|
@ -3,7 +3,6 @@ import 'dart:async';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hbb/consts.dart';
|
||||
import 'package:flutter_hbb/desktop/widgets/scroll_wrapper.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:visibility_detector/visibility_detector.dart';
|
||||
@ -14,8 +13,7 @@ import '../../models/peer_model.dart';
|
||||
import '../../models/platform_model.dart';
|
||||
import 'peer_card.dart';
|
||||
|
||||
typedef OffstageFunc = bool Function(Peer peer);
|
||||
typedef PeerCardBuilder = BasePeerCard Function(Peer peer);
|
||||
typedef PeerCardBuilder = Widget Function(Peer peer);
|
||||
|
||||
/// for peer search text, global obs value
|
||||
final peerSearchText = "".obs;
|
||||
@ -24,16 +22,10 @@ final peerSearchTextController =
|
||||
|
||||
class _PeersView extends StatefulWidget {
|
||||
final Peers peers;
|
||||
final OffstageFunc offstageFunc;
|
||||
final PeerCardBuilder peerCardBuilder;
|
||||
final ScrollController? scrollController;
|
||||
|
||||
const _PeersView(
|
||||
{required this.peers,
|
||||
required this.offstageFunc,
|
||||
required this.peerCardBuilder,
|
||||
Key? key,
|
||||
this.scrollController})
|
||||
{required this.peers, required this.peerCardBuilder, Key? key})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
@ -124,20 +116,16 @@ class _PeersViewState extends State<_PeersView> with WindowListener {
|
||||
},
|
||||
child: widget.peerCardBuilder(peer),
|
||||
);
|
||||
cards.add(Offstage(
|
||||
key: ValueKey("off${peer.id}"),
|
||||
offstage: widget.offstageFunc(peer),
|
||||
child: isDesktop
|
||||
? Obx(
|
||||
() => SizedBox(
|
||||
width: 220,
|
||||
height: peerCardUiType.value == PeerUiType.grid
|
||||
? 140
|
||||
: 42,
|
||||
child: visibilityChild,
|
||||
),
|
||||
)
|
||||
: SizedBox(width: mobileWidth, child: visibilityChild)));
|
||||
cards.add(isDesktop
|
||||
? Obx(
|
||||
() => SizedBox(
|
||||
width: 220,
|
||||
height:
|
||||
peerCardUiType.value == PeerUiType.grid ? 140 : 42,
|
||||
child: visibilityChild,
|
||||
),
|
||||
)
|
||||
: SizedBox(width: mobileWidth, child: visibilityChild));
|
||||
}
|
||||
return Wrap(spacing: space, runSpacing: space, children: cards);
|
||||
} else {
|
||||
@ -190,7 +178,6 @@ class _PeersViewState extends State<_PeersView> with WindowListener {
|
||||
abstract class BasePeersView extends StatelessWidget {
|
||||
final String name;
|
||||
final String loadEvent;
|
||||
final OffstageFunc offstageFunc;
|
||||
final PeerCardBuilder peerCardBuilder;
|
||||
final List<Peer> initPeers;
|
||||
|
||||
@ -198,7 +185,6 @@ abstract class BasePeersView extends StatelessWidget {
|
||||
Key? key,
|
||||
required this.name,
|
||||
required this.loadEvent,
|
||||
required this.offstageFunc,
|
||||
required this.peerCardBuilder,
|
||||
required this.initPeers,
|
||||
}) : super(key: key);
|
||||
@ -207,7 +193,6 @@ abstract class BasePeersView extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return _PeersView(
|
||||
peers: Peers(name: name, loadEvent: loadEvent, peers: initPeers),
|
||||
offstageFunc: offstageFunc,
|
||||
peerCardBuilder: peerCardBuilder);
|
||||
}
|
||||
}
|
||||
@ -219,7 +204,6 @@ class RecentPeersView extends BasePeersView {
|
||||
key: key,
|
||||
name: 'recent peer',
|
||||
loadEvent: 'load_recent_peers',
|
||||
offstageFunc: (Peer peer) => false,
|
||||
peerCardBuilder: (Peer peer) => RecentPeerCard(
|
||||
peer: peer,
|
||||
menuPadding: menuPadding,
|
||||
@ -242,7 +226,6 @@ class FavoritePeersView extends BasePeersView {
|
||||
key: key,
|
||||
name: 'favorite peer',
|
||||
loadEvent: 'load_fav_peers',
|
||||
offstageFunc: (Peer peer) => false,
|
||||
peerCardBuilder: (Peer peer) => FavoritePeerCard(
|
||||
peer: peer,
|
||||
menuPadding: menuPadding,
|
||||
@ -265,7 +248,6 @@ class DiscoveredPeersView extends BasePeersView {
|
||||
key: key,
|
||||
name: 'discovered peer',
|
||||
loadEvent: 'load_lan_peers',
|
||||
offstageFunc: (Peer peer) => false,
|
||||
peerCardBuilder: (Peer peer) => DiscoveredPeerCard(
|
||||
peer: peer,
|
||||
menuPadding: menuPadding,
|
||||
@ -288,12 +270,13 @@ class AddressBookPeersView extends BasePeersView {
|
||||
key: key,
|
||||
name: 'address book peer',
|
||||
loadEvent: 'load_address_book_peers',
|
||||
offstageFunc: (Peer peer) =>
|
||||
!_hitTag(gFFI.abModel.selectedTags, peer.tags),
|
||||
peerCardBuilder: (Peer peer) => AddressBookPeerCard(
|
||||
peer: peer,
|
||||
menuPadding: menuPadding,
|
||||
),
|
||||
peerCardBuilder: (Peer peer) => Obx(() => Offstage(
|
||||
key: ValueKey("off${peer.id}"),
|
||||
offstage: !_hitTag(gFFI.abModel.selectedTags, peer.tags),
|
||||
child: AddressBookPeerCard(
|
||||
peer: peer,
|
||||
menuPadding: menuPadding,
|
||||
))),
|
||||
initPeers: _loadPeers(),
|
||||
);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user