replace: context.pop

This commit is contained in:
lollipopkit
2023-04-19 20:58:29 +08:00
parent e709262477
commit 9cdfd86f70
17 changed files with 96 additions and 84 deletions

View File

@@ -359,7 +359,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 = 268; CURRENT_PROJECT_VERSION = 269;
DEVELOPMENT_TEAM = BA88US33G6; DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist";
@@ -367,7 +367,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
MARKETING_VERSION = 1.0.268; MARKETING_VERSION = 1.0.269;
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";
@@ -490,7 +490,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 = 268; CURRENT_PROJECT_VERSION = 269;
DEVELOPMENT_TEAM = BA88US33G6; DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist";
@@ -498,7 +498,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
MARKETING_VERSION = 1.0.268; MARKETING_VERSION = 1.0.269;
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";
@@ -515,7 +515,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 = 268; CURRENT_PROJECT_VERSION = 269;
DEVELOPMENT_TEAM = BA88US33G6; DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist";
@@ -523,7 +523,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
MARKETING_VERSION = 1.0.268; MARKETING_VERSION = 1.0.269;
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";

View File

@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
import 'package:r_upgrade/r_upgrade.dart'; import 'package:r_upgrade/r_upgrade.dart';
import 'package:toolbox/core/utils/navigator.dart';
import '../data/provider/app.dart'; import '../data/provider/app.dart';
import '../data/res/build_data.dart'; import '../data/res/build_data.dart';
@@ -85,7 +86,7 @@ Future<void> _doUpdate(String url, BuildContext context, S s) async {
} else { } else {
showRoundDialog(context, s.attention, Text(s.platformNotSupportUpdate), [ showRoundDialog(context, s.attention, Text(s.platformNotSupportUpdate), [
TextButton( TextButton(
onPressed: () => Navigator.of(context).pop(), onPressed: () => context.pop(),
child: Text(s.ok), child: Text(s.ok),
) )
]); ]);

View File

@@ -1,8 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
extension ContextX on BuildContext { extension ContextX on BuildContext {
void pop<T>([T? result]) { void pop<T>([T? result]) {
Navigator.of(this).pop(T); Navigator.of(this).pop(T);
} }
} }

View File

@@ -3,6 +3,7 @@ import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:toolbox/core/utils/navigator.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
import '../../data/model/server/snippet.dart'; import '../../data/model/server/snippet.dart';
@@ -135,7 +136,7 @@ void showSnippetDialog(
), ),
TextButton( TextButton(
onPressed: () { onPressed: () {
Navigator.of(context).pop(); context.pop();
AppRoute(const SnippetEditPage(), 'edit snippet').go(context); AppRoute(const SnippetEditPage(), 'edit snippet').go(context);
}, },
child: Text(s.addOne), child: Text(s.addOne),
@@ -156,7 +157,7 @@ void showSnippetDialog(
[ [
TextButton( TextButton(
onPressed: () async { onPressed: () async {
Navigator.of(context).pop(); context.pop();
onSelected(snippet); onSelected(snippet);
}, },
child: Text(s.ok), child: Text(s.ok),

View File

@@ -2,8 +2,8 @@
class BuildData { class BuildData {
static const String name = "ServerBox"; static const String name = "ServerBox";
static const int build = 268; static const int build = 269;
static const String engine = "3.7.11"; static const String engine = "3.7.11";
static const String buildAt = "2023-04-19 20:26:15.641670"; static const String buildAt = "2023-04-19 20:53:37.738261";
static const int modifications = 4; static const int modifications = 15;
} }

View File

@@ -5,6 +5,7 @@ import 'dart:io';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:toolbox/core/utils/navigator.dart';
import 'package:toolbox/data/res/path.dart'; import 'package:toolbox/data/res/path.dart';
import '../../core/extension/colorx.dart'; import '../../core/extension/colorx.dart';
@@ -145,7 +146,7 @@ class BackupPage extends StatelessWidget {
Text(s.restoreSureWithDate(backup.date)), Text(s.restoreSureWithDate(backup.date)),
[ [
TextButton( TextButton(
onPressed: () => Navigator.of(context).pop(), onPressed: () => context.pop(),
child: Text(s.cancel), child: Text(s.cancel),
), ),
TextButton( TextButton(
@@ -162,6 +163,7 @@ class BackupPage extends StatelessWidget {
for (final k in backup.dockerHosts.keys) { for (final k in backup.dockerHosts.keys) {
_dockerHosts.setDockerHost(k, backup.dockerHosts[k]!); _dockerHosts.setDockerHost(k, backup.dockerHosts[k]!);
} }
context.pop();
showRoundDialog( showRoundDialog(
context, context,
s.attention, s.attention,
@@ -172,7 +174,7 @@ class BackupPage extends StatelessWidget {
child: Text(s.restart), child: Text(s.restart),
), ),
TextButton( TextButton(
onPressed: () => Navigator.of(context).pop(), onPressed: () => context.pop(),
child: Text(s.cancel), child: Text(s.cancel),
), ),
], ],

View File

@@ -1,6 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:toolbox/core/utils/navigator.dart';
import '../../core/utils/ui.dart'; import '../../core/utils/ui.dart';
import '../../data/model/docker/ps.dart'; import '../../data/model/docker/ps.dart';
@@ -50,7 +51,7 @@ class _DockerManagePageState extends State<DockerManagePage> {
final client = locator<ServerProvider>().getServer(widget.spi.id).client; final client = locator<ServerProvider>().getServer(widget.spi.id).client;
if (client == null) { if (client == null) {
showSnackBar(context, Text(_s.noClient)); showSnackBar(context, Text(_s.noClient));
Navigator.of(context).pop(); context.pop();
return; return;
} }
_docker.init(client, widget.spi.user, onPwdRequest, widget.spi.id); _docker.init(client, widget.spi.user, onPwdRequest, widget.spi.id);
@@ -119,12 +120,12 @@ class _DockerManagePageState extends State<DockerManagePage> {
), ),
[ [
TextButton( TextButton(
onPressed: () => Navigator.of(context).pop(), onPressed: () => context.pop(),
child: Text(_s.cancel), child: Text(_s.cancel),
), ),
TextButton( TextButton(
onPressed: () async { onPressed: () async {
Navigator.of(context).pop(); context.pop();
await _showAddCmdPreview( await _showAddCmdPreview(
_buildAddCmd( _buildAddCmd(
imageCtrl.text.trim(), imageCtrl.text.trim(),
@@ -146,12 +147,12 @@ class _DockerManagePageState extends State<DockerManagePage> {
Text(cmd), Text(cmd),
[ [
TextButton( TextButton(
onPressed: () => Navigator.of(context).pop(), onPressed: () => context.pop(),
child: Text(_s.cancel), child: Text(_s.cancel),
), ),
TextButton( TextButton(
onPressed: () async { onPressed: () async {
Navigator.of(context).pop(); context.pop();
final result = await _docker.run(cmd); final result = await _docker.run(cmd);
if (result != null) { if (result != null) {
showSnackBar(context, Text(getErrMsg(result) ?? _s.unknownError)); showSnackBar(context, Text(getErrMsg(result) ?? _s.unknownError));
@@ -187,13 +188,13 @@ class _DockerManagePageState extends State<DockerManagePage> {
if (_textController.text == '') { if (_textController.text == '') {
showRoundDialog(context, _s.attention, Text(_s.fieldMustNotEmpty), [ showRoundDialog(context, _s.attention, Text(_s.fieldMustNotEmpty), [
TextButton( TextButton(
onPressed: () => Navigator.of(context).pop(), onPressed: () => context.pop(),
child: Text(_s.ok), child: Text(_s.ok),
), ),
]); ]);
return; return;
} }
Navigator.of(context).pop(); context.pop();
} }
Future<String> onPwdRequest() async { Future<String> onPwdRequest() async {
@@ -213,8 +214,8 @@ class _DockerManagePageState extends State<DockerManagePage> {
[ [
TextButton( TextButton(
onPressed: () { onPressed: () {
Navigator.of(context).pop(); context.pop();
Navigator.of(context).pop(); context.pop();
}, },
child: Text(_s.cancel), child: Text(_s.cancel),
), ),
@@ -294,12 +295,12 @@ class _DockerManagePageState extends State<DockerManagePage> {
Text(_s.sureDelete(e.repo)), Text(_s.sureDelete(e.repo)),
[ [
TextButton( TextButton(
onPressed: () => Navigator.of(context).pop(), onPressed: () => context.pop(),
child: Text(_s.cancel), child: Text(_s.cancel),
), ),
TextButton( TextButton(
onPressed: () async { onPressed: () async {
Navigator.of(context).pop(); context.pop();
final result = await _docker.run( final result = await _docker.run(
'docker rmi ${e.id} -f', 'docker rmi ${e.id} -f',
); );
@@ -375,12 +376,12 @@ class _DockerManagePageState extends State<DockerManagePage> {
onSubmitted: (value) { onSubmitted: (value) {
locator<DockerStore>().setDockerHost(widget.spi.id, value.trim()); locator<DockerStore>().setDockerHost(widget.spi.id, value.trim());
_docker.refresh(); _docker.refresh();
Navigator.of(context).pop(); context.pop();
}, },
), ),
[ [
TextButton( TextButton(
onPressed: () => Navigator.of(context).pop(), onPressed: () => context.pop(),
child: Text(_s.cancel), child: Text(_s.cancel),
), ),
], ],
@@ -478,7 +479,7 @@ class _DockerManagePageState extends State<DockerManagePage> {
[ [
TextButton( TextButton(
onPressed: () { onPressed: () {
Navigator.of(context).pop(); context.pop();
_docker.delete(dItem.containerId); _docker.delete(dItem.containerId);
}, },
child: Text(_s.ok), child: Text(_s.ok),

View File

@@ -2,6 +2,7 @@ import 'package:after_layout/after_layout.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:get_it/get_it.dart'; import 'package:get_it/get_it.dart';
import 'package:toolbox/core/utils/navigator.dart';
import 'package:toolbox/data/provider/app.dart'; import 'package:toolbox/data/provider/app.dart';
import 'package:toolbox/data/res/misc.dart'; import 'package:toolbox/data/res/misc.dart';
@@ -253,7 +254,7 @@ class _MyHomePageState extends State<MyHomePage>
child: Text(_s.feedback), child: Text(_s.feedback),
), ),
TextButton( TextButton(
onPressed: () => Navigator.of(context).pop(), onPressed: () => context.pop(),
child: Text(_s.close), child: Text(_s.close),
) )
], ],
@@ -297,7 +298,7 @@ class _MyHomePageState extends State<MyHomePage>
child: Text(_s.license), child: Text(_s.license),
), ),
TextButton( TextButton(
onPressed: () => Navigator.of(context).pop(), onPressed: () => context.pop(),
child: Text(_s.close), child: Text(_s.close),
) )
], ],

View File

@@ -1,6 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:toolbox/core/utils/navigator.dart';
import '../../data/model/pkg/upgrade_info.dart'; import '../../data/model/pkg/upgrade_info.dart';
import '../../data/model/server/dist.dart'; import '../../data/model/server/dist.dart';
@@ -51,7 +52,7 @@ class _PkgManagePageState extends State<PkgManagePage>
final si = locator<ServerProvider>().getServer(widget.spi.id); final si = locator<ServerProvider>().getServer(widget.spi.id);
if (si.client == null) { if (si.client == null) {
showSnackBar(context, Text(_s.waitConnection)); showSnackBar(context, Text(_s.waitConnection));
Navigator.of(context).pop(); context.pop();
return; return;
} }
@@ -76,14 +77,14 @@ class _PkgManagePageState extends State<PkgManagePage>
Text(_s.fieldMustNotEmpty), Text(_s.fieldMustNotEmpty),
[ [
TextButton( TextButton(
onPressed: () => Navigator.of(context).pop(), onPressed: () => context.pop(),
child: Text(_s.ok), child: Text(_s.ok),
), ),
], ],
); );
return; return;
} }
Navigator.of(context).pop(); context.pop();
} }
Future<String> onPwdRequest() async { Future<String> onPwdRequest() async {
@@ -103,8 +104,8 @@ class _PkgManagePageState extends State<PkgManagePage>
[ [
TextButton( TextButton(
onPressed: () { onPressed: () {
Navigator.of(context).pop(); context.pop();
Navigator.of(context).pop(); context.pop();
}, },
child: Text(_s.cancel)), child: Text(_s.cancel)),
TextButton( TextButton(

View File

@@ -7,6 +7,7 @@ import 'package:flutter/services.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:toolbox/core/extension/numx.dart'; import 'package:toolbox/core/extension/numx.dart';
import 'package:toolbox/core/utils/misc.dart'; import 'package:toolbox/core/utils/misc.dart';
import 'package:toolbox/core/utils/navigator.dart';
import 'package:toolbox/data/res/misc.dart'; import 'package:toolbox/data/res/misc.dart';
import '../../../core/utils/server.dart'; import '../../../core/utils/server.dart';
@@ -68,7 +69,7 @@ class _PrivateKeyEditPageState extends State<PrivateKeyEditPage>
tooltip: _s.delete, tooltip: _s.delete,
onPressed: () { onPressed: () {
_provider.delInfo(widget.info!); _provider.delInfo(widget.info!);
Navigator.of(context).pop(); context.pop();
}, },
icon: const Icon(Icons.delete)) icon: const Icon(Icons.delete))
: const SizedBox() : const SizedBox()
@@ -176,7 +177,7 @@ class _PrivateKeyEditPageState extends State<PrivateKeyEditPage>
} else { } else {
_provider.addInfo(info); _provider.addInfo(info);
} }
Navigator.of(context).pop(); context.pop();
}, },
child: const Icon(Icons.save), child: const Icon(Icons.save),
), ),

View File

@@ -2,6 +2,7 @@ import 'package:after_layout/after_layout.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:toolbox/core/utils/navigator.dart';
import '../../../core/route.dart'; import '../../../core/route.dart';
import '../../../core/utils/ui.dart'; import '../../../core/utils/ui.dart';
@@ -74,8 +75,8 @@ class _ServerEditPageState extends State<ServerEditPage> with AfterLayoutMixin {
TextButton( TextButton(
onPressed: () { onPressed: () {
_serverProvider.delServer(widget.spi!.id); _serverProvider.delServer(widget.spi!.id);
Navigator.of(context).pop(); context.pop();
Navigator.of(context).pop(); context.pop();
}, },
child: Text( child: Text(
_s.ok, _s.ok,
@@ -83,7 +84,7 @@ class _ServerEditPageState extends State<ServerEditPage> with AfterLayoutMixin {
), ),
), ),
TextButton( TextButton(
onPressed: () => Navigator.of(context).pop(), onPressed: () => context.pop(),
child: Text(_s.cancel), child: Text(_s.cancel),
) )
], ],
@@ -232,11 +233,11 @@ class _ServerEditPageState extends State<ServerEditPage> with AfterLayoutMixin {
Text(_s.sureNoPwd), Text(_s.sureNoPwd),
[ [
TextButton( TextButton(
onPressed: () => Navigator.of(context).pop(false), onPressed: () => context.pop(false),
child: Text(_s.ok), child: Text(_s.ok),
), ),
TextButton( TextButton(
onPressed: () => Navigator.of(context).pop(true), onPressed: () => context.pop(true),
child: Text(_s.cancel), child: Text(_s.cancel),
) )
], ],
@@ -277,7 +278,7 @@ class _ServerEditPageState extends State<ServerEditPage> with AfterLayoutMixin {
_serverProvider.updateServer(widget.spi!, spi); _serverProvider.updateServer(widget.spi!, spi);
} }
Navigator.of(context).pop(); context.pop();
}, },
), ),
); );

View File

@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:get_it/get_it.dart'; import 'package:get_it/get_it.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:toolbox/core/utils/navigator.dart';
import '../../../core/route.dart'; import '../../../core/route.dart';
import '../../../core/utils/ui.dart'; import '../../../core/utils/ui.dart';
@@ -222,7 +223,7 @@ class _ServerPageState extends State<ServerPage>
[ [
TextButton( TextButton(
onPressed: () { onPressed: () {
Navigator.of(context).pop(); context.pop();
AppRoute(SSHPage(spi: spi), 'ssh page').go(context); AppRoute(SSHPage(spi: spi), 'ssh page').go(context);
}, },
child: Text(_s.ok), child: Text(_s.ok),
@@ -272,7 +273,7 @@ class _ServerPageState extends State<ServerPage>
Text(result ?? _s.error, style: textSize13), Text(result ?? _s.error, style: textSize13),
[ [
TextButton( TextButton(
onPressed: () => Navigator.of(context).pop(), onPressed: () => context.pop(),
child: Text(_s.ok), child: Text(_s.ok),
) )
], ],

View File

@@ -2,6 +2,7 @@ import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:toolbox/core/utils/navigator.dart';
import '../../../core/extension/numx.dart'; import '../../../core/extension/numx.dart';
import '../../../core/extension/stringx.dart'; import '../../../core/extension/stringx.dart';
@@ -144,21 +145,21 @@ class _SFTPDownloadedPageState extends State<SFTPDownloadedPage> {
leading: const Icon(Icons.delete), leading: const Icon(Icons.delete),
title: Text(_s.delete), title: Text(_s.delete),
onTap: () { onTap: () {
Navigator.of(context).pop(); context.pop();
showRoundDialog( showRoundDialog(
context, context,
_s.sureDelete(fileName), _s.sureDelete(fileName),
const SizedBox(), const SizedBox(),
[ [
TextButton( TextButton(
onPressed: () => Navigator.of(context).pop(), onPressed: () => context.pop(),
child: Text(_s.cancel), child: Text(_s.cancel),
), ),
TextButton( TextButton(
onPressed: () { onPressed: () {
file.deleteSync(); file.deleteSync();
setState(() {}); setState(() {});
Navigator.of(context).pop(); context.pop();
}, },
child: Text(_s.ok), child: Text(_s.ok),
), ),
@@ -177,7 +178,7 @@ class _SFTPDownloadedPageState extends State<SFTPDownloadedPage> {
), ),
[ [
TextButton( TextButton(
onPressed: (() => Navigator.of(context).pop()), onPressed: (() => context.pop()),
child: Text(_s.close), child: Text(_s.close),
) )
], ],

View File

@@ -3,6 +3,7 @@ import 'dart:typed_data';
import 'package:dartssh2/dartssh2.dart'; import 'package:dartssh2/dartssh2.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:toolbox/core/utils/navigator.dart';
import '../../../core/extension/numx.dart'; import '../../../core/extension/numx.dart';
import '../../../core/extension/stringx.dart'; import '../../../core/extension/stringx.dart';
@@ -114,7 +115,7 @@ class _SFTPPageState extends State<SFTPPage> {
), ),
[ [
TextButton( TextButton(
onPressed: () => Navigator.of(context).pop(), onPressed: () => context.pop(),
child: Text(_s.close), child: Text(_s.close),
) )
], ],
@@ -135,14 +136,13 @@ class _SFTPPageState extends State<SFTPPage> {
labelText: _s.path, labelText: _s.path,
hintText: '/', hintText: '/',
), ),
onSubmitted: (value) => onSubmitted: (value) => context.pop(value),
Navigator.of(context).pop(value),
), ),
], ],
), ),
[ [
TextButton( TextButton(
onPressed: () => Navigator.of(context).pop(), onPressed: () => context.pop(),
child: Text(_s.cancel), child: Text(_s.cancel),
) )
], ],
@@ -280,7 +280,7 @@ class _SFTPPageState extends State<SFTPPage> {
), ),
[ [
TextButton( TextButton(
onPressed: () => Navigator.of(context).pop(), onPressed: () => context.pop(),
child: Text(_s.cancel), child: Text(_s.cancel),
) )
], ],
@@ -294,12 +294,12 @@ class _SFTPPageState extends State<SFTPPage> {
Text('${_s.dl2Local(name.filename)}\n${_s.keepForeground}'), Text('${_s.dl2Local(name.filename)}\n${_s.keepForeground}'),
[ [
TextButton( TextButton(
onPressed: () => Navigator.of(context).pop(), onPressed: () => context.pop(),
child: Text(_s.cancel), child: Text(_s.cancel),
), ),
TextButton( TextButton(
onPressed: () async { onPressed: () async {
Navigator.of(context).pop(); context.pop();
final remotePath = _getRemotePath(name); final remotePath = _getRemotePath(name);
final local = '${(await sftpDir).path}$remotePath'; final local = '${(await sftpDir).path}$remotePath';
final pubKeyId = widget.spi.pubKeyId; final pubKeyId = widget.spi.pubKeyId;
@@ -315,7 +315,7 @@ class _SFTPPageState extends State<SFTPPage> {
: locator<PrivateKeyStore>().get(pubKeyId).privateKey, : locator<PrivateKeyStore>().get(pubKeyId).privateKey,
); );
Navigator.of(context).pop(); context.pop();
}, },
child: Text(_s.download), child: Text(_s.download),
) )
@@ -324,7 +324,7 @@ class _SFTPPageState extends State<SFTPPage> {
} }
void delete(BuildContext context, SftpName file) { void delete(BuildContext context, SftpName file) {
Navigator.of(context).pop(); context.pop();
final isDir = file.attr.isDirectory; final isDir = file.attr.isDirectory;
showRoundDialog( showRoundDialog(
context, context,
@@ -333,12 +333,12 @@ class _SFTPPageState extends State<SFTPPage> {
'${_s.sureDelete(file.filename)}${isDir ? '\n${_s.sureDirEmpty}' : ''}'), '${_s.sureDelete(file.filename)}${isDir ? '\n${_s.sureDirEmpty}' : ''}'),
[ [
TextButton( TextButton(
onPressed: () => Navigator.of(context).pop(), onPressed: () => context.pop(),
child: Text(_s.cancel), child: Text(_s.cancel),
), ),
TextButton( TextButton(
onPressed: () async { onPressed: () async {
Navigator.of(context).pop(); context.pop();
showRoundDialog(context, 'Waiting...', centerSizedLoading, [], showRoundDialog(context, 'Waiting...', centerSizedLoading, [],
barrierDismiss: false); barrierDismiss: false);
final remotePath = _getRemotePath(file); final remotePath = _getRemotePath(file);
@@ -348,16 +348,16 @@ class _SFTPPageState extends State<SFTPPage> {
} else { } else {
await _status.client!.remove(remotePath); await _status.client!.remove(remotePath);
} }
Navigator.of(context).pop(); context.pop();
} catch (e) { } catch (e) {
Navigator.of(context).pop(); context.pop();
showRoundDialog( showRoundDialog(
context, context,
_s.attention, _s.attention,
Text(e.toString()), Text(e.toString()),
[ [
TextButton( TextButton(
onPressed: () => Navigator.of(context).pop(), onPressed: () => context.pop(),
child: Text(_s.ok), child: Text(_s.ok),
) )
], ],
@@ -376,7 +376,7 @@ class _SFTPPageState extends State<SFTPPage> {
} }
void mkdir(BuildContext context) { void mkdir(BuildContext context) {
Navigator.of(context).pop(); context.pop();
final textController = TextEditingController(); final textController = TextEditingController();
showRoundDialog( showRoundDialog(
context, context,
@@ -389,7 +389,7 @@ class _SFTPPageState extends State<SFTPPage> {
), ),
[ [
TextButton( TextButton(
onPressed: () => Navigator.of(context).pop(), onPressed: () => context.pop(),
child: Text(_s.cancel), child: Text(_s.cancel),
), ),
TextButton( TextButton(
@@ -401,7 +401,7 @@ class _SFTPPageState extends State<SFTPPage> {
Text(_s.fieldMustNotEmpty), Text(_s.fieldMustNotEmpty),
[ [
TextButton( TextButton(
onPressed: () => Navigator.of(context).pop(), onPressed: () => context.pop(),
child: Text(_s.ok), child: Text(_s.ok),
), ),
], ],
@@ -410,7 +410,7 @@ class _SFTPPageState extends State<SFTPPage> {
} }
_status.client! _status.client!
.mkdir('${_status.path!.path}/${textController.text}'); .mkdir('${_status.path!.path}/${textController.text}');
Navigator.of(context).pop(); context.pop();
listDir(); listDir();
}, },
child: Text( child: Text(
@@ -423,7 +423,7 @@ class _SFTPPageState extends State<SFTPPage> {
} }
void newFile(BuildContext context) { void newFile(BuildContext context) {
Navigator.of(context).pop(); context.pop();
final textController = TextEditingController(); final textController = TextEditingController();
showRoundDialog( showRoundDialog(
context, context,
@@ -436,7 +436,7 @@ class _SFTPPageState extends State<SFTPPage> {
), ),
[ [
TextButton( TextButton(
onPressed: () => Navigator.of(context).pop(), onPressed: () => context.pop(),
child: Text(_s.cancel), child: Text(_s.cancel),
), ),
TextButton( TextButton(
@@ -448,7 +448,7 @@ class _SFTPPageState extends State<SFTPPage> {
Text(_s.fieldMustNotEmpty), Text(_s.fieldMustNotEmpty),
[ [
TextButton( TextButton(
onPressed: () => Navigator.of(context).pop(), onPressed: () => context.pop(),
child: Text(_s.ok), child: Text(_s.ok),
), ),
], ],
@@ -458,7 +458,7 @@ class _SFTPPageState extends State<SFTPPage> {
(await _status.client! (await _status.client!
.open('${_status.path!.path}/${textController.text}')) .open('${_status.path!.path}/${textController.text}'))
.writeBytes(Uint8List(0)); .writeBytes(Uint8List(0));
Navigator.of(context).pop(); context.pop();
listDir(); listDir();
}, },
child: Text( child: Text(
@@ -471,7 +471,7 @@ class _SFTPPageState extends State<SFTPPage> {
} }
void rename(BuildContext context, SftpName file) { void rename(BuildContext context, SftpName file) {
Navigator.of(context).pop(); context.pop();
final textController = TextEditingController(); final textController = TextEditingController();
showRoundDialog( showRoundDialog(
context, context,
@@ -483,9 +483,7 @@ class _SFTPPageState extends State<SFTPPage> {
), ),
), ),
[ [
TextButton( TextButton(onPressed: () => context.pop(), child: Text(_s.cancel)),
onPressed: () => Navigator.of(context).pop(),
child: Text(_s.cancel)),
TextButton( TextButton(
onPressed: () async { onPressed: () async {
if (textController.text == '') { if (textController.text == '') {
@@ -495,7 +493,7 @@ class _SFTPPageState extends State<SFTPPage> {
Text(_s.fieldMustNotEmpty), Text(_s.fieldMustNotEmpty),
[ [
TextButton( TextButton(
onPressed: () => Navigator.of(context).pop(), onPressed: () => context.pop(),
child: Text(_s.ok), child: Text(_s.ok),
), ),
], ],
@@ -503,7 +501,7 @@ class _SFTPPageState extends State<SFTPPage> {
return; return;
} }
await _status.client!.rename(file.filename, textController.text); await _status.client!.rename(file.filename, textController.text);
Navigator.of(context).pop(); context.pop();
listDir(); listDir();
}, },
child: Text( child: Text(
@@ -547,7 +545,7 @@ class _SFTPPageState extends State<SFTPPage> {
Text(e.toString()), Text(e.toString()),
[ [
TextButton( TextButton(
onPressed: () => Navigator.of(context).pop(), onPressed: () => context.pop(),
child: Text(_s.ok), child: Text(_s.ok),
) )
], ],

View File

@@ -1,6 +1,7 @@
import 'package:after_layout/after_layout.dart'; import 'package:after_layout/after_layout.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:toolbox/core/utils/navigator.dart';
import '../../../core/utils/ui.dart'; import '../../../core/utils/ui.dart';
import '../../../data/model/server/snippet.dart'; import '../../../data/model/server/snippet.dart';
@@ -49,7 +50,7 @@ class _SnippetEditPageState extends State<SnippetEditPage>
? IconButton( ? IconButton(
onPressed: () { onPressed: () {
_provider.del(widget.snippet!); _provider.del(widget.snippet!);
Navigator.of(context).pop(); context.pop();
}, },
tooltip: _s.delete, tooltip: _s.delete,
icon: const Icon(Icons.delete)) icon: const Icon(Icons.delete))
@@ -93,7 +94,7 @@ class _SnippetEditPageState extends State<SnippetEditPage>
} else { } else {
_provider.add(snippet); _provider.add(snippet);
} }
Navigator.of(context).pop(); context.pop();
}, },
), ),
); );

View File

@@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:toolbox/core/utils/navigator.dart';
import 'package:xterm/xterm.dart' hide TerminalColors; import 'package:xterm/xterm.dart' hide TerminalColors;
import '../../core/utils/platform.dart'; import '../../core/utils/platform.dart';
@@ -119,7 +120,7 @@ class _SSHPageState extends State<SSHPage> {
await session.done; await session.done;
if (mounted) { if (mounted) {
Navigator.of(context).pop(); context.pop();
} }
} }

View File

@@ -196,6 +196,8 @@ void main(List<String> args) async {
final stopwatch = Stopwatch()..start(); final stopwatch = Stopwatch()..start();
await dartFormat(); await dartFormat();
await getGitCommitCount(); await getGitCommitCount();
// always change version to avoid dismatch version between different
// platforms
await changeAppleVersion(); await changeAppleVersion();
await updateBuildData(); await updateBuildData();
if (args.length > 1) { if (args.length > 1) {