@@ -58,35 +58,40 @@ class _PeerCardState extends State<_PeerCard>
58
58
stateGlobal.isPortrait.isTrue ? _buildPortrait () : _buildLandscape ());
59
59
}
60
60
61
+ Widget gestureDetector ({required Widget child}) {
62
+ final PeerTabModel peerTabModel = Provider .of (context);
63
+ final peer = super .widget.peer;
64
+ return GestureDetector (
65
+ onDoubleTap: peerTabModel.multiSelectionMode
66
+ ? null
67
+ : () => widget.connect (context, peer.id),
68
+ onTap: () {
69
+ if (peerTabModel.multiSelectionMode) {
70
+ peerTabModel.select (peer);
71
+ } else {
72
+ if (isMobile) {
73
+ widget.connect (context, peer.id);
74
+ } else {
75
+ peerTabModel.select (peer);
76
+ }
77
+ }
78
+ },
79
+ onLongPress: () => peerTabModel.select (peer),
80
+ child: child);
81
+ }
82
+
61
83
Widget _buildPortrait () {
62
84
final peer = super .widget.peer;
63
- final PeerTabModel peerTabModel = Provider .of (context);
64
85
return Card (
65
86
margin: EdgeInsets .symmetric (horizontal: 2 ),
66
- child: GestureDetector (
67
- onTap: () {
68
- if (peerTabModel.multiSelectionMode) {
69
- peerTabModel.select (peer);
70
- } else {
71
- if (! isWebDesktop) {
72
- connectInPeerTab (context, peer, widget.tab);
73
- }
74
- }
75
- },
76
- onDoubleTap: isWebDesktop
77
- ? () => connectInPeerTab (context, peer, widget.tab)
78
- : null ,
79
- onLongPress: () {
80
- peerTabModel.select (peer);
81
- },
87
+ child: gestureDetector (
82
88
child: Container (
83
89
padding: EdgeInsets .only (left: 12 , top: 8 , bottom: 8 ),
84
90
child: _buildPeerTile (context, peer, null )),
85
91
));
86
92
}
87
93
88
94
Widget _buildLandscape () {
89
- final PeerTabModel peerTabModel = Provider .of (context);
90
95
final peer = super .widget.peer;
91
96
var deco = Rx <BoxDecoration ?>(
92
97
BoxDecoration (
@@ -115,30 +120,21 @@ class _PeerCardState extends State<_PeerCard>
115
120
),
116
121
);
117
122
},
118
- child: GestureDetector (
119
- onDoubleTap:
120
- peerTabModel.multiSelectionMode || peerTabModel.isShiftDown
121
- ? null
122
- : () => widget.connect (context, peer.id),
123
- onTap: () => peerTabModel.select (peer),
124
- onLongPress: () => peerTabModel.select (peer),
123
+ child: gestureDetector (
125
124
child: Obx (() => peerCardUiType.value == PeerUiType .grid
126
125
? _buildPeerCard (context, peer, deco)
127
126
: _buildPeerTile (context, peer, deco))),
128
127
);
129
128
}
130
129
131
- Widget _buildPeerTile (
132
- BuildContext context, Peer peer, Rx <BoxDecoration ?>? deco) {
133
- hideUsernameOnCard ?? =
134
- bind.mainGetBuildinOption (key: kHideUsernameOnCard) == 'Y' ;
130
+ makeChild (bool isPortrait, Peer peer) {
135
131
final name = hideUsernameOnCard == true
136
132
? peer.hostname
137
133
: '${peer .username }${peer .username .isNotEmpty && peer .hostname .isNotEmpty ? '@' : '' }${peer .hostname }' ;
138
134
final greyStyle = TextStyle (
139
135
fontSize: 11 ,
140
136
color: Theme .of (context).textTheme.titleLarge? .color? .withOpacity (0.6 ));
141
- makeChild ( bool isPortrait) => Row (
137
+ return Row (
142
138
mainAxisSize: MainAxisSize .max,
143
139
children: [
144
140
Container (
@@ -210,6 +206,12 @@ class _PeerCardState extends State<_PeerCard>
210
206
)
211
207
],
212
208
);
209
+ }
210
+
211
+ Widget _buildPeerTile (
212
+ BuildContext context, Peer peer, Rx <BoxDecoration ?>? deco) {
213
+ hideUsernameOnCard ?? =
214
+ bind.mainGetBuildinOption (key: kHideUsernameOnCard) == 'Y' ;
213
215
final colors = _frontN (peer.tags, 25 )
214
216
.map ((e) => gFFI.abModel.getCurrentAbTagColor (e))
215
217
.toList ();
@@ -220,21 +222,22 @@ class _PeerCardState extends State<_PeerCard>
220
222
? '${translate ('Tags' )}: ${peer .tags .join (', ' )}'
221
223
: '' ,
222
224
child: Stack (children: [
223
- Obx (() => deco == null
224
- ? makeChild (stateGlobal.isPortrait.isTrue)
225
- : Container (
225
+ Obx (
226
+ () => deco == null
227
+ ? makeChild (stateGlobal.isPortrait.isTrue, peer)
228
+ : Container (
226
229
foregroundDecoration: deco.value,
227
- child: makeChild (stateGlobal.isPortrait.isTrue),
230
+ child: makeChild (stateGlobal.isPortrait.isTrue, peer ),
228
231
),
229
- ),
232
+ ),
230
233
if (colors.isNotEmpty)
231
- Obx (()=> Positioned (
232
- top: 2 ,
233
- right: stateGlobal.isPortrait.isTrue ? 20 : 10 ,
234
- child: CustomPaint (
235
- painter: TagPainter (radius: 3 , colors: colors),
236
- ),
237
- ))
234
+ Obx (() => Positioned (
235
+ top: 2 ,
236
+ right: stateGlobal.isPortrait.isTrue ? 20 : 10 ,
237
+ child: CustomPaint (
238
+ painter: TagPainter (radius: 3 , colors: colors),
239
+ ),
240
+ ))
238
241
]),
239
242
);
240
243
}
@@ -1259,54 +1262,53 @@ void _rdpDialog(String id) async {
1259
1262
],
1260
1263
).marginOnly (bottom: isDesktop ? 8 : 0 ),
1261
1264
Obx (() => Row (
1262
- children: [
1263
- stateGlobal.isPortrait.isFalse
1264
- ? ConstrainedBox (
1265
- constraints: const BoxConstraints (minWidth: 140 ),
1266
- child: Text (
1267
- "${translate ('Username' )}:" ,
1268
- textAlign: TextAlign .right,
1269
- ).marginOnly (right: 10 ))
1270
- : SizedBox .shrink (),
1271
- Expanded (
1272
- child: TextField (
1273
- decoration: InputDecoration (
1274
- labelText: isDesktop
1275
- ? null
1276
- : translate ('Username' )),
1277
- controller: userController,
1278
- ),
1279
- ),
1280
- ],
1281
- ).marginOnly (bottom: stateGlobal.isPortrait.isFalse ? 8 : 0 )),
1282
- Obx (() => Row (
1283
- children: [
1284
- stateGlobal.isPortrait.isFalse
1285
- ? ConstrainedBox (
1286
- constraints: const BoxConstraints (minWidth: 140 ),
1287
- child: Text (
1288
- "${translate ('Password' )}:" ,
1289
- textAlign: TextAlign .right,
1290
- ).marginOnly (right: 10 ))
1291
- : SizedBox .shrink (),
1292
- Expanded (
1293
- child: Obx (() => TextField (
1294
- obscureText: secure.value,
1295
- maxLength: maxLength,
1265
+ children: [
1266
+ stateGlobal.isPortrait.isFalse
1267
+ ? ConstrainedBox (
1268
+ constraints: const BoxConstraints (minWidth: 140 ),
1269
+ child: Text (
1270
+ "${translate ('Username' )}:" ,
1271
+ textAlign: TextAlign .right,
1272
+ ).marginOnly (right: 10 ))
1273
+ : SizedBox .shrink (),
1274
+ Expanded (
1275
+ child: TextField (
1296
1276
decoration: InputDecoration (
1297
- labelText: isDesktop
1298
- ? null
1299
- : translate ('Password' ),
1300
- suffixIcon: IconButton (
1301
- onPressed: () => secure.value = ! secure.value,
1302
- icon: Icon (secure.value
1303
- ? Icons .visibility_off
1304
- : Icons .visibility))),
1305
- controller: passwordController,
1306
- )),
1307
- ),
1308
- ],
1309
- ))
1277
+ labelText:
1278
+ isDesktop ? null : translate ('Username' )),
1279
+ controller: userController,
1280
+ ),
1281
+ ),
1282
+ ],
1283
+ ).marginOnly (bottom: stateGlobal.isPortrait.isFalse ? 8 : 0 )),
1284
+ Obx (() => Row (
1285
+ children: [
1286
+ stateGlobal.isPortrait.isFalse
1287
+ ? ConstrainedBox (
1288
+ constraints: const BoxConstraints (minWidth: 140 ),
1289
+ child: Text (
1290
+ "${translate ('Password' )}:" ,
1291
+ textAlign: TextAlign .right,
1292
+ ).marginOnly (right: 10 ))
1293
+ : SizedBox .shrink (),
1294
+ Expanded (
1295
+ child: Obx (() => TextField (
1296
+ obscureText: secure.value,
1297
+ maxLength: maxLength,
1298
+ decoration: InputDecoration (
1299
+ labelText:
1300
+ isDesktop ? null : translate ('Password' ),
1301
+ suffixIcon: IconButton (
1302
+ onPressed: () =>
1303
+ secure.value = ! secure.value,
1304
+ icon: Icon (secure.value
1305
+ ? Icons .visibility_off
1306
+ : Icons .visibility))),
1307
+ controller: passwordController,
1308
+ )),
1309
+ ),
1310
+ ],
1311
+ ))
1310
1312
],
1311
1313
),
1312
1314
),
0 commit comments