添加关于页面

This commit is contained in:
jyuesong
2022-01-20 14:05:32 +08:00
parent 130459d646
commit a97aa1f347
10 changed files with 526 additions and 219 deletions

View File

@@ -0,0 +1,128 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:qinglong_app/base/ql_app_bar.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:qinglong_app/base/theme.dart';
import 'package:url_launcher/url_launcher.dart';
import '../../main.dart';
/// @author NewTab
class AboutPage extends ConsumerStatefulWidget {
const AboutPage({Key? key}) : super(key: key);
@override
ConsumerState createState() => _AboutPageState();
}
class _AboutPageState extends ConsumerState<AboutPage> {
String desc = "";
@override
void initState() {
super.initState();
getInfo();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: QlAppBar(
canBack: true,
title: "关于",
),
body: SizedBox(
width: MediaQuery.of(context).size.width,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(
height: MediaQuery.of(context).size.height / 10,
),
Image.asset(
"assets/images/ql.png",
height: 50,
),
const SizedBox(
height: 30,
),
Text(
"青龙",
style: TextStyle(
fontWeight: FontWeight.w600,
color: ref.watch(themeProvider).themeColor.titleColor(),
fontSize: 20,
),
),
const SizedBox(
height: 15,
),
Text(
"Version ${desc}",
style: TextStyle(
color: ref.watch(themeProvider).themeColor.descColor(),
fontSize: 16,
),
),
const Spacer(),
Row(
children: [
const Spacer(),
GestureDetector(
onTap: () {
_launchURL("https://github.com/qinglong-app/qinglong_app/releases");
},
child: Text(
"版本更新",
style: TextStyle(
color: primaryColor,
fontSize: 16,
),
),
),
const SizedBox(
width: 15,
),
GestureDetector(
onTap: () {
_launchURL("https://github.com/qinglong-app/qinglong_app");
},
child: Text(
"项目地址",
style: TextStyle(
color: primaryColor,
fontSize: 16,
),
),
),
const Spacer(),
],
),
const SizedBox(
height: 15,
),
],
),
),
);
}
void _launchURL(String _url) async {
try {
await launch(_url);
} catch (e) {
logger.e(e);
}
}
void getInfo() async {
PackageInfo packageInfo = await PackageInfo.fromPlatform();
String version = packageInfo.version;
desc = version;
setState(() {});
}
}

View File

@@ -252,6 +252,7 @@ class _OtherPageState extends ConsumerState<OtherPage> {
padding: const EdgeInsets.only(
left: 15,
right: 15,
top: 5,
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
@@ -266,13 +267,51 @@ class _OtherPageState extends ConsumerState<OtherPage> {
),
const Spacer(),
CupertinoSwitch(
value: ref.watch(themeProvider).isInDartMode(),
onChanged: (open) {
ref.watch(themeProvider).changeThemeReal(open);
}),
value: ref.watch(themeProvider).isInDartMode(),
onChanged: (open) {
ref.watch(themeProvider).changeThemeReal(open);
},
),
],
),
),
const Divider(
indent: 15,
),
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
Navigator.of(context).pushNamed(
Routes.routeAbout,
);
},
child: Padding(
padding: const EdgeInsets.only(
left: 15,
right: 15,
top: 5,
bottom: 15,
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"关于",
style: TextStyle(
color: ref.watch(themeProvider).themeColor.titleColor(),
fontSize: 16,
),
),
const Spacer(),
const Icon(
CupertinoIcons.right_chevron,
size: 16,
),
],
),
),
),
],
),
),