Skip to content

Commit

Permalink
Merge branch 'rustdesk:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangbo8418 authored Sep 3, 2024
2 parents 602570a + 04c0f66 commit 7c00cc1
Show file tree
Hide file tree
Showing 19 changed files with 328 additions and 203 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 28 additions & 25 deletions flutter/lib/common/widgets/address_book.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import 'package:flutter_hbb/consts.dart';
import 'package:flutter_hbb/desktop/widgets/popup_menu.dart';
import 'package:flutter_hbb/models/ab_model.dart';
import 'package:flutter_hbb/models/platform_model.dart';
import 'package:flutter_hbb/models/state_model.dart';
import 'package:url_launcher/url_launcher_string.dart';
import '../../desktop/widgets/material_mod_popup_menu.dart' as mod_menu;
import 'package:get/get.dart';
Expand Down Expand Up @@ -61,15 +62,16 @@ class _AddressBookState extends State<AddressBook> {
retry: null, // remove retry
close: () => gFFI.abModel.currentAbPushError.value = ''),
Expanded(
child: (isDesktop || isWebDesktop)
? _buildAddressBookDesktop()
: _buildAddressBookMobile())
child: Obx(() => stateGlobal.isPortrait.isTrue
? _buildAddressBookPortrait()
: _buildAddressBookLandscape()),
),
],
);
}
});

Widget _buildAddressBookDesktop() {
Widget _buildAddressBookLandscape() {
return Row(
children: [
Offstage(
Expand Down Expand Up @@ -106,7 +108,7 @@ class _AddressBookState extends State<AddressBook> {
);
}

Widget _buildAddressBookMobile() {
Widget _buildAddressBookPortrait() {
const padding = 8.0;
return Column(
children: [
Expand Down Expand Up @@ -239,14 +241,14 @@ class _AddressBookState extends State<AddressBook> {
bind.setLocalFlutterOption(k: kOptionCurrentAbName, v: value);
}
},
customButton: Container(
height: isDesktop ? 48 : 40,
customButton: Obx(()=>Container(
height: stateGlobal.isPortrait.isFalse ? 48 : 40,
child: Row(children: [
Expanded(
child: buildItem(gFFI.abModel.currentName.value, button: true)),
Icon(Icons.arrow_drop_down),
]),
),
)),
underline: Container(
height: 0.7,
color: Theme.of(context).dividerColor.withOpacity(0.1),
Expand Down Expand Up @@ -335,18 +337,18 @@ class _AddressBookState extends State<AddressBook> {
showActionMenu: editPermission);
}

final gridView = DynamicGridView.builder(
shrinkWrap: isMobile,
gridView(bool isPortrait) => DynamicGridView.builder(
shrinkWrap: isPortrait,
gridDelegate: SliverGridDelegateWithWrapping(),
itemCount: tags.length,
itemBuilder: (BuildContext context, int index) {
final e = tags[index];
return tagBuilder(e);
});
final maxHeight = max(MediaQuery.of(context).size.height / 6, 100.0);
return (isDesktop || isWebDesktop)
? gridView
: LimitedBox(maxHeight: maxHeight, child: gridView);
return Obx(() => stateGlobal.isPortrait.isFalse
? gridView(false)
: LimitedBox(maxHeight: maxHeight, child: gridView(true)));
});
}

Expand Down Expand Up @@ -506,9 +508,9 @@ class _AddressBookState extends State<AddressBook> {
double marginBottom = 4;

row({required Widget lable, required Widget input}) {
return Row(
makeChild(bool isPortrait) => Row(
children: [
!isMobile
!isPortrait
? ConstrainedBox(
constraints: const BoxConstraints(minWidth: 100),
child: lable.marginOnly(right: 10))
Expand All @@ -519,7 +521,8 @@ class _AddressBookState extends State<AddressBook> {
child: input),
),
],
).marginOnly(bottom: !isMobile ? 8 : 0);
).marginOnly(bottom: !isPortrait ? 8 : 0);
return Obx(() => makeChild(stateGlobal.isPortrait.isTrue));
}

return CustomAlertDialog(
Expand All @@ -542,36 +545,36 @@ class _AddressBookState extends State<AddressBook> {
),
],
),
input: TextField(
input: Obx(() => TextField(
controller: idController,
inputFormatters: [IDTextInputFormatter()],
decoration: InputDecoration(
labelText: !isMobile ? null : translate('ID'),
labelText: stateGlobal.isPortrait.isFalse ? null : translate('ID'),
errorText: errorMsg,
errorMaxLines: 5),
)),
))),
row(
lable: Text(
translate('Alias'),
style: style,
),
input: TextField(
input: Obx(() => TextField(
controller: aliasController,
decoration: InputDecoration(
labelText: !isMobile ? null : translate('Alias'),
)),
labelText: stateGlobal.isPortrait.isFalse ? null : translate('Alias'),
),)),
),
if (isCurrentAbShared)
row(
lable: Text(
translate('Password'),
style: style,
),
input: TextField(
input: Obx(() => TextField(
controller: passwordController,
obscureText: !passwordVisible,
decoration: InputDecoration(
labelText: !isMobile ? null : translate('Password'),
labelText: stateGlobal.isPortrait.isFalse ? null : translate('Password'),
suffixIcon: IconButton(
icon: Icon(
passwordVisible
Expand All @@ -585,7 +588,7 @@ class _AddressBookState extends State<AddressBook> {
},
),
),
)),
),)),
if (gFFI.abModel.currentAbTags.isNotEmpty)
Align(
alignment: Alignment.centerLeft,
Expand Down
2 changes: 1 addition & 1 deletion flutter/lib/common/widgets/autocomplete.dart
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ class AutocompletePeerTileState extends State<AutocompletePeerTile> {
.map((e) => gFFI.abModel.getCurrentAbTagColor(e))
.toList();
return Tooltip(
message: isMobile
message: !(isDesktop || isWebDesktop)
? ''
: widget.peer.tags.isNotEmpty
? '${translate('Tags')}: ${widget.peer.tags.join(', ')}'
Expand Down
3 changes: 2 additions & 1 deletion flutter/lib/common/widgets/dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'package:flutter_hbb/common/widgets/setting_widgets.dart';
import 'package:flutter_hbb/consts.dart';
import 'package:flutter_hbb/models/peer_model.dart';
import 'package:flutter_hbb/models/peer_tab_model.dart';
import 'package:flutter_hbb/models/state_model.dart';
import 'package:get/get.dart';
import 'package:qr_flutter/qr_flutter.dart';

Expand Down Expand Up @@ -1123,7 +1124,7 @@ void showRequestElevationDialog(
errorText: errPwd.isEmpty ? null : errPwd.value,
),
],
).marginOnly(left: (isDesktop || isWebDesktop) ? 35 : 0),
).marginOnly(left: stateGlobal.isPortrait.isFalse ? 35 : 0),
).marginOnly(top: 10),
],
),
Expand Down
21 changes: 11 additions & 10 deletions flutter/lib/common/widgets/my_group.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_hbb/common/hbbs/hbbs.dart';
import 'package:flutter_hbb/common/widgets/login.dart';
import 'package:flutter_hbb/common/widgets/peers_view.dart';
import 'package:flutter_hbb/models/state_model.dart';
import 'package:get/get.dart';

import '../../common.dart';
Expand Down Expand Up @@ -45,15 +46,15 @@ class _MyGroupState extends State<MyGroup> {
retry: null,
close: () => gFFI.groupModel.groupLoadError.value = ''),
Expanded(
child: (isDesktop || isWebDesktop)
? _buildDesktop()
: _buildMobile())
child: Obx(() => stateGlobal.isPortrait.isTrue
? _buildPortrait()
: _buildLandscape())),
],
);
});
}

Widget _buildDesktop() {
Widget _buildLandscape() {
return Row(
children: [
Container(
Expand Down Expand Up @@ -89,7 +90,7 @@ class _MyGroupState extends State<MyGroup> {
);
}

Widget _buildMobile() {
Widget _buildPortrait() {
return Column(
children: [
Container(
Expand Down Expand Up @@ -159,14 +160,14 @@ class _MyGroupState extends State<MyGroup> {
}
return true;
}).toList();
final listView = ListView.builder(
shrinkWrap: isMobile,
listView(bool isPortrait) => ListView.builder(
shrinkWrap: isPortrait,
itemCount: items.length,
itemBuilder: (context, index) => _buildUserItem(items[index]));
var maxHeight = max(MediaQuery.of(context).size.height / 6, 100.0);
return (isDesktop || isWebDesktop)
? listView
: LimitedBox(maxHeight: maxHeight, child: listView);
return Obx(() => stateGlobal.isPortrait.isFalse
? listView(false)
: LimitedBox(maxHeight: maxHeight, child: listView(true)));
});
}

Expand Down
Loading

0 comments on commit 7c00cc1

Please sign in to comment.