|
@@ -1,13 +1,14 @@
|
|
-import 'package:flutter/material.dart';
|
|
|
|
import 'dart:async';
|
|
import 'dart:async';
|
|
import 'dart:math' as math;
|
|
import 'dart:math' as math;
|
|
|
|
+
|
|
|
|
+import 'package:flutter/material.dart';
|
|
|
|
+import 'package:flutter_clock/model/config.dart';
|
|
import 'package:intl/intl.dart';
|
|
import 'package:intl/intl.dart';
|
|
|
|
|
|
class MainPage extends StatefulWidget {
|
|
class MainPage extends StatefulWidget {
|
|
@override
|
|
@override
|
|
State<StatefulWidget> createState() {
|
|
State<StatefulWidget> createState() {
|
|
- @override
|
|
|
|
- _MainPageState createState() => _MainPageState();
|
|
|
|
|
|
+ return _MainPageState();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -24,35 +25,64 @@ class _MainPageState extends State<MainPage> {
|
|
}
|
|
}
|
|
|
|
|
|
@override
|
|
@override
|
|
- Widget build(BuildContext context) => Scaffold(
|
|
|
|
|
|
+ Widget build(BuildContext context) {
|
|
|
|
+ return Scaffold(
|
|
backgroundColor: Colors.white,
|
|
backgroundColor: Colors.white,
|
|
- appBar: AppBar(title: Text('xkcd clock')),
|
|
|
|
- body: Column(
|
|
|
|
- children: [
|
|
|
|
- Stack(
|
|
|
|
|
|
+ body: SingleChildScrollView(
|
|
|
|
+ child: Center(
|
|
|
|
+ child: Column(
|
|
children: [
|
|
children: [
|
|
- Image.asset('assets/face.png'),
|
|
|
|
- Transform.rotate(
|
|
|
|
- angle: -(radiansFromTime(_localTime.toUtc()) +
|
|
|
|
- _utcMidnightRadiansOffset),
|
|
|
|
- child: ClipOval(
|
|
|
|
- clipper: InnerFaceClipper(),
|
|
|
|
- child: Image.asset('assets/face.png'),
|
|
|
|
|
|
+ Text(
|
|
|
|
+ "Clock",
|
|
|
|
+ style: TextStyle(
|
|
|
|
+ fontSize: 30,
|
|
|
|
+ color: Colors.red,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
|
|
+ Text(
|
|
|
|
+ "author: 天问",
|
|
|
|
+ style: TextStyle(fontFamily: Config.defaultFontFamily),
|
|
|
|
+ ),
|
|
|
|
+ Text(
|
|
|
|
+ "contact: liuyuqi.gov@msn.cn",
|
|
|
|
+ style: TextStyle(fontFamily: Config.defaultFontFamily),
|
|
|
|
+ ),
|
|
|
|
+ SizedBox(
|
|
|
|
+ height: 5,
|
|
|
|
+ ),
|
|
|
|
+ Stack(
|
|
|
|
+ children: [
|
|
|
|
+ Image.asset(
|
|
|
|
+ 'assets/face.png',
|
|
|
|
+ width: 350,
|
|
|
|
+ ),
|
|
|
|
+ Transform.rotate(
|
|
|
|
+ angle: -(radiansFromTime(_localTime.toUtc()) +
|
|
|
|
+ _utcMidnightRadiansOffset),
|
|
|
|
+ child: ClipOval(
|
|
|
|
+ clipper: InnerFaceClipper(),
|
|
|
|
+ child: Image.asset(
|
|
|
|
+ 'assets/face.png',
|
|
|
|
+ width: 350,
|
|
|
|
+ ),
|
|
|
|
+ ),
|
|
|
|
+ ),
|
|
|
|
+ ],
|
|
|
|
+ ),
|
|
|
|
+ Text(DateFormat.EEEE().format(_localTime),
|
|
|
|
+ style: TextStyle(fontSize: 48)),
|
|
|
|
+ Text(DateFormat.yMMMMd().format(_localTime),
|
|
|
|
+ style: TextStyle(fontSize: 20)),
|
|
|
|
+ Text(DateFormat.jms().format(_localTime),
|
|
|
|
+ style: TextStyle(fontSize: 42)),
|
|
],
|
|
],
|
|
),
|
|
),
|
|
- Text(DateFormat.EEEE().format(_localTime),
|
|
|
|
- style: TextStyle(fontSize: 48)),
|
|
|
|
- Text(DateFormat.yMMMMd().format(_localTime),
|
|
|
|
- style: TextStyle(fontSize: 20)),
|
|
|
|
- Text(DateFormat.jm().format(_localTime),
|
|
|
|
- style: TextStyle(fontSize: 42)),
|
|
|
|
- ],
|
|
|
|
- ),
|
|
|
|
- );
|
|
|
|
|
|
+ ),
|
|
|
|
+ ));
|
|
|
|
+ }
|
|
|
|
|
|
static double radiansFromDegrees(double degrees) => degrees * math.pi / 180;
|
|
static double radiansFromDegrees(double degrees) => degrees * math.pi / 180;
|
|
|
|
+
|
|
static double radiansFromTime(DateTime time) {
|
|
static double radiansFromTime(DateTime time) {
|
|
final midnightToday = DateTime(time.year, time.month, time.day);
|
|
final midnightToday = DateTime(time.year, time.month, time.day);
|
|
final secondsSinceMidnight = midnightToday.difference(time).inSeconds;
|
|
final secondsSinceMidnight = midnightToday.difference(time).inSeconds;
|