Skip to content

Commit

Permalink
🐛 fix animation && add doctor features
Browse files Browse the repository at this point in the history
  • Loading branch information
H2Sxxa committed Aug 4, 2024
1 parent f921ee5 commit 742e357
Show file tree
Hide file tree
Showing 11 changed files with 133 additions and 40 deletions.
Empty file.
Empty file.
3 changes: 3 additions & 0 deletions assets/i18n/zh_CN/doctor/0x800701bc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
打开WSL后出现 0x800701bc 错误

原因: WSL内核还未升级
3 changes: 3 additions & 0 deletions assets/i18n/zh_CN/doctor/optional_feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
打开WSL后提示开启 HyperV...

原因: 可选功能未开启
2 changes: 1 addition & 1 deletion lib/i18n/i18n.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ extension I18nEx on BuildContext {

Widget i18nMarkdown(String fileName, [bool shrinkWrap = true]) {
return FutureBuilder(
future: ArcheBus.bus.of<I18n>().loadString(fileName),
future: ArcheBus.bus.of<I18n>().loadString("$fileName.md"),
builder: (context, snapshot) {
var data = snapshot.data;
if (data == null) {
Expand Down
8 changes: 7 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ class HomePageState extends State<HomePage> with RefreshMountedStateMixin {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Theme.of(context).colorScheme.surfaceContainer,
body: NavigationView(
builder: (context, vertical, horizontal, state) => Column(
children: [
Expand All @@ -162,7 +163,7 @@ class HomePageState extends State<HomePage> with RefreshMountedStateMixin {
appWindow.startDragging();
},
),
state.content
state.content,
],
),
)
Expand All @@ -171,24 +172,29 @@ class HomePageState extends State<HomePage> with RefreshMountedStateMixin {
backgroundColor: Theme.of(context).colorScheme.surfaceContainer,
items: [
PageContainer(
key: UniqueKey(),
title: context.i18n.getOrKey("home"),
child: const Center(
child: Text("TODO"),
),
).toItem(icon: const Icon(Icons.home)),
PageContainer(
key: UniqueKey(),
title: context.i18n.getOrKey("install"),
child: const InstallPage(),
).toItem(icon: const Icon(Icons.install_desktop)),
PageContainer(
key: UniqueKey(),
title: context.i18n.getOrKey("manage"),
child: const DistributionManagePage(),
).toItem(icon: const Icon(Icons.apps)),
PageContainer(
key: UniqueKey(),
title: context.i18n.getOrKey("doctor"),
child: const DoctorPage(),
).toItem(icon: const Icon(FontAwesomeIcons.userDoctor)),
PageContainer(
key: UniqueKey(),
title: context.i18n.getOrKey("settings"),
child: const SettingsPage(),
).toItem(icon: const Icon(Icons.settings)),
Expand Down
69 changes: 68 additions & 1 deletion lib/views/pages/doctor.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import 'package:flutter/material.dart';
import 'package:wslconfigurer/i18n/i18n.dart';
import 'package:wslconfigurer/views/widgets/basic.dart';
import 'package:wslconfigurer/views/widgets/optional_features.dart';
import 'package:wslconfigurer/views/widgets/update_kernel.dart';

class DoctorPage extends StatefulWidget {
const DoctorPage({super.key});
Expand All @@ -10,6 +14,69 @@ class DoctorPage extends StatefulWidget {
class _DoctorPageState extends State<DoctorPage> {
@override
Widget build(BuildContext context) {
return const Column();
return Navigator(
onGenerateRoute: (settings) {
Widget Function(BuildContext context) builder;
var route = settings.name ?? "/";
if (route == "/optional_features") {
builder = (context) => Scaffold(
backgroundColor: Colors.transparent,
appBar: AppBar(
backgroundColor: Colors.transparent,
),
body: const CheckOptionalFeatureWidget(),
);
} else {
builder = (context) =>
ScrollableContainer(padding: const EdgeInsets.all(8), children: [
const DoctorFetaure(
descriptionKey: "0x800701bc",
solution: UpdateKernel(),
),
DoctorFetaure(
descriptionKey: "optional_feature",
solution: ListTile(
title: context.i18nText("optional_features"),
trailing: FilledButton(
onPressed: () =>
Navigator.of(context).pushNamed("/optional_features"),
child: context.i18nText("open"),
),
),
),
]);
}

return PageRouteBuilder(
pageBuilder: (context, animation, secondaryAnimation) =>
FadeTransition(opacity: animation, child: builder(context)),
);
},
);
}
}

class DoctorFetaure extends StatelessWidget {
final String descriptionKey;
final Widget? solution;
const DoctorFetaure({super.key, required this.descriptionKey, this.solution});

@override
Widget build(BuildContext context) {
return Card.filled(
child: WidthInfCenterWidget(
child: Padding(
padding: const EdgeInsets.all(8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
context.i18nMarkdown("doctor/$descriptionKey"),
const Divider(),
solution ?? const SizedBox.shrink()
],
),
),
),
);
}
}
39 changes: 3 additions & 36 deletions lib/views/pages/install.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@ import 'package:flutter/services.dart';
import 'package:flutter_staggered_animations/flutter_staggered_animations.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:system_info2/system_info2.dart';
import 'package:url_launcher/url_launcher_string.dart';
import 'package:wslconfigurer/i18n/i18n.dart';
import 'package:wslconfigurer/models/config.dart';
import 'package:wslconfigurer/models/distribution.dart';
import 'package:wslconfigurer/views/widgets/basic.dart';
import 'package:wslconfigurer/views/widgets/divider.dart';
import 'package:wslconfigurer/views/widgets/optfeat.dart';
import 'package:wslconfigurer/views/widgets/optional_features.dart';
import 'package:wslconfigurer/views/widgets/process.dart';
import 'package:wslconfigurer/views/widgets/update_kernel.dart';
import 'package:wslconfigurer/windows/ms_open.dart';
import 'package:wslconfigurer/windows/msi.dart';
import 'package:wslconfigurer/windows/utf16.dart';

class InstallPage extends StatefulWidget {
Expand Down Expand Up @@ -108,38 +106,7 @@ class _InstallPageState extends State<InstallPage> {
title: context.i18nText("install.upgrade_wsl2_kernel"),
trailing: Text(SysInfo.rawKernelArchitecture),
),
Card.filled(
child: Column(
children: [
ListTile(
title: context.i18nText("install.manual"),
trailing: IconButton(
onPressed: () => launchUrlString(
AppConfigs.wslLinuxKernelUpdateInstallerUrl),
icon: const Icon(Icons.open_in_browser),
),
),
ListTile(
title: context.i18nText("install.automate"),
trailing: IconButton(
onPressed: () {
ComplexDialog.instance
.withContext(context: context)
.withChild(
DownloadMSIProgressDialog(
AppConfigs.wslLinuxKernelUpdateInstallerUrl,
logPath: "installer.log",
),
)
.copy(barrierDismissible: false)
.prompt();
},
icon: const Icon(Icons.install_desktop),
),
)
],
),
),
const Card.filled(child: UpdateKernel()),
divider8,
ListTile(
leading: const Icon(FontAwesomeIcons.section),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class _CheckOptionalFeatureWidgetState
spacing: 8,
direction: Axis.vertical,
children: [
context.i18nMarkdown("optional_features.md", true),
context.i18nMarkdown("optional_features", true),
FilledButton(
onPressed: () => openMSSetting("optionalfeatures"),
child: context.i18nText("optional_features"),
Expand Down
44 changes: 44 additions & 0 deletions lib/views/widgets/update_kernel.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import 'package:arche/arche.dart';
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher_string.dart';
import 'package:wslconfigurer/i18n/i18n.dart';
import 'package:wslconfigurer/models/config.dart';
import 'package:wslconfigurer/windows/msi.dart';

class UpdateKernel extends StatelessWidget {
const UpdateKernel({super.key});

@override
Widget build(BuildContext context) {
return Column(
children: [
ListTile(
title: context.i18nText("install.manual"),
trailing: IconButton(
onPressed: () =>
launchUrlString(AppConfigs.wslLinuxKernelUpdateInstallerUrl),
icon: const Icon(Icons.open_in_browser),
),
),
ListTile(
title: context.i18nText("install.automate"),
trailing: IconButton(
onPressed: () {
ComplexDialog.instance
.withContext(context: context)
.withChild(
DownloadMSIProgressDialog(
AppConfigs.wslLinuxKernelUpdateInstallerUrl,
logPath: "installer.log",
),
)
.copy(barrierDismissible: false)
.prompt();
},
icon: const Icon(Icons.install_desktop),
),
)
],
);
}
}
3 changes: 3 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ flutter:
assets:
- assets/i18n/
- assets/i18n/en_US/
- assets/i18n/en_US/doctor/
- assets/i18n/zh_CN/
- assets/i18n/zh_CN/doctor/


# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware
Expand Down

0 comments on commit 742e357

Please sign in to comment.