Skip to content

Commit

Permalink
feat: intro page (#416)
Browse files Browse the repository at this point in the history
Fixes #415
  • Loading branch information
lollipopkit authored Jun 23, 2024
1 parent d6e37b0 commit ddaf916
Show file tree
Hide file tree
Showing 18 changed files with 163 additions and 8 deletions.
29 changes: 28 additions & 1 deletion lib/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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});
Expand Down Expand Up @@ -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;
}
}

Expand Down
1 change: 1 addition & 0 deletions lib/data/res/github_id.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ abstract final class GithubIds {
'geol',
'Mooling0602',
'IllTamer',
'marlkiller',
};
}

Expand Down
2 changes: 2 additions & 0 deletions lib/data/store/setting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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------
Expand Down
107 changes: 107 additions & 0 deletions lib/intro.dart
Original file line number Diff line number Diff line change
@@ -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,
),
);
}
}
2 changes: 2 additions & 0 deletions lib/l10n/app_de.arb
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions lib/l10n/app_es.arb
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions lib/l10n/app_fr.arb
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions lib/l10n/app_id.arb
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions lib/l10n/app_ja.arb
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
"export": "エクスポート",
"extraArgs": "追加引数",
"failed": "失敗しました",
"fdroidReleaseTip": "このアプリをFdroidからダウンロードした場合、このオプションをオフにすることをお勧めします。",
"feedback": "フィードバック",
"feedbackOnGithub": "問題がある場合は、GitHubでフィードバックしてください",
"fieldMustNotEmpty": "これらの入力フィールドは空にできません。",
Expand Down Expand Up @@ -135,6 +136,7 @@
"imagesList": "イメージリスト",
"import": "インポート",
"inAppUpdate": "アプリ内で更新しますか?それ以外の場合は、ブラウザを使用してダウンロードしてください。",
"init": "初期化する",
"inner": "内蔵",
"inputDomainHere": "ここにドメインを入力",
"install": "インストール",
Expand Down
2 changes: 2 additions & 0 deletions lib/l10n/app_nl.arb
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions lib/l10n/app_pt.arb
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions lib/l10n/app_ru.arb
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
"export": "экспорт",
"extraArgs": "дополнительные аргументы",
"failed": "неудача",
"fdroidReleaseTip": "Если вы скачали это приложение с Fdroid, рекомендуется отключить эту опцию.",
"feedback": "обратная связь",
"feedbackOnGithub": "Если у вас есть какие-либо вопросы, пожалуйста, отправьте отзыв на GitHub",
"fieldMustNotEmpty": "Эти поля не могут быть пустыми.",
Expand Down Expand Up @@ -135,6 +136,7 @@
"imagesList": "список образов",
"import": "импорт",
"inAppUpdate": "Обновить в приложении? В противном случае загрузите с помощью браузера.",
"init": "Инициализировать",
"inner": "встроенный",
"inputDomainHere": "введите домен здесь",
"install": "установить",
Expand Down
2 changes: 2 additions & 0 deletions lib/l10n/app_zh.arb
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
"export": "导出",
"extraArgs": "额外参数",
"failed": "失败",
"fdroidReleaseTip": "如果你是从 Fdroid 下载的本应用,推荐关闭此选项",
"feedback": "反馈",
"feedbackOnGithub": "如果你有任何问题,请在GitHub反馈",
"fieldMustNotEmpty": "这些输入框不能为空。",
Expand Down Expand Up @@ -135,6 +136,7 @@
"imagesList": "镜像列表",
"import": "导入",
"inAppUpdate": "在App内更新?否则使用浏览器下载",
"init": "初始化",
"inner": "内置",
"inputDomainHere": "在这里输入域名",
"install": "安装",
Expand Down
2 changes: 2 additions & 0 deletions lib/l10n/app_zh_tw.arb
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
"export": "導出",
"extraArgs": "額外參數",
"failed": "失敗",
"fdroidReleaseTip": "如果你是從 Fdroid 下載的本應用,推薦關閉此選項",
"feedback": "反饋",
"feedbackOnGithub": "如果你有任何問題,請在GitHub反饋",
"fieldMustNotEmpty": "這些輸入框不能為空。",
Expand Down Expand Up @@ -135,6 +136,7 @@
"imagesList": "鏡像列表",
"import": "導入",
"inAppUpdate": "在App內更新?否則使用瀏覽器下載。",
"init": "初始化",
"inner": "內置",
"inputDomainHere": "在這裡輸入域名",
"install": "安裝",
Expand Down
4 changes: 0 additions & 4 deletions lib/view/page/home/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit ddaf916

Please sign in to comment.