mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
opt.: server edit page
This commit is contained in:
@@ -470,7 +470,7 @@
|
|||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CLANG_ENABLE_MODULES = YES;
|
CLANG_ENABLE_MODULES = YES;
|
||||||
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
||||||
CURRENT_PROJECT_VERSION = 525;
|
CURRENT_PROJECT_VERSION = 526;
|
||||||
DEVELOPMENT_TEAM = BA88US33G6;
|
DEVELOPMENT_TEAM = BA88US33G6;
|
||||||
ENABLE_BITCODE = NO;
|
ENABLE_BITCODE = NO;
|
||||||
INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist";
|
INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist";
|
||||||
@@ -478,7 +478,7 @@
|
|||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"@executable_path/Frameworks",
|
"@executable_path/Frameworks",
|
||||||
);
|
);
|
||||||
MARKETING_VERSION = 1.0.525;
|
MARKETING_VERSION = 1.0.526;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
|
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||||
@@ -602,7 +602,7 @@
|
|||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CLANG_ENABLE_MODULES = YES;
|
CLANG_ENABLE_MODULES = YES;
|
||||||
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
||||||
CURRENT_PROJECT_VERSION = 525;
|
CURRENT_PROJECT_VERSION = 526;
|
||||||
DEVELOPMENT_TEAM = BA88US33G6;
|
DEVELOPMENT_TEAM = BA88US33G6;
|
||||||
ENABLE_BITCODE = NO;
|
ENABLE_BITCODE = NO;
|
||||||
INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist";
|
INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist";
|
||||||
@@ -610,7 +610,7 @@
|
|||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"@executable_path/Frameworks",
|
"@executable_path/Frameworks",
|
||||||
);
|
);
|
||||||
MARKETING_VERSION = 1.0.525;
|
MARKETING_VERSION = 1.0.526;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
|
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||||
@@ -628,7 +628,7 @@
|
|||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CLANG_ENABLE_MODULES = YES;
|
CLANG_ENABLE_MODULES = YES;
|
||||||
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
||||||
CURRENT_PROJECT_VERSION = 525;
|
CURRENT_PROJECT_VERSION = 526;
|
||||||
DEVELOPMENT_TEAM = BA88US33G6;
|
DEVELOPMENT_TEAM = BA88US33G6;
|
||||||
ENABLE_BITCODE = NO;
|
ENABLE_BITCODE = NO;
|
||||||
INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist";
|
INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist";
|
||||||
@@ -636,7 +636,7 @@
|
|||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"@executable_path/Frameworks",
|
"@executable_path/Frameworks",
|
||||||
);
|
);
|
||||||
MARKETING_VERSION = 1.0.525;
|
MARKETING_VERSION = 1.0.526;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
|
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||||
@@ -657,7 +657,7 @@
|
|||||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 525;
|
CURRENT_PROJECT_VERSION = 526;
|
||||||
DEVELOPMENT_TEAM = BA88US33G6;
|
DEVELOPMENT_TEAM = BA88US33G6;
|
||||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||||
GENERATE_INFOPLIST_FILE = YES;
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
@@ -670,7 +670,7 @@
|
|||||||
"@executable_path/Frameworks",
|
"@executable_path/Frameworks",
|
||||||
"@executable_path/../../Frameworks",
|
"@executable_path/../../Frameworks",
|
||||||
);
|
);
|
||||||
MARKETING_VERSION = 1.0.525;
|
MARKETING_VERSION = 1.0.526;
|
||||||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||||
MTL_FAST_MATH = YES;
|
MTL_FAST_MATH = YES;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget;
|
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget;
|
||||||
@@ -696,7 +696,7 @@
|
|||||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 525;
|
CURRENT_PROJECT_VERSION = 526;
|
||||||
DEVELOPMENT_TEAM = BA88US33G6;
|
DEVELOPMENT_TEAM = BA88US33G6;
|
||||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||||
GENERATE_INFOPLIST_FILE = YES;
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
@@ -709,7 +709,7 @@
|
|||||||
"@executable_path/Frameworks",
|
"@executable_path/Frameworks",
|
||||||
"@executable_path/../../Frameworks",
|
"@executable_path/../../Frameworks",
|
||||||
);
|
);
|
||||||
MARKETING_VERSION = 1.0.525;
|
MARKETING_VERSION = 1.0.526;
|
||||||
MTL_FAST_MATH = YES;
|
MTL_FAST_MATH = YES;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget;
|
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
@@ -732,7 +732,7 @@
|
|||||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 525;
|
CURRENT_PROJECT_VERSION = 526;
|
||||||
DEVELOPMENT_TEAM = BA88US33G6;
|
DEVELOPMENT_TEAM = BA88US33G6;
|
||||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||||
GENERATE_INFOPLIST_FILE = YES;
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
@@ -745,7 +745,7 @@
|
|||||||
"@executable_path/Frameworks",
|
"@executable_path/Frameworks",
|
||||||
"@executable_path/../../Frameworks",
|
"@executable_path/../../Frameworks",
|
||||||
);
|
);
|
||||||
MARKETING_VERSION = 1.0.525;
|
MARKETING_VERSION = 1.0.526;
|
||||||
MTL_FAST_MATH = YES;
|
MTL_FAST_MATH = YES;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget;
|
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
|||||||
@@ -57,7 +57,8 @@ class MyApp extends StatelessWidget {
|
|||||||
ThemeData _getAmoledTheme(ThemeData darkTheme) => darkTheme.copyWith(
|
ThemeData _getAmoledTheme(ThemeData darkTheme) => darkTheme.copyWith(
|
||||||
scaffoldBackgroundColor: Colors.black,
|
scaffoldBackgroundColor: Colors.black,
|
||||||
dialogBackgroundColor: Colors.black,
|
dialogBackgroundColor: Colors.black,
|
||||||
drawerTheme: const DrawerThemeData(backgroundColor: Colors.black),
|
drawerTheme: const DrawerThemeData(
|
||||||
|
backgroundColor: Colors.black, shadowColor: Colors.black),
|
||||||
appBarTheme: const AppBarTheme(backgroundColor: Colors.black),
|
appBarTheme: const AppBarTheme(backgroundColor: Colors.black),
|
||||||
dialogTheme: const DialogTheme(backgroundColor: Colors.black),
|
dialogTheme: const DialogTheme(backgroundColor: Colors.black),
|
||||||
bottomSheetTheme:
|
bottomSheetTheme:
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
class BuildData {
|
class BuildData {
|
||||||
static const String name = "ServerBox";
|
static const String name = "ServerBox";
|
||||||
static const int build = 525;
|
static const int build = 526;
|
||||||
static const String engine = "3.13.1";
|
static const String engine = "3.13.1";
|
||||||
static const String buildAt = "2023-09-03 17:54:05.367410";
|
static const String buildAt = "2023-09-05 21:15:22.219124";
|
||||||
static const int modifications = 4;
|
static const int modifications = 2;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import 'package:provider/provider.dart';
|
|||||||
import 'package:toolbox/core/extension/context.dart';
|
import 'package:toolbox/core/extension/context.dart';
|
||||||
import 'package:toolbox/view/widget/input_field.dart';
|
import 'package:toolbox/view/widget/input_field.dart';
|
||||||
import 'package:toolbox/view/widget/round_rect_card.dart';
|
import 'package:toolbox/view/widget/round_rect_card.dart';
|
||||||
|
import 'package:toolbox/view/widget/value_notifier.dart';
|
||||||
|
|
||||||
import '../../../core/route.dart';
|
import '../../../core/route.dart';
|
||||||
import '../../../core/utils/ui.dart';
|
import '../../../core/utils/ui.dart';
|
||||||
@@ -13,7 +14,6 @@ import '../../../data/model/server/server_private_info.dart';
|
|||||||
import '../../../data/provider/private_key.dart';
|
import '../../../data/provider/private_key.dart';
|
||||||
import '../../../data/provider/server.dart';
|
import '../../../data/provider/server.dart';
|
||||||
import '../../../data/res/ui.dart';
|
import '../../../data/res/ui.dart';
|
||||||
import '../../../data/store/private_key.dart';
|
|
||||||
import '../../../locator.dart';
|
import '../../../locator.dart';
|
||||||
import '../../widget/custom_appbar.dart';
|
import '../../widget/custom_appbar.dart';
|
||||||
import '../../widget/tag.dart';
|
import '../../widget/tag.dart';
|
||||||
@@ -30,7 +30,7 @@ class ServerEditPage extends StatefulWidget {
|
|||||||
class _ServerEditPageState extends State<ServerEditPage> with AfterLayoutMixin {
|
class _ServerEditPageState extends State<ServerEditPage> with AfterLayoutMixin {
|
||||||
final _nameController = TextEditingController();
|
final _nameController = TextEditingController();
|
||||||
final _ipController = TextEditingController();
|
final _ipController = TextEditingController();
|
||||||
final _alterUrlController = TextEditingController();
|
final _altUrlController = TextEditingController();
|
||||||
final _portController = TextEditingController();
|
final _portController = TextEditingController();
|
||||||
final _usernameController = TextEditingController();
|
final _usernameController = TextEditingController();
|
||||||
final _passwordController = TextEditingController();
|
final _passwordController = TextEditingController();
|
||||||
@@ -41,27 +41,21 @@ class _ServerEditPageState extends State<ServerEditPage> with AfterLayoutMixin {
|
|||||||
final _usernameFocus = FocusNode();
|
final _usernameFocus = FocusNode();
|
||||||
|
|
||||||
late FocusScopeNode _focusScope;
|
late FocusScopeNode _focusScope;
|
||||||
late ServerProvider _serverProvider;
|
|
||||||
late S _s;
|
late S _s;
|
||||||
|
|
||||||
final usePublicKey = ValueNotifier(false);
|
final _serverProvider = locator<ServerProvider>();
|
||||||
final autoConnect = ValueNotifier(true);
|
final _keyProvider = locator<PrivateKeyProvider>();
|
||||||
int? _pubKeyIndex;
|
|
||||||
PrivateKeyInfo? _keyInfo;
|
|
||||||
List<String> _tags = [];
|
|
||||||
|
|
||||||
@override
|
final _keyIdx = ValueNotifier<int?>(null);
|
||||||
void initState() {
|
final _autoConnect = ValueNotifier(true);
|
||||||
super.initState();
|
List<String> _tags = <String>[];
|
||||||
_serverProvider = locator<ServerProvider>();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
super.dispose();
|
super.dispose();
|
||||||
_nameController.dispose();
|
_nameController.dispose();
|
||||||
_ipController.dispose();
|
_ipController.dispose();
|
||||||
_alterUrlController.dispose();
|
_altUrlController.dispose();
|
||||||
_portController.dispose();
|
_portController.dispose();
|
||||||
_usernameController.dispose();
|
_usernameController.dispose();
|
||||||
_passwordController.dispose();
|
_passwordController.dispose();
|
||||||
@@ -156,7 +150,7 @@ class _ServerEditPageState extends State<ServerEditPage> with AfterLayoutMixin {
|
|||||||
hint: 'root',
|
hint: 'root',
|
||||||
),
|
),
|
||||||
Input(
|
Input(
|
||||||
controller: _alterUrlController,
|
controller: _altUrlController,
|
||||||
type: TextInputType.text,
|
type: TextInputType.text,
|
||||||
node: _alterUrlFocus,
|
node: _alterUrlFocus,
|
||||||
label: _s.alterUrl,
|
label: _s.alterUrl,
|
||||||
@@ -165,50 +159,29 @@ class _ServerEditPageState extends State<ServerEditPage> with AfterLayoutMixin {
|
|||||||
),
|
),
|
||||||
TagEditor(
|
TagEditor(
|
||||||
tags: _tags,
|
tags: _tags,
|
||||||
onChanged: (p0) => setState(() {
|
onChanged: (p0) {
|
||||||
_tags = p0;
|
setState(() {
|
||||||
}),
|
_tags = p0;
|
||||||
|
});
|
||||||
|
},
|
||||||
s: _s,
|
s: _s,
|
||||||
tagSuggestions: [..._serverProvider.tags],
|
tagSuggestions: [..._serverProvider.tags],
|
||||||
onRenameTag: _serverProvider.renameTag,
|
onRenameTag: _serverProvider.renameTag,
|
||||||
),
|
),
|
||||||
width7,
|
_buildAuth(),
|
||||||
Row(
|
ListTile(
|
||||||
children: [
|
title: Text(_s.autoConnect),
|
||||||
width13,
|
trailing: ValueBuilder(
|
||||||
Text(_s.keyAuth),
|
listenable: _autoConnect,
|
||||||
width13,
|
build: () => Switch(
|
||||||
Switch(
|
value: _autoConnect.value,
|
||||||
value: usePublicKey.value,
|
onChanged: (val) {
|
||||||
onChanged: (val) => setState(() => usePublicKey.value = val),
|
_autoConnect.value = val;
|
||||||
|
},
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
width13,
|
|
||||||
Text(_s.autoConnect),
|
|
||||||
width13,
|
|
||||||
Switch(
|
|
||||||
value: autoConnect.value,
|
|
||||||
onChanged: (val) => setState(() => autoConnect.value = val),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
];
|
];
|
||||||
if (usePublicKey.value) {
|
|
||||||
children.add(_buildKeyAuth());
|
|
||||||
} else {
|
|
||||||
children.add(Input(
|
|
||||||
controller: _passwordController,
|
|
||||||
obscureText: true,
|
|
||||||
type: TextInputType.text,
|
|
||||||
label: _s.pwd,
|
|
||||||
icon: Icons.password,
|
|
||||||
hint: _s.pwd,
|
|
||||||
onSubmitted: (_) => {},
|
|
||||||
));
|
|
||||||
}
|
|
||||||
return SingleChildScrollView(
|
return SingleChildScrollView(
|
||||||
padding: const EdgeInsets.fromLTRB(17, 17, 17, 47),
|
padding: const EdgeInsets.fromLTRB(17, 17, 17, 47),
|
||||||
child: Column(
|
child: Column(
|
||||||
@@ -219,23 +192,58 @@ class _ServerEditPageState extends State<ServerEditPage> with AfterLayoutMixin {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget _buildAuth() {
|
||||||
|
final switch_ = ListTile(
|
||||||
|
title: Text(_s.keyAuth),
|
||||||
|
trailing: ValueBuilder(
|
||||||
|
listenable: _keyIdx,
|
||||||
|
build: () => Switch(
|
||||||
|
value: _keyIdx.value != null,
|
||||||
|
onChanged: (val) {
|
||||||
|
if (val) {
|
||||||
|
_keyIdx.value = -1;
|
||||||
|
} else {
|
||||||
|
_keyIdx.value = null;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
/// Put [switch_] out of [ValueBuilder] to avoid rebuild
|
||||||
|
return ValueBuilder(
|
||||||
|
listenable: _keyIdx,
|
||||||
|
build: () {
|
||||||
|
final children = <Widget>[switch_];
|
||||||
|
if (_keyIdx.value != null) {
|
||||||
|
children.add(_buildKeyAuth());
|
||||||
|
} else {
|
||||||
|
children.add(Input(
|
||||||
|
controller: _passwordController,
|
||||||
|
obscureText: true,
|
||||||
|
type: TextInputType.text,
|
||||||
|
label: _s.pwd,
|
||||||
|
icon: Icons.password,
|
||||||
|
hint: _s.pwd,
|
||||||
|
onSubmitted: (_) => _onSave(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
return Column(children: children);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Widget _buildKeyAuth() {
|
Widget _buildKeyAuth() {
|
||||||
return Consumer<PrivateKeyProvider>(
|
return Consumer<PrivateKeyProvider>(
|
||||||
builder: (_, key, __) {
|
builder: (_, key, __) {
|
||||||
for (var item in key.pkis) {
|
final tiles = List<Widget>.generate(key.pkis.length, (index) {
|
||||||
if (item.id == widget.spi?.pubKeyId) {
|
final e = key.pkis[index];
|
||||||
_pubKeyIndex ??= key.pkis.indexOf(item);
|
return ListTile(
|
||||||
}
|
contentPadding: EdgeInsets.zero,
|
||||||
}
|
title: Text(e.id, textAlign: TextAlign.start),
|
||||||
final tiles = key.pkis
|
trailing: _buildRadio(index, e),
|
||||||
.map(
|
);
|
||||||
(e) => ListTile(
|
});
|
||||||
contentPadding: EdgeInsets.zero,
|
|
||||||
title: Text(e.id, textAlign: TextAlign.start),
|
|
||||||
trailing: _buildRadio(key.pkis.indexOf(e), e),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.toList();
|
|
||||||
tiles.add(
|
tiles.add(
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text(_s.addPrivateKey),
|
title: Text(_s.addPrivateKey),
|
||||||
@@ -248,10 +256,11 @@ class _ServerEditPageState extends State<ServerEditPage> with AfterLayoutMixin {
|
|||||||
);
|
);
|
||||||
return RoundRectCard(
|
return RoundRectCard(
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 17),
|
padding: const EdgeInsets.symmetric(horizontal: 17),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: tiles,
|
children: tiles,
|
||||||
)),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -260,82 +269,21 @@ class _ServerEditPageState extends State<ServerEditPage> with AfterLayoutMixin {
|
|||||||
Widget _buildFAB() {
|
Widget _buildFAB() {
|
||||||
return FloatingActionButton(
|
return FloatingActionButton(
|
||||||
heroTag: 'server',
|
heroTag: 'server',
|
||||||
|
onPressed: _onSave,
|
||||||
child: const Icon(Icons.save),
|
child: const Icon(Icons.save),
|
||||||
onPressed: () async {
|
|
||||||
if (_ipController.text == '') {
|
|
||||||
showSnackBar(context, Text(_s.plzEnterHost));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!usePublicKey.value && _passwordController.text == '') {
|
|
||||||
final cancel = await showRoundDialog<bool>(
|
|
||||||
context: context,
|
|
||||||
title: Text(_s.attention),
|
|
||||||
child: Text(_s.sureNoPwd),
|
|
||||||
actions: [
|
|
||||||
TextButton(
|
|
||||||
onPressed: () => context.pop(false),
|
|
||||||
child: Text(_s.ok),
|
|
||||||
),
|
|
||||||
TextButton(
|
|
||||||
onPressed: () => context.pop(true),
|
|
||||||
child: Text(_s.cancel),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
|
||||||
if (cancel ?? true) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (usePublicKey.value && _pubKeyIndex == -1) {
|
|
||||||
showSnackBar(context, Text(_s.plzSelectKey));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (_usernameController.text.isEmpty) {
|
|
||||||
_usernameController.text = 'root';
|
|
||||||
}
|
|
||||||
if (_portController.text.isEmpty) {
|
|
||||||
_portController.text = '22';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (widget.spi != null && widget.spi!.pubKeyId != null) {
|
|
||||||
_keyInfo ??= locator<PrivateKeyStore>().get(widget.spi!.pubKeyId!);
|
|
||||||
}
|
|
||||||
|
|
||||||
final authorization = _passwordController.text;
|
|
||||||
final spi = ServerPrivateInfo(
|
|
||||||
name: _nameController.text,
|
|
||||||
ip: _ipController.text,
|
|
||||||
port: int.parse(_portController.text),
|
|
||||||
user: _usernameController.text,
|
|
||||||
pwd: authorization,
|
|
||||||
pubKeyId: usePublicKey.value ? _keyInfo!.id : null,
|
|
||||||
tags: _tags,
|
|
||||||
alterUrl:
|
|
||||||
_alterUrlController.text == '' ? null : _alterUrlController.text,
|
|
||||||
autoConnect: autoConnect.value,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (widget.spi == null) {
|
|
||||||
_serverProvider.addServer(spi);
|
|
||||||
} else {
|
|
||||||
_serverProvider.updateServer(widget.spi!, spi);
|
|
||||||
}
|
|
||||||
|
|
||||||
context.pop();
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Radio _buildRadio(int index, PrivateKeyInfo pki) {
|
Widget _buildRadio(int index, PrivateKeyInfo pki) {
|
||||||
return Radio<int>(
|
return ValueBuilder(
|
||||||
value: index,
|
listenable: _keyIdx,
|
||||||
groupValue: _pubKeyIndex,
|
build: () => Radio<int>(
|
||||||
onChanged: (int? value) {
|
value: index,
|
||||||
setState(() {
|
groupValue: _keyIdx.value,
|
||||||
_pubKeyIndex = value!;
|
onChanged: (value) {
|
||||||
_keyInfo = pki;
|
_keyIdx.value = value;
|
||||||
});
|
},
|
||||||
},
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -349,14 +297,75 @@ class _ServerEditPageState extends State<ServerEditPage> with AfterLayoutMixin {
|
|||||||
if (widget.spi?.pubKeyId == null) {
|
if (widget.spi?.pubKeyId == null) {
|
||||||
_passwordController.text = widget.spi?.pwd ?? '';
|
_passwordController.text = widget.spi?.pwd ?? '';
|
||||||
} else {
|
} else {
|
||||||
usePublicKey.value = true;
|
_keyIdx.value =
|
||||||
|
_keyProvider.pkis.indexWhere((e) => e.id == widget.spi!.pubKeyId);
|
||||||
}
|
}
|
||||||
if (widget.spi?.tags != null) {
|
if (widget.spi?.tags != null) {
|
||||||
_tags = widget.spi!.tags!;
|
_tags = widget.spi!.tags!;
|
||||||
}
|
}
|
||||||
_alterUrlController.text = widget.spi?.alterUrl ?? '';
|
_altUrlController.text = widget.spi?.alterUrl ?? '';
|
||||||
autoConnect.value = widget.spi?.autoConnect ?? true;
|
_autoConnect.value = widget.spi?.autoConnect ?? true;
|
||||||
setState(() {});
|
setState(() {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _onSave() async {
|
||||||
|
if (_ipController.text == '') {
|
||||||
|
showSnackBar(context, Text(_s.plzEnterHost));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (_keyIdx.value == null && _passwordController.text == '') {
|
||||||
|
final cancel = await showRoundDialog<bool>(
|
||||||
|
context: context,
|
||||||
|
title: Text(_s.attention),
|
||||||
|
child: Text(_s.sureNoPwd),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => context.pop(false),
|
||||||
|
child: Text(_s.ok),
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => context.pop(true),
|
||||||
|
child: Text(_s.cancel),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
if (cancel ?? true) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// If [_pubKeyIndex] is -1, it means that the user has not selected
|
||||||
|
if (_keyIdx.value == -1) {
|
||||||
|
showSnackBar(context, Text(_s.plzSelectKey));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (_usernameController.text.isEmpty) {
|
||||||
|
_usernameController.text = 'root';
|
||||||
|
}
|
||||||
|
if (_portController.text.isEmpty) {
|
||||||
|
_portController.text = '22';
|
||||||
|
}
|
||||||
|
|
||||||
|
final spi = ServerPrivateInfo(
|
||||||
|
name: _nameController.text,
|
||||||
|
ip: _ipController.text,
|
||||||
|
port: int.parse(_portController.text),
|
||||||
|
user: _usernameController.text,
|
||||||
|
pwd: _passwordController.text.isEmpty ? null : _passwordController.text,
|
||||||
|
pubKeyId: _keyIdx.value != null
|
||||||
|
? _keyProvider.pkis.elementAt(_keyIdx.value!).id
|
||||||
|
: null,
|
||||||
|
tags: _tags,
|
||||||
|
alterUrl: _altUrlController.text.isEmpty ? null : _altUrlController.text,
|
||||||
|
autoConnect: _autoConnect.value,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (widget.spi == null) {
|
||||||
|
_serverProvider.addServer(spi);
|
||||||
|
} else {
|
||||||
|
_serverProvider.updateServer(widget.spi!, spi);
|
||||||
|
}
|
||||||
|
|
||||||
|
context.pop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -474,9 +474,9 @@
|
|||||||
baseConfigurationReference = C1C758C41C4E208965A68933 /* Pods-RunnerTests.debug.xcconfig */;
|
baseConfigurationReference = C1C758C41C4E208965A68933 /* Pods-RunnerTests.debug.xcconfig */;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
BUNDLE_LOADER = "$(TEST_HOST)";
|
BUNDLE_LOADER = "$(TEST_HOST)";
|
||||||
CURRENT_PROJECT_VERSION = 525;
|
CURRENT_PROJECT_VERSION = 526;
|
||||||
GENERATE_INFOPLIST_FILE = YES;
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
MARKETING_VERSION = 1.0.525;
|
MARKETING_VERSION = 1.0.526;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = tech.lolli.serverBox.RunnerTests;
|
PRODUCT_BUNDLE_IDENTIFIER = tech.lolli.serverBox.RunnerTests;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SWIFT_VERSION = 5.0;
|
SWIFT_VERSION = 5.0;
|
||||||
@@ -489,9 +489,9 @@
|
|||||||
baseConfigurationReference = 15AF97DF993E8968098D6EBE /* Pods-RunnerTests.release.xcconfig */;
|
baseConfigurationReference = 15AF97DF993E8968098D6EBE /* Pods-RunnerTests.release.xcconfig */;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
BUNDLE_LOADER = "$(TEST_HOST)";
|
BUNDLE_LOADER = "$(TEST_HOST)";
|
||||||
CURRENT_PROJECT_VERSION = 525;
|
CURRENT_PROJECT_VERSION = 526;
|
||||||
GENERATE_INFOPLIST_FILE = YES;
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
MARKETING_VERSION = 1.0.525;
|
MARKETING_VERSION = 1.0.526;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = tech.lolli.serverBox.RunnerTests;
|
PRODUCT_BUNDLE_IDENTIFIER = tech.lolli.serverBox.RunnerTests;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SWIFT_VERSION = 5.0;
|
SWIFT_VERSION = 5.0;
|
||||||
@@ -504,9 +504,9 @@
|
|||||||
baseConfigurationReference = 7CFA7DE7FABA75685DFB6948 /* Pods-RunnerTests.profile.xcconfig */;
|
baseConfigurationReference = 7CFA7DE7FABA75685DFB6948 /* Pods-RunnerTests.profile.xcconfig */;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
BUNDLE_LOADER = "$(TEST_HOST)";
|
BUNDLE_LOADER = "$(TEST_HOST)";
|
||||||
CURRENT_PROJECT_VERSION = 525;
|
CURRENT_PROJECT_VERSION = 526;
|
||||||
GENERATE_INFOPLIST_FILE = YES;
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
MARKETING_VERSION = 1.0.525;
|
MARKETING_VERSION = 1.0.526;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = tech.lolli.serverBox.RunnerTests;
|
PRODUCT_BUNDLE_IDENTIFIER = tech.lolli.serverBox.RunnerTests;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SWIFT_VERSION = 5.0;
|
SWIFT_VERSION = 5.0;
|
||||||
|
|||||||
Reference in New Issue
Block a user