about_page.dart
2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import 'dart:async';
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:one_poem/res/resources.dart';
import 'package:one_poem/routers/fluro_navigator.dart';
import 'package:one_poem/util/device_utils.dart';
import 'package:one_poem/util/other_utils.dart';
import 'package:one_poem/widgets/click_item.dart';
import 'package:one_poem/widgets/my_app_bar.dart';
class AboutPage extends StatefulWidget {
const AboutPage({Key? key}) : super(key: key);
@override
_AboutPageState createState() => _AboutPageState();
}
class _AboutPageState extends State<AboutPage> {
final List<FlutterLogoStyle> _styles = <FlutterLogoStyle>[
FlutterLogoStyle.stacked,
FlutterLogoStyle.markOnly,
FlutterLogoStyle.horizontal
];
final List<Cubic> _curves = <Cubic>[
Curves.ease, Curves.easeIn, Curves.easeInOutCubic, Curves.easeInOut,
Curves.easeInQuad, Curves.easeInCirc, Curves.easeInBack, Curves.easeInOutExpo,
Curves.easeInToLinear, Curves.easeOutExpo, Curves.easeInOutSine, Curves.easeOutSine,
];
// 取随机颜色
Color _randomColor() {
final int red = Random.secure().nextInt(255);
final int greed = Random.secure().nextInt(255);
final int blue = Random.secure().nextInt(255);
return Color.fromARGB(255, red, greed, blue);
}
Timer? _countdownTimer;
@override
void initState() {
super.initState();
WidgetsBinding.instance!.addPostFrameCallback((_) async {
// 2s定时器
_countdownTimer = Timer.periodic(const Duration(seconds: 2), (_) {
// https://www.jianshu.com/p/e4106b829bff
if (!mounted) {
return;
}
setState(() {
});
});
});
}
@override
void dispose() {
_countdownTimer?.cancel();
_countdownTimer = null;
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: const MyAppBar(
title: '关于我们',
),
body: Column(
children: <Widget>[
Gaps.vGap50,
FlutterLogo(
size: 100.0,
textColor: _randomColor(),
style: _styles[Random.secure().nextInt(3)],
curve: _curves[Random.secure().nextInt(12)],
),
Gaps.vGap10,
ClickItem(
title: 'Github',
content: 'Go Star',
onTap: () => _launchWebURL('Flutter Deer', 'https://github.com/simplezhli/flutter_deer')
),
ClickItem(
title: '作者博客',
onTap: () => _launchWebURL('作者博客', 'https://weilu.blog.csdn.net')
),
],
),
);
}
void _launchWebURL(String title, String url) {
if (Device.isMobile) {
NavigatorUtils.goWebViewPage(context, title, url);
} else {
Utils.launchWebURL(url);
}
}
}