优化统计报告

gxh_branch
gexinghai 3 years ago
parent cb4ce20a7c
commit fb697e68a0

@ -15,7 +15,7 @@ migration:
- platform: root
create_revision: ff5b5b5fa6f35b717667719ddfdb1521d8bdd05a
base_revision: ff5b5b5fa6f35b717667719ddfdb1521d8bdd05a
- platform: android
- platform: web
create_revision: ff5b5b5fa6f35b717667719ddfdb1521d8bdd05a
base_revision: ff5b5b5fa6f35b717667719ddfdb1521d8bdd05a

@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:timemanage/screen/dashboard/dashboard_screen.dart';
///
/// dartdoc/** */
/// dartdoc/** */
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {

@ -44,203 +44,215 @@ class CourseScreenState extends State<CourseScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
SizedBox(
child: GridView.builder(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemCount: 8,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 8, childAspectRatio: 1 / 1),
itemBuilder: (BuildContext context, int index) {
return Container(
color: index == currentWeekIndex
? Color(0x00f7f7f7)
: Colors.white,
child: Center(
child: index == 0
? Column(
mainAxisAlignment: MainAxisAlignment.center,
children: const [
Text("星期",
style: TextStyle(
fontSize: 14, color: Colors.black87)),
SizedBox(height: 5),
Text("日期", style: TextStyle(fontSize: 12)),
],
)
: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(weekList[index - 1],
style: TextStyle(
fontSize: 14,
color: index == currentWeekIndex
? Colors.lightBlue
: Colors.black87)),
SizedBox(height: 5),
Text(dateList[index - 1],
style: TextStyle(
fontSize: 12,
color: index == currentWeekIndex
? Colors.lightBlue
: Colors.black87)),
],
),
),
);
}),
),
Expanded(
child: SingleChildScrollView(
child: Row(
children: [
Expanded(
flex: 1,
child: GridView.builder(
shrinkWrap: true,
// physics:ClampingScrollPhysics(),
itemCount: 10,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 1, childAspectRatio: 1 / 2),
itemBuilder: (BuildContext context, int index) {
return Container(
decoration: BoxDecoration(
color: Color(0x00ff5ff5),
// border: Border.all(color: Colors.black12, width: 0.5),
border: Border(
bottom: BorderSide(
color: Colors.black12, width: 0.5),
right: BorderSide(
color: Colors.black12, width: 0.5),
),
body: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
SizedBox(
child: GridView.builder(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemCount: 8,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 8, childAspectRatio: 1 / 1),
itemBuilder: (BuildContext context, int index) {
return Container(
color: index == currentWeekIndex
? Color(0x00f7f7f7)
: Colors.white,
child: Center(
child: index == 0
? Column(
mainAxisAlignment: MainAxisAlignment.center,
children: const [
Text("星期",
style: TextStyle(
fontSize: 14, color: Colors.black87)),
SizedBox(height: 5),
Text("日期", style: TextStyle(fontSize: 12)),
],
)
: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(weekList[index - 1],
style: TextStyle(
fontSize: 14,
color: index == currentWeekIndex
? Colors.lightBlue
: Colors.black87)),
SizedBox(height: 5),
Text(dateList[index - 1],
style: TextStyle(
fontSize: 12,
color: index == currentWeekIndex
? Colors.lightBlue
: Colors.black87)),
],
),
// width: 25,
// height:s 80,
child: Center(
child: Text(
(index + 1).toInt().toString(),
style: TextStyle(fontSize: 15),
),
));
}),
),
Expanded(
flex: 7,
child: GridView.builder(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemCount: 35,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 7, childAspectRatio: 1 / 4),
itemBuilder: (BuildContext context, int index) {
return GestureDetector(
// onTap: () {
// //
// print('点击了课程');
// },
// onTap: () {
// // EditCoursePage
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (context) => EditCoursePage(
// onSave: (String) {},
// )),
// );
// },
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => EditCoursePage(
onSave: (courseInfo) {
//
setState(() {
//
infoList[index % 2] = courseInfo;
});
},
),
);
}),
),
Expanded(
child: SingleChildScrollView(
child: Row(
children: [
Expanded(
flex: 1,
child: GridView.builder(
shrinkWrap: true,
// physics:ClampingScrollPhysics(),
itemCount: 10,
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 1, childAspectRatio: 1 / 2),
itemBuilder: (BuildContext context, int index) {
return Container(
decoration: BoxDecoration(
color: Color(0x00ff5ff5),
// border: Border.all(color: Colors.black12, width: 0.5),
border: Border(
bottom: BorderSide(
color: Colors.black12, width: 0.5),
right: BorderSide(
color: Colors.black12, width: 0.5),
),
),
);
},
child: Stack(
children: [
Column(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Flexible(
flex: 1,
child: Container(
width: double.infinity,
height: double.infinity,
decoration: BoxDecoration(
color: Colors.white,
border: Border(
bottom: BorderSide(
color: Colors.black12,
width: 0.5),
right: BorderSide(
color: Colors.black12,
width: 0.5),
),
)),
),
Flexible(
flex: 1,
child: Container(
width: double.infinity,
height: double.infinity,
decoration: BoxDecoration(
color: Colors.white,
border: Border(
bottom: BorderSide(
color: Colors.black12,
width: 0.5),
right: BorderSide(
color: Colors.black12,
width: 0.5),
),
)),
),
],
),
if (index % 5 == 0 || index % 5 == 1)
Container(
margin: EdgeInsets.all(0.5),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(2),
color: colorList[index % 7],
// width: 25,
// height:s 80,
child: Center(
child: Text(
(index + 1).toInt().toString(),
style: TextStyle(fontSize: 15),
),
));
}),
),
Expanded(
flex: 7,
child: GridView.builder(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemCount: 35,
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 7, childAspectRatio: 1 / 4),
itemBuilder: (BuildContext context, int index) {
return GestureDetector(
// onTap: () {
// //
// print('点击了课程');
// },
// onTap: () {
// // EditCoursePage
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (context) => EditCoursePage(
// onSave: (String) {},
// )),
// );
// },
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => EditCoursePage(
onSave: (courseInfo) {
//
setState(() {
//
infoList[index % 2] = courseInfo;
});
},
),
child: Center(
child: Text(
infoList[index % 2],
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontSize: 11,
letterSpacing: 1),
),
);
},
child: Stack(
children: [
Column(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Flexible(
flex: 1,
child: Container(
width: double.infinity,
height: double.infinity,
decoration: BoxDecoration(
color: Colors.white,
border: Border(
bottom: BorderSide(
color: Colors.black12,
width: 0.5),
right: BorderSide(
color: Colors.black12,
width: 0.5),
),
)),
),
),
)
],
),
);
}),
)
],
Flexible(
flex: 1,
child: Container(
width: double.infinity,
height: double.infinity,
decoration: BoxDecoration(
color: Colors.white,
border: Border(
bottom: BorderSide(
color: Colors.black12,
width: 0.5),
right: BorderSide(
color: Colors.black12,
width: 0.5),
),
)),
),
],
),
if (index % 5 == 0 || index % 5 == 1)
Container(
margin: EdgeInsets.all(0.5),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(2),
color: colorList[index % 7],
),
child: Center(
child: Text(
infoList[index % 2],
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontSize: 11,
letterSpacing: 1),
),
),
)
],
),
);
}),
)
],
),
),
),
_bottomView
],
),
//
floatingActionButton: Container(
margin: EdgeInsets.only(left: 20),
color: Colors.blueAccent,
child: IconButton(
icon: Icon(Icons.arrow_back),
onPressed: () {
Navigator.pop(context);
},
),
_bottomView
],
),
);
));
}
String pageTitle() => "我的课表";

@ -2,14 +2,20 @@ import 'package:flutter/material.dart';
class ExportScreen extends StatelessWidget {
const ExportScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('导入与导出'),
),
body: const Center(
child: Text('导入与导出界面'),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: const [
Text('导入与导出'),
],
),
),
);
}

@ -17,39 +17,45 @@ class _ReportsScreenState extends State<ReportsScreen> {
//
Future<List<TimerEntry>> timers = TimerEntryDatabase.instance.readAll();
//
Map<String, num> persentMap = {};
Map<String, int> persentMap = {'工作': 3, '学习': 2, '娱乐': 4, '运动': 1, '其他': 6};
@override
void initState() {
super.initState();
//
classifyTimers().then((value) => persentMap = value);
classifyTimers().then((value) {
value.forEach((key, value) {
if (persentMap.containsKey(key)) {
persentMap[key] = value;
} else {
persentMap[key] = value;
}
});
});
}
/**
*
* @return
*/
Future<Map<String, num>> classifyTimers() async {
///
/// @return
Future<Map<String, int>> classifyTimers() async {
var timers = await TimerEntryDatabase.instance.readAll(); //
Map<String, num> presentMap = {}; //
Map<String, int> presentMap = persentMap; //
for (var timer in timers) {
var response = await postData(timer.name); // API
await Future.delayed(Duration(milliseconds: 500)); // 0.5API
var classification =
jsonDecode(response.body)['item']['lv1_tag_list'][0]['tag']; // API
await Future.delayed(
Duration(milliseconds: 500)); // 0.5API
var classification = jsonDecode(response.body)['item']['lv1_tag_list'][0]
['tag']; // API
// APIISO-8859-1
classification = utf8.decode(classification.runes.toList());
persentMap[classification] = timer.stopwatch!.elapsed.inSeconds;
persentMap[classification] =
(persentMap[classification] ?? 0) + 1; //
log('name: ${timer.name}, classification: $classification, persent: ${persentMap[classification]}');
}
return persentMap;
}
/**
* API
* @param name
* @return API
*/
/// API
/// @param name
/// @return API
Future<http.Response> postData(String name) async {
String API_KEY = "YGxSMNdWKO5Gpt12dNVY2nGq"; // APIAPI Key
String SECRET_KEY = "G5NBDTiRPhsBqMi1Od0XZw4RSMlFgeek"; // APISecret Key
@ -95,28 +101,38 @@ class _ReportsScreenState extends State<ReportsScreen> {
title: const Text('统计报告'),
),
body: FutureBuilder<Map<String, num>>(
future: classifyTimers(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
//
return Center(
//
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: const [
CircularProgressIndicator(),
SizedBox(height: 20),
Text('正在统计,请稍后...'),
],
),
);
} else if (snapshot.hasError) {
return Text('Error: ${snapshot.error}');
} else {
// the Future has completed with data. Display the data.
return Text(snapshot.data.toString());
}
}),
future: classifyTimers(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
//
return Center(
//
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: const [
CircularProgressIndicator(),
SizedBox(height: 20),
Text('正在统计,请稍后...'),
],
),
);
} else if (snapshot.hasError) {
return Text('Error: ${snapshot.error}');
} else {
// the Future has completed with data. Display the data.
//
return ListView.builder(
itemCount: persentMap.length,
itemBuilder: (context, index) {
return ListTile(
title: Text(persentMap.keys.elementAt(index)),
subtitle: Text('${persentMap.values.elementAt(index)}'),
);
},
);
}
},
),
);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 917 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

@ -0,0 +1,59 @@
<!DOCTYPE html>
<html>
<head>
<!--
If you are serving your web app in a path other than the root, change the
href value below to reflect the base path you are serving from.
The path provided below has to start and end with a slash "/" in order for
it to work correctly.
For more details:
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
This is a placeholder for base href that will be replaced by the value of
the `--base-href` argument provided to `flutter build`.
-->
<base href="$FLUTTER_BASE_HREF">
<meta charset="UTF-8">
<meta content="IE=Edge" http-equiv="X-UA-Compatible">
<meta name="description" content="A new Flutter project.">
<!-- iOS meta tags & icons -->
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-title" content="timemaneger">
<link rel="apple-touch-icon" href="icons/Icon-192.png">
<!-- Favicon -->
<link rel="icon" type="image/png" href="favicon.png"/>
<title>timemaneger</title>
<link rel="manifest" href="manifest.json">
<script>
// The value below is injected by flutter build, do not touch.
const serviceWorkerVersion = null;
</script>
<!-- This script adds the flutter initialization JS code -->
<script src="flutter.js" defer></script>
</head>
<body>
<script>
window.addEventListener('load', function(ev) {
// Download main.dart.js
_flutter.loader.loadEntrypoint({
serviceWorker: {
serviceWorkerVersion: serviceWorkerVersion,
},
onEntrypointLoaded: function(engineInitializer) {
engineInitializer.initializeEngine().then(function(appRunner) {
appRunner.runApp();
});
}
});
});
</script>
</body>
</html>

@ -0,0 +1,35 @@
{
"name": "timemaneger",
"short_name": "timemaneger",
"start_url": ".",
"display": "standalone",
"background_color": "#0175C2",
"theme_color": "#0175C2",
"description": "A new Flutter project.",
"orientation": "portrait-primary",
"prefer_related_applications": false,
"icons": [
{
"src": "icons/Icon-192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "icons/Icon-512.png",
"sizes": "512x512",
"type": "image/png"
},
{
"src": "icons/Icon-maskable-192.png",
"sizes": "192x192",
"type": "image/png",
"purpose": "maskable"
},
{
"src": "icons/Icon-maskable-512.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "maskable"
}
]
}
Loading…
Cancel
Save