feat: intro page (#416)

Fixes #415
This commit is contained in:
lollipopkit🏳️‍⚧️
2024-06-24 00:43:52 +08:00
committed by GitHub
parent d6e37b058f
commit ddaf916170
18 changed files with 163 additions and 8 deletions

View File

@@ -3,10 +3,14 @@ import 'package:fl_lib/fl_lib.dart';
import 'package:fl_lib/l10n/gen_l10n/lib_l10n.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:server_box/core/extension/context/locale.dart';
import 'package:server_box/data/res/build_data.dart';
import 'package:server_box/data/res/rebuild.dart';
import 'package:server_box/data/res/store.dart';
import 'package:server_box/view/page/home/home.dart';
import 'package:icons_plus/icons_plus.dart';
part 'intro.dart';
class MyApp extends StatelessWidget {
const MyApp({super.key});
@@ -82,7 +86,30 @@ class MyApp extends StatelessWidget {
Widget _buildAppContent(BuildContext ctx) {
//if (Pros.app.isWearOS) return const WearHome();
return const HomePage();
return const _AppContent(
intro: _IntroPage(),
child: HomePage(),
);
}
}
/// It's used for init settings related to [BuildContext]
final class _AppContent extends StatelessWidget {
final Widget child;
final Widget intro;
const _AppContent({required this.child, required this.intro});
@override
Widget build(BuildContext context) {
context.setLibL10n();
final appL10n = AppLocalizations.of(context);
if (appL10n != null) l10n = appL10n;
final showIntro = Stores.setting.showIntro.fetch();
if (showIntro) return intro;
return child;
}
}

View File

@@ -83,6 +83,7 @@ abstract final class GithubIds {
'geol',
'Mooling0602',
'IllTamer',
'marlkiller',
};
}

View File

@@ -280,6 +280,8 @@ class SettingStore extends PersistentStore {
/// Format: {width}x{height}
late final windowSize = property('windowSize', '');
late final showIntro = property('showIntro', true);
// Never show these settings for users
//
// ------BEGIN------

107
lib/intro.dart Normal file
View File

@@ -0,0 +1,107 @@
part of 'app.dart';
final class _IntroPage extends StatelessWidget {
const _IntroPage();
static final _setting = Stores.setting;
static const _kIconSize = 23.0;
static const _introListPad = EdgeInsets.symmetric(horizontal: 17);
@override
Widget build(BuildContext context) {
return LayoutBuilder(
builder: (context, cons) {
final padTop = cons.maxHeight * .2;
return IntroPage(
pages: [
_buildAppSettings(context, padTop),
_buildRecommended(context, padTop),
],
onDone: (ctx) {
//Stores.setting.showIntro.put(false);
Navigator.of(ctx).pushReplacement(
MaterialPageRoute(builder: (_) => const HomePage()),
);
},
);
},
);
}
Widget _buildRecommended(BuildContext context, double padTop) {
return ListView(
padding: _introListPad,
children: [
SizedBox(height: padTop),
const Icon(Bootstrap.stars, size: 35),
SizedBox(height: padTop),
ListTile(
leading: const Icon(MingCute.delete_2_fill),
title: const Text('rm -r'),
subtitle: Text(l10n.sftpRmrDirSummary, style: UIs.textGrey),
trailing: StoreSwitch(prop: _setting.sftpRmrDir),
).cardx,
ListTile(
leading: const Icon(IonIcons.stats_chart, size: _kIconSize),
title: Text(l10n.parseContainerStats),
subtitle: Text(l10n.parseContainerStatsTip, style: UIs.textGrey),
trailing: StoreSwitch(prop: _setting.containerParseStat),
).cardx,
ListTile(
leading: const Icon(OctIcons.cpu),
title: Text('CPU ${l10n.noLineChart}'),
subtitle: Text(l10n.cpuViewAsProgressTip, style: UIs.textGrey),
trailing: StoreSwitch(prop: _setting.cpuViewAsProgress),
).cardx,
],
);
}
Widget _buildAppSettings(BuildContext ctx, double padTop) {
return ListView(
padding: _introListPad,
children: [
SizedBox(height: padTop),
_buildTitle(l10n.init, big: true),
SizedBox(height: padTop),
ListTile(
leading: const Icon(IonIcons.language),
title: Text(l10n.language),
onTap: () async {
final selected = await ctx.showPickSingleDialog(
title: l10n.language,
items: AppLocalizations.supportedLocales,
name: (p0) => p0.code,
initial: _setting.locale.fetch().toLocale,
);
if (selected != null) {
_setting.locale.put(selected.code);
RNodes.app.build();
}
},
trailing: Text(
l10n.languageName,
style: const TextStyle(fontSize: 15, color: Colors.grey),
),
).cardx,
ListTile(
leading: const Icon(Icons.update),
title: Text(l10n.autoCheckUpdate),
subtitle: Text(l10n.fdroidReleaseTip, style: UIs.textGrey),
trailing: StoreSwitch(prop: _setting.autoCheckAppUpdate),
).cardx,
],
);
}
Widget _buildTitle(String text, {bool big = false}) {
return Center(
child: Text(
text,
style: big
? const TextStyle(fontSize: 41, fontWeight: FontWeight.w500)
: UIs.textGrey,
),
);
}
}

View File

@@ -101,6 +101,7 @@
"export": "Export",
"extraArgs": "Extra args",
"failed": "Failed",
"fdroidReleaseTip": "Wenn Sie diese App von Fdroid heruntergeladen haben, wird empfohlen, diese Option zu deaktivieren.",
"feedback": "Feedback",
"feedbackOnGithub": "Wenn du Fragen hast, stelle diese bitte auf Github.",
"fieldMustNotEmpty": "Die Eingabefelder dürfen nicht leer sein.",
@@ -135,6 +136,7 @@
"imagesList": "Images",
"import": "Importieren",
"inAppUpdate": "Im App aktualisieren? Andernfalls mit einem Browser herunterladen.",
"init": "Initialisieren",
"inner": "Eingebaut",
"inputDomainHere": "Domain eingeben",
"install": "install",

View File

@@ -101,6 +101,7 @@
"export": "Export",
"extraArgs": "Extra args",
"failed": "Failed",
"fdroidReleaseTip": "If you downloaded this app from Fdroid, it is recommended to turn off this option.",
"feedback": "Feedback",
"feedbackOnGithub": "If you have any questions, please feedback on Github.",
"fieldMustNotEmpty": "These fields must not be empty.",
@@ -135,6 +136,7 @@
"imagesList": "Images list",
"import": "Import",
"inAppUpdate": "Update within the app? Otherwise, download using a browser.",
"init": "Initialize",
"inner": "Inner",
"inputDomainHere": "Input Domain here",
"install": "install",

View File

@@ -101,6 +101,7 @@
"export": "Exportar",
"extraArgs": "Argumentos extra",
"failed": "Fallido",
"fdroidReleaseTip": "Si descargaste esta aplicación desde Fdroid, se recomienda desactivar esta opción.",
"feedback": "Retroalimentación",
"feedbackOnGithub": "Si tienes algún problema, por favor informa en GitHub",
"fieldMustNotEmpty": "Estos campos no pueden estar vacíos.",
@@ -135,6 +136,7 @@
"imagesList": "Lista de imágenes",
"import": "Importar",
"inAppUpdate": "¿Actualizar dentro de la app? De lo contrario, descargar usando un navegador.",
"init": "Inicializar",
"inner": "Interno",
"inputDomainHere": "Introduce el dominio aquí",
"install": "Instalar",

View File

@@ -101,6 +101,7 @@
"export": "Exporter",
"extraArgs": "Arguments supplémentaires",
"failed": "Échoué",
"fdroidReleaseTip": "Si vous avez téléchargé cette application depuis Fdroid, il est recommandé de désactiver cette option.",
"feedback": "Retour",
"feedbackOnGithub": "Si vous avez des questions, veuillez donner votre avis sur Github.",
"fieldMustNotEmpty": "Ces champs ne doivent pas être vides.",
@@ -135,6 +136,7 @@
"imagesList": "Liste des images",
"import": "Importer",
"inAppUpdate": "Mettre à jour dans l'application ? Sinon, téléchargez en utilisant un navigateur.",
"init": "Initialiser",
"inner": "Interne",
"inputDomainHere": "Saisissez le domaine ici",
"install": "Installer",

View File

@@ -101,6 +101,7 @@
"export": "Ekspor",
"extraArgs": "Args ekstra",
"failed": "Gagal",
"fdroidReleaseTip": "Jika Anda mengunduh aplikasi ini dari Fdroid, disarankan untuk mematikan opsi ini.",
"feedback": "Masukan",
"feedbackOnGithub": "Jika Anda memiliki pertanyaan, silakan umpan balik tentang GitHub.",
"fieldMustNotEmpty": "Bidang -bidang ini tidak boleh kosong.",
@@ -135,6 +136,7 @@
"imagesList": "Daftar gambar",
"import": "Impor",
"inAppUpdate": "Perbarui di dalam aplikasi? Jika tidak, unduh menggunakan browser.",
"init": "Menginisialisasi",
"inner": "Batin",
"inputDomainHere": "Input domain di sini",
"install": "Install",

View File

@@ -101,6 +101,7 @@
"export": "エクスポート",
"extraArgs": "追加引数",
"failed": "失敗しました",
"fdroidReleaseTip": "このアプリをFdroidからダウンロードした場合、このオプションをオフにすることをお勧めします。",
"feedback": "フィードバック",
"feedbackOnGithub": "問題がある場合は、GitHubでフィードバックしてください",
"fieldMustNotEmpty": "これらの入力フィールドは空にできません。",
@@ -135,6 +136,7 @@
"imagesList": "イメージリスト",
"import": "インポート",
"inAppUpdate": "アプリ内で更新しますか?それ以外の場合は、ブラウザを使用してダウンロードしてください。",
"init": "初期化する",
"inner": "内蔵",
"inputDomainHere": "ここにドメインを入力",
"install": "インストール",

View File

@@ -101,6 +101,7 @@
"export": "Exporteren",
"extraArgs": "Extra argumenten",
"failed": "Mislukt",
"fdroidReleaseTip": "Als u deze app van Fdroid heeft gedownload, wordt aanbevolen deze optie uit te schakelen.",
"feedback": "Feedback",
"feedbackOnGithub": "Als je vragen hebt, geef dan feedback op Github.",
"fieldMustNotEmpty": "Deze velden mogen niet leeg zijn.",
@@ -135,6 +136,7 @@
"imagesList": "Lijst met afbeeldingen",
"import": "Importeren",
"inAppUpdate": "Bijwerken binnen de app? Anders downloaden via een browser.",
"init": "Initialiseren",
"inner": "Intern",
"inputDomainHere": "Voer hier domein in",
"install": "Installeren",

View File

@@ -101,6 +101,7 @@
"export": "Exportar",
"extraArgs": "Argumentos extras",
"failed": "Falhou",
"fdroidReleaseTip": "Se você baixou este aplicativo do Fdroid, é recomendado desativar esta opção.",
"feedback": "Feedback",
"feedbackOnGithub": "Se você tem qualquer problema, por favor, dê feedback no GitHub",
"fieldMustNotEmpty": "Estes campos não podem estar vazios.",
@@ -135,6 +136,7 @@
"imagesList": "Lista de imagens",
"import": "Importar",
"inAppUpdate": "Atualizar dentro do app? Caso contrário, baixe usando um navegador.",
"init": "Inicializar",
"inner": "Interno",
"inputDomainHere": "Insira o domínio aqui",
"install": "Instalar",

View File

@@ -101,6 +101,7 @@
"export": "экспорт",
"extraArgs": "дополнительные аргументы",
"failed": "неудача",
"fdroidReleaseTip": "Если вы скачали это приложение с Fdroid, рекомендуется отключить эту опцию.",
"feedback": "обратная связь",
"feedbackOnGithub": "Если у вас есть какие-либо вопросы, пожалуйста, отправьте отзыв на GitHub",
"fieldMustNotEmpty": "Эти поля не могут быть пустыми.",
@@ -135,6 +136,7 @@
"imagesList": "список образов",
"import": "импорт",
"inAppUpdate": "Обновить в приложении? В противном случае загрузите с помощью браузера.",
"init": "Инициализировать",
"inner": "встроенный",
"inputDomainHere": "введите домен здесь",
"install": "установить",

View File

@@ -101,6 +101,7 @@
"export": "导出",
"extraArgs": "额外参数",
"failed": "失败",
"fdroidReleaseTip": "如果你是从 Fdroid 下载的本应用,推荐关闭此选项",
"feedback": "反馈",
"feedbackOnGithub": "如果你有任何问题请在GitHub反馈",
"fieldMustNotEmpty": "这些输入框不能为空。",
@@ -135,6 +136,7 @@
"imagesList": "镜像列表",
"import": "导入",
"inAppUpdate": "在App内更新否则使用浏览器下载",
"init": "初始化",
"inner": "内置",
"inputDomainHere": "在这里输入域名",
"install": "安装",

View File

@@ -101,6 +101,7 @@
"export": "導出",
"extraArgs": "額外參數",
"failed": "失敗",
"fdroidReleaseTip": "如果你是從 Fdroid 下載的本應用,推薦關閉此選項",
"feedback": "反饋",
"feedbackOnGithub": "如果你有任何問題請在GitHub反饋",
"fieldMustNotEmpty": "這些輸入框不能為空。",
@@ -135,6 +136,7 @@
"imagesList": "鏡像列表",
"import": "導入",
"inAppUpdate": "在App內更新否則使用瀏覽器下載。",
"init": "初始化",
"inner": "內置",
"inputDomainHere": "在這裡輸入域名",
"install": "安裝",

View File

@@ -2,7 +2,6 @@ import 'dart:convert';
import 'package:fl_lib/fl_lib.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:icons_plus/icons_plus.dart';
import 'package:server_box/core/channel/home_widget.dart';
import 'package:server_box/core/extension/build.dart';
@@ -59,9 +58,6 @@ class _HomePageState extends State<HomePage>
@override
void didChangeDependencies() {
super.didChangeDependencies();
context.setLibL10n();
final appL10n = AppLocalizations.of(context);
if (appL10n != null) l10n = appL10n;
_isLandscape.value =
MediaQuery.of(context).orientation == Orientation.landscape;
}

View File

@@ -385,8 +385,8 @@ packages:
dependency: "direct main"
description:
path: "."
ref: "v1.0.48"
resolved-ref: "48e91d023afa5c73970c75b8fc1f5dffa0c809d7"
ref: "v1.0.49"
resolved-ref: "85ae5cfeba1c8a959e0bd83b7e1eff5edc572ab9"
url: "https://github.com/lppcg/fl_lib"
source: git
version: "0.0.1"

View File

@@ -58,7 +58,7 @@ dependencies:
fl_lib:
git:
url: https://github.com/lppcg/fl_lib
ref: v1.0.48
ref: v1.0.49
dependency_overrides:
# dartssh2: