extract out about dialog
This commit is contained in:
parent
4472062740
commit
6e9283c86b
2 changed files with 95 additions and 107 deletions
83
lib/helpers/extensions/show_about_dialog.dart
Normal file
83
lib/helpers/extensions/show_about_dialog.dart
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
import "package:flutter/material.dart";
|
||||
import "package:flutter_svg/flutter_svg.dart";
|
||||
import "package:hooks_riverpod/hooks_riverpod.dart";
|
||||
import "package:m3e_card_list/m3e_card_list.dart";
|
||||
import "package:nexus/helpers/launch_helper.dart";
|
||||
import "package:package_info_plus/package_info_plus.dart";
|
||||
|
||||
extension ShowContextMenu on BuildContext {
|
||||
Future<void> showAboutDialog(WidgetRef ref) async {
|
||||
final packageInfo = await PackageInfo.fromPlatform();
|
||||
|
||||
if (mounted) {
|
||||
showDialog(
|
||||
context: this,
|
||||
builder: (context) => AlertDialog(
|
||||
content: Column(
|
||||
mainAxisSize: .min,
|
||||
spacing: 16,
|
||||
children: [
|
||||
Row(
|
||||
spacing: 12,
|
||||
children: [
|
||||
SvgPicture.asset("assets/icon.svg", width: 64),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: .start,
|
||||
children: [
|
||||
Wrap(
|
||||
crossAxisAlignment: .center,
|
||||
spacing: 4,
|
||||
children: [
|
||||
Text(
|
||||
"Nexus",
|
||||
style: Theme.of(context).textTheme.headlineMedium,
|
||||
),
|
||||
Text("(${packageInfo.version})"),
|
||||
],
|
||||
),
|
||||
|
||||
Text(
|
||||
"A simple and user-friendly Matrix client",
|
||||
overflow: .ellipsis,
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
M3ECardColumn(
|
||||
onTap: (index) =>
|
||||
ref.watch(LaunchHelper.provider).launchUrl(switch (index) {
|
||||
0 => Uri.https("git.federated.nexus", "nexus/nexus"),
|
||||
_ => Uri.https("liberapay.com", "QuadRadical"),
|
||||
}),
|
||||
children: [
|
||||
ListTile(
|
||||
leading: Icon(Icons.commit),
|
||||
title: Text("Source Code"),
|
||||
),
|
||||
ListTile(
|
||||
leading: Icon(Icons.favorite, color: Colors.pinkAccent),
|
||||
title: Text("Donate"),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => showLicensePage(context: context),
|
||||
child: Text("View licenses"),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: Navigator.of(context).pop,
|
||||
child: Text("Close"),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,23 +1,20 @@
|
|||
import "dart:io";
|
||||
|
||||
import "package:collection/collection.dart";
|
||||
import "package:fast_immutable_collections/fast_immutable_collections.dart";
|
||||
import "package:flutter/material.dart";
|
||||
import "package:flutter_hooks/flutter_hooks.dart";
|
||||
import "package:flutter_svg/flutter_svg.dart";
|
||||
import "package:hooks_riverpod/hooks_riverpod.dart";
|
||||
import "package:intl/intl.dart";
|
||||
import "package:m3e_card_list/m3e_card_list.dart";
|
||||
import "package:navigation_rail_m3e/navigation_rail_m3e.dart";
|
||||
import "package:nexus/controllers/settings_controller.dart";
|
||||
import "package:nexus/helpers/extensions/better_when.dart";
|
||||
import "package:nexus/helpers/launch_helper.dart";
|
||||
import "package:nexus/helpers/extensions/show_about_dialog.dart";
|
||||
import "package:nexus/models/setting.dart";
|
||||
import "package:nexus/models/settings.dart";
|
||||
import "package:nexus/models/settings_category.dart";
|
||||
import "package:nexus/widgets/divider_text.dart";
|
||||
import "package:nexus/widgets/settings/dialog_list_tile.dart";
|
||||
import "package:package_info_plus/package_info_plus.dart";
|
||||
import "package:super_sliver_list/super_sliver_list.dart";
|
||||
import "package:nexus/main.dart";
|
||||
|
||||
|
|
@ -143,6 +140,16 @@ class SettingsPage extends ConsumerWidget {
|
|||
|
||||
return matches.map(
|
||||
(match) => ListTile(
|
||||
onTap: () {
|
||||
// TODO: Do something
|
||||
// if (categoriesArePages) {
|
||||
// // Navigator.of(context).push(route);
|
||||
// } else {
|
||||
// selected.value = match.$1.$1;
|
||||
// }
|
||||
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
leading: Icon(match.$2.icon),
|
||||
title: Text(match.$2.title),
|
||||
subtitle: Text(match.$2.description),
|
||||
|
|
@ -157,109 +164,7 @@ class SettingsPage extends ConsumerWidget {
|
|||
actionsPadding: .symmetric(horizontal: 12),
|
||||
actions: [
|
||||
IconButton(
|
||||
onPressed: () async {
|
||||
final packageInfo = await PackageInfo.fromPlatform();
|
||||
|
||||
if (context.mounted) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
content: Column(
|
||||
mainAxisSize: .min,
|
||||
spacing: 16,
|
||||
children: [
|
||||
Row(
|
||||
spacing: 12,
|
||||
children: [
|
||||
SvgPicture.asset("assets/icon.svg", width: 64),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: .start,
|
||||
children: [
|
||||
Wrap(
|
||||
crossAxisAlignment: .center,
|
||||
spacing: 4,
|
||||
children: [
|
||||
Text(
|
||||
"Nexus",
|
||||
style: Theme.of(
|
||||
context,
|
||||
).textTheme.headlineMedium,
|
||||
),
|
||||
Text("(${packageInfo.version})"),
|
||||
],
|
||||
),
|
||||
|
||||
Text(
|
||||
"A simple and user-friendly Matrix client",
|
||||
overflow: .ellipsis,
|
||||
style: Theme.of(
|
||||
context,
|
||||
).textTheme.titleMedium,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
M3ECardColumn(
|
||||
onTap: (index) => ref
|
||||
.watch(LaunchHelper.provider)
|
||||
.launchUrl(switch (index) {
|
||||
0 => Uri.https(
|
||||
"git.federated.nexus",
|
||||
"nexus/nexus",
|
||||
),
|
||||
_ => Uri.https(
|
||||
"liberapay.com",
|
||||
"QuadRadical",
|
||||
),
|
||||
}),
|
||||
children: [
|
||||
ListTile(
|
||||
leading: Icon(Icons.commit),
|
||||
title: Text("Source Code"),
|
||||
),
|
||||
ListTile(
|
||||
leading: Icon(
|
||||
Icons.favorite,
|
||||
color: Colors.pinkAccent,
|
||||
),
|
||||
title: Text("Donate"),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => showLicensePage(context: context),
|
||||
child: Text("View licenses"),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: Navigator.of(context).pop,
|
||||
child: Text("Close"),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
// showAboutDialog(
|
||||
// context: context,
|
||||
// applicationName: "Nexus",
|
||||
// applicationVersion: packageInfo.version,
|
||||
// children: [
|
||||
// Text(
|
||||
// "A simple and user-friendly Matrix client.",
|
||||
// style: Theme.of(context).textTheme.titleMedium,
|
||||
// ),
|
||||
// ],
|
||||
// applicationIcon: SvgPicture.asset(
|
||||
// "assets/icon.svg",
|
||||
// width: 48,
|
||||
// ),
|
||||
// );
|
||||
}
|
||||
},
|
||||
onPressed: () => context.showAboutDialog(ref),
|
||||
icon: Icon(Icons.info_outline),
|
||||
),
|
||||
],
|
||||
|
|
|
|||
Loading…
Reference in a new issue