opt. for performance

This commit is contained in:
lollipopkit
2023-06-05 17:51:52 +08:00
parent 378baf589a
commit 7b1c1b9a5a
15 changed files with 68 additions and 126 deletions

View File

@@ -360,7 +360,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 = 347; CURRENT_PROJECT_VERSION = 353;
DEVELOPMENT_TEAM = BA88US33G6; DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist";
@@ -368,7 +368,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
MARKETING_VERSION = 1.0.347; MARKETING_VERSION = 1.0.353;
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";
@@ -491,7 +491,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 = 347; CURRENT_PROJECT_VERSION = 353;
DEVELOPMENT_TEAM = BA88US33G6; DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist";
@@ -499,7 +499,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
MARKETING_VERSION = 1.0.347; MARKETING_VERSION = 1.0.353;
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";
@@ -516,7 +516,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 = 347; CURRENT_PROJECT_VERSION = 353;
DEVELOPMENT_TEAM = BA88US33G6; DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist";
@@ -524,7 +524,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
MARKETING_VERSION = 1.0.347; MARKETING_VERSION = 1.0.353;
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

@@ -103,7 +103,7 @@ void setTransparentNavigationBar(BuildContext context) {
String tabTitleName(BuildContext context, AppTab tab) { String tabTitleName(BuildContext context, AppTab tab) {
final s = S.of(context)!; final s = S.of(context)!;
switch (tab) { switch (tab) {
case AppTab.servers: case AppTab.server:
return s.server; return s.server;
case AppTab.snippet: case AppTab.snippet:
return s.convert; return s.convert;

View File

@@ -1 +1,21 @@
enum AppTab { servers, snippet, ping } import 'package:flutter/material.dart';
import 'package:toolbox/view/page/ping.dart';
import 'package:toolbox/view/page/server/tab.dart';
import 'package:toolbox/view/page/snippet/list.dart';
enum AppTab {
server,
snippet,
ping;
Widget get page {
switch (this) {
case server:
return const ServerPage();
case snippet:
return const SnippetListPage();
case ping:
return const PingPage();
}
}
}

View File

@@ -2,8 +2,8 @@
class BuildData { class BuildData {
static const String name = "ServerBox"; static const String name = "ServerBox";
static const int build = 347; static const int build = 353;
static const String engine = "3.10.3"; static const String engine = "3.10.3";
static const String buildAt = "2023-06-04 22:37:44.679072"; static const String buildAt = "2023-06-05 17:15:25.298942";
static const int modifications = 7; static const int modifications = 6;
} }

View File

@@ -2,7 +2,7 @@ const backendUrl = 'https://res.lolli.tech';
const baseUrl = '$backendUrl/serverbox'; const baseUrl = '$backendUrl/serverbox';
const joinQQGroupUrl = 'https://jq.qq.com/?_wv=1027&k=G0hUmPAq'; const joinQQGroupUrl = 'https://jq.qq.com/?_wv=1027&k=G0hUmPAq';
const myGithub = 'https://github.com/lollipopkit'; const myGithub = 'https://github.com/lollipopkit';
const issueUrl = '$myGithub/flutter_server_box/issues'; const appHelpUrl = '$myGithub/flutter_server_box#-help';
// Thanks // Thanks
const thanksMap = { const thanksMap = {

View File

@@ -24,14 +24,6 @@ class SettingStore extends PersistentStore {
StoreProperty<int> get storeVersion => StoreProperty<int> get storeVersion =>
property('storeVersion', defaultValue: 0); property('storeVersion', defaultValue: 0);
// Show logo on server detail page
StoreProperty<bool> get showDistLogo =>
property('showDistLogo', defaultValue: true);
// First time to use SSH term
StoreProperty<bool> get firstTimeUseSshTerm =>
property('firstTimeUseSshTerm', defaultValue: true);
StoreProperty<int> get termColorIdx => StoreProperty<int> get termColorIdx =>
property('termColorIdx', defaultValue: 0); property('termColorIdx', defaultValue: 0);

View File

@@ -419,7 +419,7 @@ class _DockerManagePageState extends State<DockerManagePage> {
return Text(_s.waitConnection); return Text(_s.waitConnection);
case DockerErrType.invalidVersion: case DockerErrType.invalidVersion:
return UrlText( return UrlText(
text: _s.invalidVersionHelp(issueUrl), text: _s.invalidVersionHelp(appHelpUrl),
replace: 'Github', replace: 'Github',
); );
default: default:

View File

@@ -2,11 +2,11 @@ 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/extension/navigator.dart';
import 'package:toolbox/data/model/app/tab.dart'; import 'package:toolbox/data/model/app/tab.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';
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/analysis.dart'; import '../../core/analysis.dart';
import '../../core/route.dart'; import '../../core/route.dart';
@@ -23,12 +23,9 @@ import '../widget/url_text.dart';
import 'backup.dart'; import 'backup.dart';
import 'convert.dart'; import 'convert.dart';
import 'debug.dart'; import 'debug.dart';
import 'ping.dart';
import 'private_key/list.dart'; import 'private_key/list.dart';
import 'server/tab.dart';
import 'setting.dart'; import 'setting.dart';
import 'sftp/local.dart'; import 'sftp/local.dart';
import 'snippet/list.dart';
class HomePage extends StatefulWidget { class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key); const HomePage({Key? key}) : super(key: key);
@@ -47,19 +44,19 @@ class _HomePageState extends State<HomePage>
late final PageController _pageController; late final PageController _pageController;
late int _selectIndex; final _selectIndex = ValueNotifier(0);
late S _s; late S _s;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
WidgetsBinding.instance.addObserver(this); WidgetsBinding.instance.addObserver(this);
_selectIndex = _setting.launchPage.fetch()!; _selectIndex.value = _setting.launchPage.fetch()!;
// avoid index out of range // avoid index out of range
if (_selectIndex >= AppTab.values.length || _selectIndex < 0) { if (_selectIndex.value >= AppTab.values.length || _selectIndex.value < 0) {
_selectIndex = 0; _selectIndex.value = 0;
} }
_pageController = PageController(initialPage: _selectIndex); _pageController = PageController(initialPage: _selectIndex.value);
} }
@override @override
@@ -120,34 +117,27 @@ class _HomePageState extends State<HomePage>
), ),
], ],
), ),
body: PageView( body: PageView.builder(
physics: const ClampingScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
controller: _pageController, controller: _pageController,
onPageChanged: (index) { itemBuilder: (_, index) => AppTab.values[index].page,
setState(() {
_selectIndex = index;
FocusScope.of(context).requestFocus(FocusNode());
});
},
children: const [ServerPage(), SnippetListPage(), PingPage()],
), ),
bottomNavigationBar: _buildBottomBar(context), bottomNavigationBar:
ValueBuilder(listenable: _selectIndex, build: _buildBottomBar),
); );
} }
Widget _buildBottomBar(BuildContext context) { Widget _buildBottomBar() {
return NavigationBar( return NavigationBar(
selectedIndex: _selectIndex, selectedIndex: _selectIndex.value,
animationDuration: const Duration(milliseconds: 250), animationDuration: const Duration(milliseconds: 250),
onDestinationSelected: (int index) { onDestinationSelected: (int index) {
setState(() { _selectIndex.value = index;
_selectIndex = index; _pageController.animateToPage(
_pageController.animateToPage( index,
index, duration: const Duration(milliseconds: 677),
duration: const Duration(milliseconds: 677), curve: Curves.fastLinearToSlowEaseIn,
curve: Curves.fastLinearToSlowEaseIn, );
);
});
}, },
labelBehavior: NavigationDestinationLabelBehavior.onlyShowSelected, labelBehavior: NavigationDestinationLabelBehavior.onlyShowSelected,
destinations: [ destinations: [
@@ -189,9 +179,7 @@ class _HomePageState extends State<HomePage>
style: textSize13, style: textSize13,
), ),
), ),
SizedBox( const SizedBox(height: 37),
height: MediaQuery.of(context).size.height * 0.07,
),
Padding( Padding(
padding: const EdgeInsets.symmetric(horizontal: 17), padding: const EdgeInsets.symmetric(horizontal: 17),
child: Column( child: Column(
@@ -264,17 +252,13 @@ class _HomePageState extends State<HomePage>
), ),
actions: [ actions: [
TextButton( TextButton(
onPressed: () => openUrl(issueUrl), onPressed: () => openUrl(appHelpUrl),
child: Text(_s.feedback), child: Text(_s.feedback),
), ),
TextButton( TextButton(
onPressed: () => showLicensePage(context: context), onPressed: () => showLicensePage(context: context),
child: Text(_s.license), child: Text(_s.license),
), ),
TextButton(
onPressed: () => context.pop(),
child: Text(_s.close),
)
], ],
); );
}, },
@@ -288,20 +272,9 @@ class _HomePageState extends State<HomePage>
} }
Widget _buildIcon() { Widget _buildIcon() {
return Stack( return ConstrainedBox(
alignment: Alignment.center, constraints: const BoxConstraints(maxHeight: 57, maxWidth: 57),
children: [ child: appIcon,
ConstrainedBox(
constraints: const BoxConstraints(maxHeight: 53, maxWidth: 53),
child: Container(
color: Colors.white,
),
),
ConstrainedBox(
constraints: const BoxConstraints(maxHeight: 83, maxWidth: 83),
child: appIcon,
)
],
); );
} }

View File

@@ -82,10 +82,10 @@ class _PingPageState extends State<PingPage>
); );
} }
void _doPing() { Future<void> _doPing() async {
context.pop(); context.pop();
try { try {
doPing(); await doPing();
} catch (e) { } catch (e) {
showRoundDialog( showRoundDialog(
context: context, context: context,

View File

@@ -97,12 +97,7 @@ class _PrivateKeyEditPageState extends State<PrivateKeyEditPage>
} }
FocusScope.of(context).unfocus(); FocusScope.of(context).unfocus();
setState(() { setState(() {
_loading = const SizedBox( _loading = centerSizedLoading;
height: 50,
child: Center(
child: CircularProgressIndicator(),
),
);
}); });
final info = PrivateKeyInfo(name, key, ''); final info = PrivateKeyInfo(name, key, '');
try { try {

View File

@@ -14,7 +14,7 @@ import '../../../data/provider/server.dart';
import '../../../data/res/ui.dart'; import '../../../data/res/ui.dart';
import '../../../data/store/private_key.dart'; import '../../../data/store/private_key.dart';
import '../../../locator.dart'; import '../../../locator.dart';
import '../../widget/tag.dart'; import '../../widget/tag_editor.dart';
import '../private_key/edit.dart'; import '../private_key/edit.dart';
class ServerEditPage extends StatefulWidget { class ServerEditPage extends StatefulWidget {

View File

@@ -17,12 +17,10 @@ import '../../../data/provider/server.dart';
import '../../../data/res/color.dart'; import '../../../data/res/color.dart';
import '../../../data/model/app/menu.dart'; import '../../../data/model/app/menu.dart';
import '../../../data/res/ui.dart'; import '../../../data/res/ui.dart';
import '../../../data/res/url.dart';
import '../../../data/store/setting.dart'; import '../../../data/store/setting.dart';
import '../../../locator.dart'; import '../../../locator.dart';
import '../../widget/popup_menu.dart'; import '../../widget/popup_menu.dart';
import '../../widget/round_rect_card.dart'; import '../../widget/round_rect_card.dart';
import '../../widget/url_text.dart';
import '../docker.dart'; import '../docker.dart';
import '../pkg.dart'; import '../pkg.dart';
import '../sftp/remote.dart'; import '../sftp/remote.dart';
@@ -303,29 +301,7 @@ class _ServerPageState extends State<ServerPage>
Icons.terminal, Icons.terminal,
size: 21, size: 21,
), ),
onTap: () async { onTap: () => AppRoute(SSHPage(spi: spi), 'ssh page').go(context),
if (_settingStore.firstTimeUseSshTerm.fetch()!) {
await showRoundDialog(
context: context,
child: UrlText(
text: _s.sshTip(issueUrl),
replace: 'Github Issue',
),
actions: [
TextButton(
onPressed: () {
_settingStore.firstTimeUseSshTerm.put(false);
context.pop();
AppRoute(SSHPage(spi: spi), 'ssh page').go(context);
},
child: Text(_s.ok),
)
],
);
} else {
AppRoute(SSHPage(spi: spi), 'ssh page').go(context);
}
},
); );
} }

View File

@@ -142,7 +142,6 @@ class _SettingPageState extends State<SettingPage> {
Widget _buildServer() { Widget _buildServer() {
return Column( return Column(
children: [ children: [
_buildDistLogoSwitch(),
_buildUpdateInterval(), _buildUpdateInterval(),
_buildMaxRetry(), _buildMaxRetry(),
_buildDiskIgnorePath(), _buildDiskIgnorePath(),
@@ -168,19 +167,6 @@ class _SettingPageState extends State<SettingPage> {
); );
} }
Widget _buildDistLogoSwitch() {
return ListTile(
title: Text(
_s.showDistLogo,
),
subtitle: Text(
_s.onServerDetailPage,
style: grey,
),
trailing: buildSwitch(context, _setting.showDistLogo),
);
}
Widget _buildCheckUpdate() { Widget _buildCheckUpdate() {
return Consumer<AppProvider>( return Consumer<AppProvider>(
builder: (_, app, __) { builder: (_, app, __) {

View File

@@ -475,9 +475,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 = 347; CURRENT_PROJECT_VERSION = 353;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0.347; MARKETING_VERSION = 1.0.353;
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;
@@ -490,9 +490,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 = 347; CURRENT_PROJECT_VERSION = 353;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0.347; MARKETING_VERSION = 1.0.353;
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;
@@ -505,9 +505,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 = 347; CURRENT_PROJECT_VERSION = 353;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0.347; MARKETING_VERSION = 1.0.353;
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;