Merge pull request #4562 from grummbeer/cleanup-page-install
Cleanup page install
This commit is contained in:
commit
d2bb866e48
@ -7,6 +7,7 @@ import 'package:flutter_hbb/desktop/widgets/tabbar_widget.dart';
|
|||||||
import 'package:flutter_hbb/models/platform_model.dart';
|
import 'package:flutter_hbb/models/platform_model.dart';
|
||||||
import 'package:flutter_hbb/models/state_model.dart';
|
import 'package:flutter_hbb/models/state_model.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
import 'package:path/path.dart';
|
||||||
import 'package:url_launcher/url_launcher_string.dart';
|
import 'package:url_launcher/url_launcher_string.dart';
|
||||||
import 'package:window_manager/window_manager.dart';
|
import 'package:window_manager/window_manager.dart';
|
||||||
|
|
||||||
@ -69,6 +70,12 @@ class _InstallPageBodyState extends State<_InstallPageBody>
|
|||||||
final RxBool showProgress = false.obs;
|
final RxBool showProgress = false.obs;
|
||||||
final RxBool btnEnabled = true.obs;
|
final RxBool btnEnabled = true.obs;
|
||||||
|
|
||||||
|
// todo move to theme.
|
||||||
|
final buttonStyle = OutlinedButton.styleFrom(
|
||||||
|
textStyle: TextStyle(fontSize: 14, fontWeight: FontWeight.normal),
|
||||||
|
padding: EdgeInsets.symmetric(vertical: 15, horizontal: 12),
|
||||||
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
windowManager.addListener(this);
|
windowManager.addListener(this);
|
||||||
@ -90,177 +97,153 @@ class _InstallPageBodyState extends State<_InstallPageBody>
|
|||||||
windowManager.close();
|
windowManager.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InkWell Option(RxBool option, {String label = ''}) {
|
||||||
|
return InkWell(
|
||||||
|
// todo mouseCursor: "SystemMouseCursors.forbidden" or no cursor on btnEnabled == false
|
||||||
|
borderRadius: BorderRadius.circular(6),
|
||||||
|
onTap: () => btnEnabled.value ? option.value = !option.value : null,
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Obx(
|
||||||
|
() => Checkbox(
|
||||||
|
visualDensity: VisualDensity(horizontal: -4, vertical: -4),
|
||||||
|
value: option.value,
|
||||||
|
onChanged: (v) =>
|
||||||
|
btnEnabled.value ? option.value = !option.value : null,
|
||||||
|
).marginOnly(right: 8),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Text(translate(label)),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final double em = 13;
|
final double em = 13;
|
||||||
final btnFontSize = 0.9 * em;
|
|
||||||
final double button_radius = 6;
|
|
||||||
final isDarkTheme = MyTheme.currentThemeMode() == ThemeMode.dark;
|
final isDarkTheme = MyTheme.currentThemeMode() == ThemeMode.dark;
|
||||||
final buttonStyle = OutlinedButton.styleFrom(
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.all(Radius.circular(button_radius)),
|
|
||||||
));
|
|
||||||
final inputBorder = OutlineInputBorder(
|
|
||||||
borderRadius: BorderRadius.zero,
|
|
||||||
borderSide:
|
|
||||||
BorderSide(color: isDarkTheme ? Colors.white70 : Colors.black12));
|
|
||||||
final textColor = isDarkTheme ? null : Colors.black87;
|
|
||||||
final dividerColor = isDarkTheme ? Colors.white70 : Colors.black87;
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: null,
|
backgroundColor: null,
|
||||||
body: SingleChildScrollView(
|
body: SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
|
Text(translate('Installation'),
|
||||||
|
style: Theme.of(context).textTheme.headlineMedium),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text('${translate('Installation Path')}:')
|
||||||
translate('Installation'),
|
.marginOnly(right: 10),
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 2 * em, fontWeight: FontWeight.w500),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Text('${translate('Installation Path')}: '),
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TextField(
|
child: TextField(
|
||||||
controller: controller,
|
controller: controller,
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
style: TextStyle(
|
decoration: InputDecoration(
|
||||||
fontSize: 1.5 * em, fontWeight: FontWeight.w400),
|
contentPadding: EdgeInsets.all(0.75 * em),
|
||||||
decoration: InputDecoration(
|
),
|
||||||
isDense: true,
|
).marginOnly(right: 10),
|
||||||
contentPadding: EdgeInsets.all(0.75 * em),
|
),
|
||||||
enabledBorder: inputBorder,
|
Obx(
|
||||||
border: inputBorder,
|
() => OutlinedButton.icon(
|
||||||
focusedBorder: inputBorder,
|
icon: Icon(Icons.folder_outlined, size: 16),
|
||||||
constraints: BoxConstraints(maxHeight: 3 * em),
|
onPressed: btnEnabled.value ? selectInstallPath : null,
|
||||||
|
style: buttonStyle,
|
||||||
|
label: Text(translate('Change Path')),
|
||||||
),
|
),
|
||||||
)),
|
)
|
||||||
Obx(() => OutlinedButton(
|
|
||||||
onPressed:
|
|
||||||
btnEnabled.value ? selectInstallPath : null,
|
|
||||||
style: buttonStyle,
|
|
||||||
child: Text(translate('Change Path'),
|
|
||||||
style: TextStyle(
|
|
||||||
color: textColor, fontSize: btnFontSize)))
|
|
||||||
.marginOnly(left: em))
|
|
||||||
],
|
],
|
||||||
).marginSymmetric(vertical: 2 * em),
|
).marginSymmetric(vertical: 2 * em),
|
||||||
TextButton(
|
Option(startmenu, label: 'Create start menu shortcuts')
|
||||||
onPressed: () => startmenu.value = !startmenu.value,
|
.marginOnly(bottom: 7),
|
||||||
child: Row(
|
Option(desktopicon, label: 'Create desktop icon'),
|
||||||
children: [
|
|
||||||
Obx(() => Checkbox(
|
|
||||||
value: startmenu.value,
|
|
||||||
onChanged: (b) {
|
|
||||||
if (b != null) startmenu.value = b;
|
|
||||||
})),
|
|
||||||
RichText(
|
|
||||||
text: TextSpan(
|
|
||||||
text: translate('Create start menu shortcuts'),
|
|
||||||
style: DefaultTextStyle.of(context).style,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
TextButton(
|
|
||||||
onPressed: () => desktopicon.value = !desktopicon.value,
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Obx(() => Checkbox(
|
|
||||||
value: desktopicon.value,
|
|
||||||
onChanged: (b) {
|
|
||||||
if (b != null) desktopicon.value = b;
|
|
||||||
})),
|
|
||||||
RichText(
|
|
||||||
text: TextSpan(
|
|
||||||
text: translate('Create desktop icon'),
|
|
||||||
style: DefaultTextStyle.of(context).style,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Offstage(
|
Offstage(
|
||||||
offstage: !Platform.isWindows,
|
offstage: !Platform.isWindows,
|
||||||
child: TextButton(
|
child: Option(driverCert, label: 'idd_driver_tip'),
|
||||||
onPressed: () => driverCert.value = !driverCert.value,
|
).marginOnly(top: 7),
|
||||||
child: Row(
|
Container(
|
||||||
children: [
|
padding: EdgeInsets.all(12),
|
||||||
Obx(() => Checkbox(
|
decoration: BoxDecoration(
|
||||||
value: driverCert.value,
|
color: isDarkTheme
|
||||||
onChanged: (b) {
|
? Color.fromARGB(135, 87, 87, 90)
|
||||||
if (b != null) driverCert.value = b;
|
: Colors.grey[100],
|
||||||
})),
|
borderRadius: BorderRadius.circular(8),
|
||||||
RichText(
|
border: Border.all(color: Colors.grey),
|
||||||
text: TextSpan(
|
|
||||||
text: translate('idd_driver_tip'),
|
|
||||||
style: DefaultTextStyle.of(context).style,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
|
||||||
),
|
|
||||||
GestureDetector(
|
|
||||||
onTap: () => launchUrlString('http://rustdesk.com/privacy'),
|
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Text(translate('End-user license agreement'),
|
Icon(Icons.info_outline_rounded, size: 32)
|
||||||
style: const TextStyle(
|
.marginOnly(right: 16),
|
||||||
decoration: TextDecoration.underline))
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(translate('agreement_tip'))
|
||||||
|
.marginOnly(bottom: em),
|
||||||
|
InkWell(
|
||||||
|
hoverColor: Colors.transparent,
|
||||||
|
onTap: () =>
|
||||||
|
launchUrlString('https://rustdesk.com/privacy'),
|
||||||
|
child: Tooltip(
|
||||||
|
message: 'https://rustdesk.com/privacy',
|
||||||
|
child: Row(children: [
|
||||||
|
Icon(Icons.launch_outlined, size: 16)
|
||||||
|
.marginOnly(right: 5),
|
||||||
|
Text(
|
||||||
|
translate('End-user license agreement'),
|
||||||
|
style: const TextStyle(
|
||||||
|
decoration: TextDecoration.underline),
|
||||||
|
)
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
],
|
],
|
||||||
)).marginOnly(top: 2 * em),
|
)).marginSymmetric(vertical: 2 * em),
|
||||||
Row(children: [Text(translate('agreement_tip'))])
|
|
||||||
.marginOnly(top: em),
|
|
||||||
Divider(color: dividerColor).marginSymmetric(vertical: 0.5 * em),
|
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Obx(() => Offstage(
|
child: Obx(() => Offstage(
|
||||||
offstage: !showProgress.value,
|
offstage: !showProgress.value,
|
||||||
child: LinearProgressIndicator(),
|
child:
|
||||||
))),
|
LinearProgressIndicator().marginOnly(right: 10),
|
||||||
Obx(() => OutlinedButton(
|
)),
|
||||||
onPressed: btnEnabled.value
|
),
|
||||||
? () => windowManager.close()
|
Obx(
|
||||||
: null,
|
() => OutlinedButton.icon(
|
||||||
style: buttonStyle,
|
icon: Icon(Icons.close_rounded, size: 16),
|
||||||
child: Text(translate('Cancel'),
|
label: Text(translate('Cancel')),
|
||||||
style: TextStyle(
|
onPressed:
|
||||||
color: textColor, fontSize: btnFontSize)))
|
btnEnabled.value ? () => windowManager.close() : null,
|
||||||
.marginSymmetric(horizontal: 2 * em)),
|
style: buttonStyle,
|
||||||
Obx(() => ElevatedButton(
|
).marginOnly(right: 10),
|
||||||
|
),
|
||||||
|
Obx(
|
||||||
|
() => ElevatedButton.icon(
|
||||||
|
icon: Icon(Icons.done_rounded, size: 16),
|
||||||
|
label: Text(translate('Accept and Install')),
|
||||||
onPressed: btnEnabled.value ? install : null,
|
onPressed: btnEnabled.value ? install : null,
|
||||||
style: ElevatedButton.styleFrom(
|
style: buttonStyle,
|
||||||
primary: MyTheme.button,
|
),
|
||||||
shape: RoundedRectangleBorder(
|
),
|
||||||
borderRadius: BorderRadius.all(
|
|
||||||
Radius.circular(button_radius)),
|
|
||||||
)),
|
|
||||||
child: Text(
|
|
||||||
translate('Accept and Install'),
|
|
||||||
style: TextStyle(fontSize: btnFontSize),
|
|
||||||
))),
|
|
||||||
Offstage(
|
Offstage(
|
||||||
offstage: bind.installShowRunWithoutInstall(),
|
offstage: bind.installShowRunWithoutInstall(),
|
||||||
child: Obx(() => OutlinedButton(
|
child: Obx(
|
||||||
onPressed: btnEnabled.value
|
() => OutlinedButton.icon(
|
||||||
? () => bind.installRunWithoutInstall()
|
icon: Icon(Icons.screen_share_outlined, size: 16),
|
||||||
: null,
|
label: Text(translate('Run without install')),
|
||||||
style: buttonStyle,
|
onPressed: btnEnabled.value
|
||||||
child: Text(translate('Run without install'),
|
? () => bind.installRunWithoutInstall()
|
||||||
style: TextStyle(
|
: null,
|
||||||
color: textColor, fontSize: btnFontSize)))
|
style: buttonStyle,
|
||||||
.marginOnly(left: 2 * em)),
|
).marginOnly(left: 10),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
).paddingSymmetric(horizontal: 8 * em, vertical: 2 * em),
|
).paddingSymmetric(horizontal: 4 * em, vertical: 3 * em),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,19 +261,21 @@ class _InstallPageBodyState extends State<_InstallPageBody>
|
|||||||
if (driverCert.isTrue) {
|
if (driverCert.isTrue) {
|
||||||
final tag = 'install-info-install-cert-confirm';
|
final tag = 'install-info-install-cert-confirm';
|
||||||
final btns = [
|
final btns = [
|
||||||
dialogButton(
|
OutlinedButton.icon(
|
||||||
'Cancel',
|
icon: Icon(Icons.close_rounded, size: 16),
|
||||||
|
label: Text(translate('Cancel')),
|
||||||
onPressed: () => gFFI.dialogManager.dismissByTag(tag),
|
onPressed: () => gFFI.dialogManager.dismissByTag(tag),
|
||||||
isOutline: true,
|
style: buttonStyle,
|
||||||
),
|
),
|
||||||
dialogButton(
|
ElevatedButton.icon(
|
||||||
'OK',
|
icon: Icon(Icons.done_rounded, size: 16),
|
||||||
|
label: Text(translate('OK')),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
gFFI.dialogManager.dismissByTag(tag);
|
gFFI.dialogManager.dismissByTag(tag);
|
||||||
do_install();
|
do_install();
|
||||||
},
|
},
|
||||||
isOutline: false,
|
style: buttonStyle,
|
||||||
),
|
)
|
||||||
];
|
];
|
||||||
gFFI.dialogManager.show(
|
gFFI.dialogManager.show(
|
||||||
(setState, close, context) => CustomAlertDialog(
|
(setState, close, context) => CustomAlertDialog(
|
||||||
@ -312,8 +297,7 @@ class _InstallPageBodyState extends State<_InstallPageBody>
|
|||||||
String? install_path = await FilePicker.platform
|
String? install_path = await FilePicker.platform
|
||||||
.getDirectoryPath(initialDirectory: controller.text);
|
.getDirectoryPath(initialDirectory: controller.text);
|
||||||
if (install_path != null) {
|
if (install_path != null) {
|
||||||
install_path = '$install_path\\${await bind.mainGetAppName()}';
|
controller.text = join(install_path, await bind.mainGetAppName());
|
||||||
controller.text = install_path;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user