mirror of
https://github.com/kodjodevf/mangayomi.git
synced 2026-04-21 16:01:58 +00:00
refactor
This commit is contained in:
parent
417abe8d5e
commit
3f54459f65
7 changed files with 123 additions and 123 deletions
|
|
@ -2,126 +2,101 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:mangayomi/modules/more/about/providers/check_for_update.dart';
|
||||
import 'package:mangayomi/modules/more/about/providers/get_package_info.dart';
|
||||
import 'package:mangayomi/modules/widgets/progress_center.dart';
|
||||
import 'package:mangayomi/providers/l10n_providers.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
|
||||
class AboutScreen extends ConsumerStatefulWidget {
|
||||
class AboutScreen extends ConsumerWidget {
|
||||
const AboutScreen({super.key});
|
||||
|
||||
@override
|
||||
ConsumerState<AboutScreen> createState() => _AboutScreenState();
|
||||
}
|
||||
|
||||
class _AboutScreenState extends ConsumerState<AboutScreen> {
|
||||
Future<void> _launchInBrowser(Uri url) async {
|
||||
if (!await launchUrl(
|
||||
url,
|
||||
mode: LaunchMode.externalApplication,
|
||||
)) {
|
||||
throw 'Could not launch $url';
|
||||
}
|
||||
}
|
||||
|
||||
PackageInfo _packageInfo = PackageInfo(
|
||||
appName: 'Unknown',
|
||||
packageName: 'Unknown',
|
||||
version: 'Unknown',
|
||||
buildNumber: 'Unknown',
|
||||
buildSignature: 'Unknown',
|
||||
installerStore: 'Unknown',
|
||||
);
|
||||
|
||||
Future<void> _initPackageInfo() async {
|
||||
final info = await PackageInfo.fromPlatform();
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_packageInfo = info;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_initPackageInfo();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final l10n = l10nLocalizations(context);
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(l10n!.about),
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 40),
|
||||
child: Image.asset(
|
||||
"assets/app_icons/icon.png",
|
||||
color: Theme.of(context).brightness == Brightness.light
|
||||
? Colors.black
|
||||
: Colors.white,
|
||||
fit: BoxFit.cover,
|
||||
height: 100,
|
||||
),
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
const Divider(
|
||||
color: Colors.grey,
|
||||
),
|
||||
ListTile(
|
||||
onTap: () {},
|
||||
title: const Text('Version'),
|
||||
subtitle: Text(
|
||||
'Beta (${_packageInfo.version})',
|
||||
style: const TextStyle(fontSize: 12),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
onTap: () {
|
||||
ref.read(checkForUpdateProvider(
|
||||
context: context, manualUpdate: true));
|
||||
},
|
||||
title: Text(l10n.check_for_update),
|
||||
),
|
||||
// ListTile(
|
||||
// onTap: () {},
|
||||
// title: const Text("What's news"),
|
||||
// ),
|
||||
// ListTile(
|
||||
// onTap: () {},
|
||||
// title: const Text('Help translation'),
|
||||
// ),
|
||||
// ListTile(
|
||||
// onTap: () {},
|
||||
// title: const Text('Privacy policy'),
|
||||
// ),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
_launchInBrowser(Uri.parse(
|
||||
'https://github.com/kodjodevf/mangayomi'));
|
||||
},
|
||||
icon: const Icon(FontAwesomeIcons.github)),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
_launchInBrowser(Uri.parse(
|
||||
'https://discord.com/invite/EjfBuYahsP'));
|
||||
},
|
||||
icon: const Icon(FontAwesomeIcons.discord))
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
appBar: AppBar(
|
||||
title: Text(l10n!.about),
|
||||
),
|
||||
),
|
||||
);
|
||||
body: ref.watch(getPackageInfoProvider).when(
|
||||
data: (data) => SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 40),
|
||||
child: Image.asset(
|
||||
"assets/app_icons/icon.png",
|
||||
color: Theme.of(context).brightness == Brightness.light
|
||||
? Colors.black
|
||||
: Colors.white,
|
||||
fit: BoxFit.cover,
|
||||
height: 100,
|
||||
),
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
const Divider(
|
||||
color: Colors.grey,
|
||||
),
|
||||
ListTile(
|
||||
onTap: () {},
|
||||
title: const Text('Version'),
|
||||
subtitle: Text(
|
||||
'Beta (${data.version})',
|
||||
style: const TextStyle(fontSize: 12),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
onTap: () {
|
||||
ref.read(checkForUpdateProvider(
|
||||
context: context, manualUpdate: true));
|
||||
},
|
||||
title: Text(l10n.check_for_update),
|
||||
),
|
||||
// ListTile(
|
||||
// onTap: () {},
|
||||
// title: const Text("What's news"),
|
||||
// ),
|
||||
// ListTile(
|
||||
// onTap: () {},
|
||||
// title: const Text('Help translation'),
|
||||
// ),
|
||||
// ListTile(
|
||||
// onTap: () {},
|
||||
// title: const Text('Privacy policy'),
|
||||
// ),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
_launchInBrowser(Uri.parse(
|
||||
'https://github.com/kodjodevf/mangayomi'));
|
||||
},
|
||||
icon: const Icon(FontAwesomeIcons.github)),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
_launchInBrowser(Uri.parse(
|
||||
'https://discord.com/invite/EjfBuYahsP'));
|
||||
},
|
||||
icon: const Icon(FontAwesomeIcons.discord))
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
error: (error, stackTrace) => ErrorWidget(error),
|
||||
loading: () => const ProgressCenter(),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _launchInBrowser(Uri url) async {
|
||||
if (!await launchUrl(
|
||||
url,
|
||||
mode: LaunchMode.externalApplication,
|
||||
)) {
|
||||
throw 'Could not launch $url';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import 'package:url_launcher/url_launcher.dart';
|
|||
part 'check_for_update.g.dart';
|
||||
|
||||
@riverpod
|
||||
checkForUpdate(CheckForUpdateRef ref,
|
||||
Future<void> checkForUpdate(CheckForUpdateRef ref,
|
||||
{BuildContext? context, bool? manualUpdate}) async {
|
||||
manualUpdate = manualUpdate ?? false;
|
||||
final l10n = l10nLocalizations(context!)!;
|
||||
|
|
|
|||
8
lib/modules/more/about/providers/get_package_info.dart
Normal file
8
lib/modules/more/about/providers/get_package_info.dart
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
part 'get_package_info.g.dart';
|
||||
|
||||
@riverpod
|
||||
Future<PackageInfo> getPackageInfo(GetPackageInfoRef ref) async {
|
||||
return (await PackageInfo.fromPlatform());
|
||||
}
|
||||
25
lib/modules/more/about/providers/get_package_info.g.dart
Normal file
25
lib/modules/more/about/providers/get_package_info.g.dart
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'get_package_info.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$getPackageInfoHash() => r'792f15659bdcbe4914a35d47d302aa0e61a207d6';
|
||||
|
||||
/// See also [getPackageInfo].
|
||||
@ProviderFor(getPackageInfo)
|
||||
final getPackageInfoProvider = AutoDisposeFutureProvider<PackageInfo>.internal(
|
||||
getPackageInfo,
|
||||
name: r'getPackageInfoProvider',
|
||||
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$getPackageInfoHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
typedef GetPackageInfoRef = AutoDisposeFutureProviderRef<PackageInfo>;
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member
|
||||
|
|
@ -42,12 +42,5 @@ String regCustomMatcher(
|
|||
}
|
||||
|
||||
String padIndex(int index) {
|
||||
String idx = index.toString();
|
||||
|
||||
if (idx.length == 1) {
|
||||
return '00$idx';
|
||||
} else if (idx.length == 2) {
|
||||
return '0$idx';
|
||||
}
|
||||
return idx;
|
||||
return index.toString().padLeft(3, "0");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ packages:
|
|||
source: hosted
|
||||
version: "67.0.0"
|
||||
analyzer:
|
||||
dependency: "direct overridden"
|
||||
dependency: transitive
|
||||
description:
|
||||
name: analyzer
|
||||
sha256: "37577842a27e4338429a1cbc32679d508836510b056f1eedf0c8d20e39c1383d"
|
||||
|
|
|
|||
|
|
@ -81,7 +81,6 @@ dependencies:
|
|||
super_sliver_list: ^0.4.1
|
||||
|
||||
dependency_overrides:
|
||||
analyzer: ">=5.2.0 <7.0.0"
|
||||
http: ^1.2.1
|
||||
ffi: ^2.1.2
|
||||
flex_seed_scheme: ^2.0.0
|
||||
|
|
|
|||
Loading…
Reference in a new issue