2020-08-10 20:41:22 +02:00
|
|
|
import 'dart:developer' as developer;
|
|
|
|
|
2020-07-26 12:20:42 +02:00
|
|
|
import 'package:dio/dio.dart';
|
|
|
|
import 'package:fl_chart/fl_chart.dart';
|
2020-03-14 04:14:24 +01:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/services.dart';
|
2020-05-09 17:42:13 +02:00
|
|
|
import 'package:fluttertoast/fluttertoast.dart';
|
2020-07-26 12:20:42 +02:00
|
|
|
import 'package:intl/intl.dart';
|
2020-05-09 17:42:13 +02:00
|
|
|
import 'package:line_icons/line_icons.dart';
|
2020-07-26 12:20:42 +02:00
|
|
|
import 'package:provider/provider.dart';
|
2020-07-26 15:48:30 +02:00
|
|
|
import 'package:webfeed/webfeed.dart';
|
2020-05-06 18:50:32 +02:00
|
|
|
|
|
|
|
import '../local_storage/sqflite_localpodcast.dart';
|
2020-07-14 17:45:45 +02:00
|
|
|
import '../state/podcast_group.dart';
|
2020-07-26 12:20:42 +02:00
|
|
|
import '../type/play_histroy.dart';
|
2020-09-23 16:19:07 +02:00
|
|
|
import '../type/search_api/searchpodcast.dart';
|
2020-05-06 18:50:32 +02:00
|
|
|
import '../type/sub_history.dart';
|
2020-10-09 17:59:29 +02:00
|
|
|
import '../util/custom_widget.dart';
|
2020-07-26 12:20:42 +02:00
|
|
|
import '../util/extension_helper.dart';
|
2020-03-14 04:14:24 +01:00
|
|
|
|
|
|
|
class PlayedHistory extends StatefulWidget {
|
|
|
|
@override
|
|
|
|
_PlayedHistoryState createState() => _PlayedHistoryState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _PlayedHistoryState extends State<PlayedHistory>
|
|
|
|
with SingleTickerProviderStateMixin {
|
2020-08-16 10:05:18 +02:00
|
|
|
/// Get play history.
|
|
|
|
Future<List<PlayHistory>> _getPlayHistory(int top) async {
|
2020-07-26 12:20:42 +02:00
|
|
|
var dbHelper = DBHelper();
|
2020-03-14 04:14:24 +01:00
|
|
|
List<PlayHistory> playHistory;
|
2020-04-02 11:52:26 +02:00
|
|
|
playHistory = await dbHelper.getPlayHistory(top);
|
2020-07-26 12:20:42 +02:00
|
|
|
for (var record in playHistory) {
|
|
|
|
await record.getEpisode();
|
|
|
|
}
|
2020-03-14 04:14:24 +01:00
|
|
|
return playHistory;
|
|
|
|
}
|
|
|
|
|
2020-08-16 10:05:18 +02:00
|
|
|
bool _loadMore = false;
|
|
|
|
|
2020-08-28 23:05:37 +02:00
|
|
|
Future<void> _loadMoreData() async {
|
2020-07-26 12:20:42 +02:00
|
|
|
if (mounted) {
|
2020-04-02 11:52:26 +02:00
|
|
|
setState(() {
|
2020-08-16 10:05:18 +02:00
|
|
|
_loadMore = true;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
await Future.delayed(Duration(milliseconds: 500));
|
|
|
|
if (mounted) {
|
|
|
|
setState(() {
|
|
|
|
_top = _top + 10;
|
|
|
|
_loadMore = false;
|
2020-04-02 11:52:26 +02:00
|
|
|
});
|
2020-07-26 12:20:42 +02:00
|
|
|
}
|
2020-04-02 11:52:26 +02:00
|
|
|
}
|
|
|
|
|
2020-08-16 10:05:18 +02:00
|
|
|
int _top = 10;
|
2020-04-02 11:52:26 +02:00
|
|
|
|
2020-03-14 04:14:24 +01:00
|
|
|
Future<List<SubHistory>> getSubHistory() async {
|
2020-07-26 12:20:42 +02:00
|
|
|
var dbHelper = DBHelper();
|
2020-03-14 04:14:24 +01:00
|
|
|
return await dbHelper.getSubHistory();
|
|
|
|
}
|
|
|
|
|
|
|
|
TabController _controller;
|
|
|
|
List<int> list = const [0, 1, 2, 3, 4, 5, 6];
|
|
|
|
|
|
|
|
Future<List<FlSpot>> getData() async {
|
|
|
|
var dbHelper = DBHelper();
|
2020-07-26 12:20:42 +02:00
|
|
|
var stats = <FlSpot>[];
|
2020-07-13 09:41:59 +02:00
|
|
|
|
|
|
|
for (var day in list) {
|
2020-07-26 12:20:42 +02:00
|
|
|
var mins = await dbHelper.listenMins(7 - day);
|
2020-03-14 04:14:24 +01:00
|
|
|
stats.add(FlSpot(day.toDouble(), mins));
|
2020-07-13 09:41:59 +02:00
|
|
|
}
|
2020-03-14 04:14:24 +01:00
|
|
|
return stats;
|
|
|
|
}
|
|
|
|
|
2020-05-09 17:42:13 +02:00
|
|
|
Future recoverSub(BuildContext context, String url) async {
|
|
|
|
Fluttertoast.showToast(
|
2020-07-06 11:50:20 +02:00
|
|
|
msg: context.s.toastPodcastRecovering,
|
2020-05-09 17:42:13 +02:00
|
|
|
gravity: ToastGravity.BOTTOM,
|
|
|
|
);
|
2020-07-14 17:45:45 +02:00
|
|
|
var subscribeWorker = context.watch<GroupList>();
|
2020-05-09 17:42:13 +02:00
|
|
|
try {
|
2020-07-26 12:20:42 +02:00
|
|
|
var options = BaseOptions(
|
2020-05-09 17:42:13 +02:00
|
|
|
connectTimeout: 10000,
|
|
|
|
receiveTimeout: 10000,
|
|
|
|
);
|
2020-07-26 12:20:42 +02:00
|
|
|
var response = await Dio(options).get(url);
|
2020-05-09 17:42:13 +02:00
|
|
|
var p = RssFeed.parse(response.data);
|
|
|
|
var podcast = OnlinePodcast(
|
|
|
|
rss: url,
|
|
|
|
title: p.title,
|
|
|
|
publisher: p.author,
|
|
|
|
description: p.description,
|
|
|
|
image: p.itunes.image.href);
|
2020-07-26 12:20:42 +02:00
|
|
|
var item = SubscribeItem(podcast.rss, podcast.title,
|
2020-07-17 16:44:07 +02:00
|
|
|
imgUrl: podcast.image, group: 'Home');
|
2020-05-09 17:42:13 +02:00
|
|
|
subscribeWorker.setSubscribeItem(item);
|
2020-08-10 20:41:22 +02:00
|
|
|
} catch (e) {
|
|
|
|
developer.log(e.toString(), name: 'Recover podcast error');
|
2020-05-09 17:42:13 +02:00
|
|
|
Fluttertoast.showToast(
|
2020-07-06 11:50:20 +02:00
|
|
|
msg: context.s.toastRecoverFailed,
|
2020-05-09 17:42:13 +02:00
|
|
|
gravity: ToastGravity.BOTTOM,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-14 04:14:24 +01:00
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
_controller = TabController(length: 2, vsync: this);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
_controller.dispose();
|
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
double top = 0;
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2020-07-02 14:58:55 +02:00
|
|
|
final s = context.s;
|
2020-03-14 04:14:24 +01:00
|
|
|
return AnnotatedRegion<SystemUiOverlayStyle>(
|
|
|
|
value: SystemUiOverlayStyle(
|
|
|
|
statusBarIconBrightness: Theme.of(context).accentColorBrightness,
|
|
|
|
systemNavigationBarColor: Theme.of(context).primaryColor,
|
2020-03-19 20:58:30 +01:00
|
|
|
systemNavigationBarIconBrightness:
|
|
|
|
Theme.of(context).accentColorBrightness,
|
2020-03-14 04:14:24 +01:00
|
|
|
),
|
2020-03-19 20:58:30 +01:00
|
|
|
child: Scaffold(
|
2020-09-23 16:19:07 +02:00
|
|
|
backgroundColor: context.primaryColor,
|
2020-03-19 20:58:30 +01:00
|
|
|
body: SafeArea(
|
|
|
|
child: NestedScrollView(
|
2020-07-26 12:20:42 +02:00
|
|
|
headerSliverBuilder: (context, innerBoxScrolled) {
|
2020-03-19 20:58:30 +01:00
|
|
|
return <Widget>[
|
|
|
|
SliverAppBar(
|
|
|
|
backgroundColor: Theme.of(context).primaryColor,
|
2020-10-09 17:59:29 +02:00
|
|
|
leading: CustomBackButton(),
|
2020-03-19 20:58:30 +01:00
|
|
|
elevation: 0,
|
|
|
|
expandedHeight: 260,
|
|
|
|
floating: false,
|
|
|
|
pinned: true,
|
|
|
|
flexibleSpace: LayoutBuilder(
|
2020-07-26 12:20:42 +02:00
|
|
|
builder: (context, constraints) {
|
2020-03-19 20:58:30 +01:00
|
|
|
top = constraints.biggest.height;
|
|
|
|
return FlexibleSpaceBar(
|
|
|
|
title: top < 70 + MediaQuery.of(context).padding.top
|
|
|
|
? Text(
|
2020-07-02 14:58:55 +02:00
|
|
|
s.settingsHistory,
|
2020-03-19 20:58:30 +01:00
|
|
|
)
|
|
|
|
: Center(),
|
|
|
|
background: Padding(
|
|
|
|
padding: EdgeInsets.only(
|
2020-07-08 15:18:08 +02:00
|
|
|
top: 50, left: 20, right: 20, bottom: 20),
|
2020-03-19 20:58:30 +01:00
|
|
|
child: FutureBuilder<List<FlSpot>>(
|
|
|
|
future: getData(),
|
|
|
|
builder: (context, snapshot) {
|
|
|
|
return snapshot.hasData
|
|
|
|
? HistoryChart(snapshot.data)
|
|
|
|
: Center();
|
|
|
|
}),
|
2020-03-14 04:14:24 +01:00
|
|
|
),
|
2020-03-19 20:58:30 +01:00
|
|
|
);
|
|
|
|
},
|
2020-03-14 04:14:24 +01:00
|
|
|
),
|
2020-03-19 20:58:30 +01:00
|
|
|
),
|
|
|
|
SliverPersistentHeader(
|
|
|
|
delegate: _SliverAppBarDelegate(
|
|
|
|
TabBar(
|
|
|
|
controller: _controller,
|
2020-05-09 17:42:13 +02:00
|
|
|
indicatorColor: context.accentColor,
|
2020-07-08 15:18:08 +02:00
|
|
|
labelColor: context.textColor,
|
|
|
|
labelStyle: context.textTheme.headline6,
|
2020-03-19 20:58:30 +01:00
|
|
|
tabs: <Widget>[
|
|
|
|
Tab(
|
2020-07-08 15:18:08 +02:00
|
|
|
child: Text(s.listen),
|
2020-03-19 20:58:30 +01:00
|
|
|
),
|
|
|
|
Tab(
|
2020-07-08 15:18:08 +02:00
|
|
|
child: Text(s.subscribe),
|
2020-03-19 20:58:30 +01:00
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
2020-05-09 17:42:13 +02:00
|
|
|
context.primaryColor),
|
2020-03-19 20:58:30 +01:00
|
|
|
pinned: true,
|
|
|
|
),
|
|
|
|
];
|
|
|
|
},
|
|
|
|
body: TabBarView(controller: _controller, children: <Widget>[
|
|
|
|
FutureBuilder<List<PlayHistory>>(
|
2020-08-16 10:05:18 +02:00
|
|
|
future: _getPlayHistory(_top),
|
2020-03-19 20:58:30 +01:00
|
|
|
builder: (context, snapshot) {
|
2020-09-29 19:25:44 +02:00
|
|
|
var width = context.width;
|
2020-03-19 20:58:30 +01:00
|
|
|
return snapshot.hasData
|
2020-04-02 11:52:26 +02:00
|
|
|
? NotificationListener<ScrollNotification>(
|
2020-07-26 12:20:42 +02:00
|
|
|
onNotification: (scrollInfo) {
|
2020-04-02 11:52:26 +02:00
|
|
|
if (scrollInfo.metrics.pixels ==
|
|
|
|
scrollInfo.metrics.maxScrollExtent &&
|
2020-08-16 10:05:18 +02:00
|
|
|
snapshot.data.length == _top) {
|
|
|
|
if (!_loadMore) {
|
|
|
|
_loadMoreData();
|
|
|
|
}
|
|
|
|
}
|
2020-04-02 11:52:26 +02:00
|
|
|
return true;
|
|
|
|
},
|
|
|
|
child: ListView.builder(
|
|
|
|
scrollDirection: Axis.vertical,
|
2020-08-16 10:05:18 +02:00
|
|
|
itemCount: snapshot.data.length + 1,
|
2020-07-26 12:20:42 +02:00
|
|
|
itemBuilder: (context, index) {
|
2020-08-16 10:05:18 +02:00
|
|
|
if (index == snapshot.data.length) {
|
|
|
|
return SizedBox(
|
|
|
|
height: 2,
|
|
|
|
child: _loadMore
|
|
|
|
? LinearProgressIndicator()
|
|
|
|
: Center());
|
|
|
|
} else {
|
|
|
|
var seekValue =
|
|
|
|
snapshot.data[index].seekValue;
|
|
|
|
var seconds = snapshot.data[index].seconds;
|
|
|
|
return Container(
|
|
|
|
padding:
|
|
|
|
const EdgeInsets.symmetric(vertical: 5),
|
|
|
|
color: context.scaffoldBackgroundColor,
|
|
|
|
child: Column(
|
|
|
|
children: <Widget>[
|
|
|
|
ListTile(
|
|
|
|
title: Column(
|
|
|
|
mainAxisAlignment:
|
|
|
|
MainAxisAlignment.start,
|
|
|
|
crossAxisAlignment:
|
|
|
|
CrossAxisAlignment.start,
|
|
|
|
children: <Widget>[
|
|
|
|
Text(
|
|
|
|
DateFormat.yMd()
|
|
|
|
.add_jm()
|
|
|
|
.format(snapshot
|
|
|
|
.data[index].playdate),
|
2020-07-08 15:18:08 +02:00
|
|
|
style: TextStyle(
|
2020-08-16 10:05:18 +02:00
|
|
|
color: context.textColor
|
|
|
|
.withOpacity(0.8),
|
|
|
|
fontSize: 15,
|
|
|
|
fontStyle:
|
|
|
|
FontStyle.italic),
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
snapshot.data[index].title,
|
|
|
|
maxLines: 2,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
subtitle: Row(
|
|
|
|
children: <Widget>[
|
|
|
|
Icon(
|
|
|
|
Icons.timelapse,
|
|
|
|
color: Colors.grey[400],
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
height: 2,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
border: Border(
|
|
|
|
bottom: BorderSide(
|
|
|
|
color: Colors
|
|
|
|
.grey[400],
|
|
|
|
width: 2.0))),
|
|
|
|
width: width * seekValue <
|
|
|
|
(width - 120)
|
|
|
|
? width * seekValue
|
|
|
|
: width - 120,
|
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
horizontal: 2),
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
width: 50,
|
|
|
|
alignment: Alignment.center,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: context.accentColor,
|
|
|
|
borderRadius:
|
|
|
|
BorderRadius.all(
|
|
|
|
Radius.circular(
|
|
|
|
10))),
|
|
|
|
padding: EdgeInsets.all(2),
|
|
|
|
child: Text(
|
|
|
|
seconds == 0 && seekValue == 1
|
|
|
|
? s.mark
|
|
|
|
: seconds.toInt().toTime,
|
|
|
|
style: TextStyle(
|
|
|
|
color: Colors.white),
|
|
|
|
),
|
2020-04-02 11:52:26 +02:00
|
|
|
),
|
2020-08-16 10:05:18 +02:00
|
|
|
],
|
|
|
|
),
|
2020-04-02 11:52:26 +02:00
|
|
|
),
|
2020-08-16 10:05:18 +02:00
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
2020-04-02 11:52:26 +02:00
|
|
|
}),
|
|
|
|
)
|
2020-03-19 20:58:30 +01:00
|
|
|
: Center(
|
2020-07-08 15:18:08 +02:00
|
|
|
child: SizedBox(
|
|
|
|
height: 25,
|
|
|
|
width: 25,
|
|
|
|
child: CircularProgressIndicator()),
|
2020-03-19 20:58:30 +01:00
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
FutureBuilder<List<SubHistory>>(
|
|
|
|
future: getSubHistory(),
|
|
|
|
builder: (context, snapshot) {
|
|
|
|
return snapshot.hasData
|
|
|
|
? ListView.builder(
|
2020-06-11 17:13:10 +02:00
|
|
|
// shrinkWrap: true,
|
2020-03-19 20:58:30 +01:00
|
|
|
scrollDirection: Axis.vertical,
|
|
|
|
itemCount: snapshot.data.length,
|
2020-07-26 12:20:42 +02:00
|
|
|
itemBuilder: (context, index) {
|
|
|
|
var _status = snapshot.data[index].status;
|
2020-03-19 20:58:30 +01:00
|
|
|
return Container(
|
2020-06-10 18:36:53 +02:00
|
|
|
color: context.scaffoldBackgroundColor,
|
2020-03-19 20:58:30 +01:00
|
|
|
child: Column(
|
2020-03-14 04:14:24 +01:00
|
|
|
children: <Widget>[
|
|
|
|
ListTile(
|
|
|
|
enabled: _status,
|
|
|
|
title: Column(
|
|
|
|
mainAxisAlignment:
|
|
|
|
MainAxisAlignment.start,
|
|
|
|
crossAxisAlignment:
|
|
|
|
CrossAxisAlignment.start,
|
|
|
|
children: <Widget>[
|
|
|
|
Text(
|
|
|
|
DateFormat.yMd().add_jm().format(
|
|
|
|
snapshot.data[index].subDate),
|
|
|
|
style: TextStyle(
|
2020-07-08 15:18:08 +02:00
|
|
|
color: context.textColor
|
|
|
|
.withOpacity(0.8),
|
2020-03-14 04:14:24 +01:00
|
|
|
fontSize: 15,
|
|
|
|
fontStyle: FontStyle.italic),
|
|
|
|
),
|
|
|
|
Text(snapshot.data[index].title),
|
|
|
|
],
|
|
|
|
),
|
2020-06-12 19:56:13 +02:00
|
|
|
subtitle: _status
|
2020-07-06 11:50:20 +02:00
|
|
|
? Text(s.daysAgo(DateTime.now()
|
|
|
|
.difference(
|
|
|
|
snapshot.data[index].subDate)
|
|
|
|
.inDays))
|
2020-06-12 19:56:13 +02:00
|
|
|
: Text(
|
2020-07-06 11:50:20 +02:00
|
|
|
s.removedAt(DateFormat.yMd()
|
|
|
|
.add_jm()
|
|
|
|
.format(snapshot
|
|
|
|
.data[index].delDate)),
|
2020-06-12 19:56:13 +02:00
|
|
|
style: TextStyle(color: Colors.red),
|
|
|
|
),
|
2020-05-09 17:42:13 +02:00
|
|
|
trailing: !_status
|
|
|
|
? Material(
|
|
|
|
color: Colors.transparent,
|
|
|
|
child: IconButton(
|
2020-07-06 11:50:20 +02:00
|
|
|
tooltip: s.recoverSubscribe,
|
2020-05-09 17:42:13 +02:00
|
|
|
icon: Icon(LineIcons
|
|
|
|
.trash_restore_alt_solid),
|
|
|
|
onPressed: () => recoverSub(
|
|
|
|
context,
|
|
|
|
snapshot.data[index].rssUrl),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
: null,
|
2020-03-14 04:14:24 +01:00
|
|
|
),
|
|
|
|
Divider(
|
|
|
|
height: 2,
|
|
|
|
)
|
|
|
|
],
|
2020-03-19 20:58:30 +01:00
|
|
|
),
|
|
|
|
);
|
|
|
|
})
|
|
|
|
: Center(
|
2020-07-08 15:18:08 +02:00
|
|
|
child: SizedBox(
|
|
|
|
height: 25,
|
|
|
|
width: 25,
|
|
|
|
child: CircularProgressIndicator()),
|
2020-03-19 20:58:30 +01:00
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
]),
|
|
|
|
),
|
2020-03-14 04:14:24 +01:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
|
|
|
|
_SliverAppBarDelegate(this._tabBar, this._color);
|
|
|
|
final Color _color;
|
|
|
|
final TabBar _tabBar;
|
|
|
|
|
|
|
|
@override
|
|
|
|
double get minExtent => _tabBar.preferredSize.height;
|
|
|
|
@override
|
|
|
|
double get maxExtent => _tabBar.preferredSize.height;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(
|
|
|
|
BuildContext context, double shrinkOffset, bool overlapsContent) {
|
2020-07-26 12:20:42 +02:00
|
|
|
return Container(
|
2020-03-14 04:14:24 +01:00
|
|
|
color: _color,
|
|
|
|
child: _tabBar,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
bool shouldRebuild(_SliverAppBarDelegate oldDelegate) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class HistoryChart extends StatelessWidget {
|
|
|
|
final List<FlSpot> stats;
|
|
|
|
HistoryChart(this.stats);
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2020-03-19 20:58:30 +01:00
|
|
|
return SafeArea(
|
|
|
|
child: LineChart(
|
|
|
|
LineChartData(
|
|
|
|
backgroundColor: Colors.transparent,
|
|
|
|
gridData: FlGridData(
|
|
|
|
show: true,
|
2020-05-09 17:42:13 +02:00
|
|
|
drawHorizontalLine: false,
|
2020-03-19 20:58:30 +01:00
|
|
|
getDrawingHorizontalLine: (value) {
|
2020-05-09 17:42:13 +02:00
|
|
|
return value % 1000 == 0
|
2020-03-19 20:58:30 +01:00
|
|
|
? FlLine(
|
2020-05-09 17:42:13 +02:00
|
|
|
color: context.brightness == Brightness.light
|
2020-03-19 20:58:30 +01:00
|
|
|
? Colors.grey[400]
|
|
|
|
: Colors.grey[700],
|
2020-05-09 17:42:13 +02:00
|
|
|
strokeWidth: 0,
|
2020-03-19 20:58:30 +01:00
|
|
|
)
|
|
|
|
: FlLine(color: Colors.transparent);
|
2020-03-14 04:14:24 +01:00
|
|
|
},
|
|
|
|
),
|
2020-03-19 20:58:30 +01:00
|
|
|
titlesData: FlTitlesData(
|
|
|
|
show: true,
|
|
|
|
bottomTitles: SideTitles(
|
2020-10-09 06:21:09 +02:00
|
|
|
getTextStyles: (i) => TextStyle(
|
2020-03-19 20:58:30 +01:00
|
|
|
color: const Color(0xff67727d),
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
fontSize: 12,
|
|
|
|
),
|
|
|
|
showTitles: true,
|
|
|
|
reservedSize: 10,
|
|
|
|
getTitles: (value) {
|
|
|
|
return DateFormat.E().format(DateTime.now()
|
|
|
|
.subtract(Duration(days: (7 - value.toInt()))));
|
|
|
|
},
|
|
|
|
margin: 5,
|
2020-03-14 04:14:24 +01:00
|
|
|
),
|
2020-03-19 20:58:30 +01:00
|
|
|
leftTitles: SideTitles(
|
|
|
|
showTitles: true,
|
2020-10-09 06:21:09 +02:00
|
|
|
getTextStyles: (s) => TextStyle(
|
2020-03-19 20:58:30 +01:00
|
|
|
color: const Color(0xff67727d),
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
fontSize: 12,
|
|
|
|
),
|
|
|
|
getTitles: (value) {
|
|
|
|
return value % 60 == 0 && value > 0 ? '${value ~/ 60}h' : '';
|
|
|
|
},
|
|
|
|
reservedSize: 20,
|
|
|
|
margin: 5,
|
2020-03-14 04:14:24 +01:00
|
|
|
),
|
|
|
|
),
|
2020-03-19 20:58:30 +01:00
|
|
|
borderData: FlBorderData(
|
|
|
|
show: false,
|
|
|
|
border: Border(
|
|
|
|
left: BorderSide(color: Colors.red, width: 2),
|
|
|
|
)),
|
2020-07-08 15:18:08 +02:00
|
|
|
lineTouchData: LineTouchData(
|
|
|
|
enabled: true,
|
|
|
|
touchTooltipData: LineTouchTooltipData(
|
|
|
|
tooltipBgColor: context.scaffoldBackgroundColor,
|
|
|
|
fitInsideHorizontally: true,
|
|
|
|
getTooltipItems: (touchedBarSpots) {
|
|
|
|
return touchedBarSpots.map((barSpot) {
|
|
|
|
return LineTooltipItem(context.s.minsCount(barSpot.y.toInt()),
|
|
|
|
context.textTheme.subtitle1);
|
|
|
|
}).toList();
|
|
|
|
},
|
|
|
|
),
|
|
|
|
getTouchedSpotIndicator: (barData, spotIndexes) {
|
|
|
|
return spotIndexes.map((spotIndex) {
|
|
|
|
return TouchedSpotIndicatorData(
|
|
|
|
FlLine(color: Colors.transparent),
|
|
|
|
FlDotData(
|
|
|
|
show: true,
|
|
|
|
getDotPainter: (spot, percent, barData, index) {
|
|
|
|
return FlDotCirclePainter(
|
|
|
|
radius: 3,
|
|
|
|
color: context.accentColor,
|
|
|
|
strokeWidth: 4,
|
|
|
|
strokeColor: context.primaryColor);
|
|
|
|
}));
|
|
|
|
}).toList();
|
|
|
|
},
|
|
|
|
),
|
2020-03-19 20:58:30 +01:00
|
|
|
lineBarsData: [
|
|
|
|
LineChartBarData(
|
2020-07-26 12:20:42 +02:00
|
|
|
spots: stats,
|
2020-07-08 15:18:08 +02:00
|
|
|
isCurved: true,
|
|
|
|
colors: [context.accentColor],
|
|
|
|
preventCurveOverShooting: true,
|
2020-03-19 20:58:30 +01:00
|
|
|
barWidth: 3,
|
|
|
|
isStrokeCapRound: true,
|
2020-05-09 17:42:13 +02:00
|
|
|
belowBarData: BarAreaData(
|
|
|
|
show: true,
|
|
|
|
gradientFrom: Offset(0, 0),
|
|
|
|
gradientTo: Offset(0, 1),
|
|
|
|
gradientColorStops: [
|
|
|
|
0.3,
|
2020-07-08 15:18:08 +02:00
|
|
|
0.8,
|
|
|
|
0.99
|
2020-05-09 17:42:13 +02:00
|
|
|
],
|
|
|
|
colors: [
|
|
|
|
context.accentColor.withOpacity(0.6),
|
2020-07-08 15:18:08 +02:00
|
|
|
context.accentColor.withOpacity(0.1),
|
|
|
|
context.accentColor.withOpacity(0)
|
2020-05-09 17:42:13 +02:00
|
|
|
]),
|
2020-03-19 20:58:30 +01:00
|
|
|
dotData: FlDotData(
|
2020-07-08 15:18:08 +02:00
|
|
|
show: true,
|
|
|
|
getDotPainter: (spot, percent, barData, index) {
|
|
|
|
return FlDotCirclePainter(
|
|
|
|
radius: 2,
|
|
|
|
color: context.primaryColor,
|
|
|
|
strokeWidth: 3,
|
|
|
|
strokeColor: context.accentColor);
|
|
|
|
}),
|
2020-03-19 20:58:30 +01:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2020-03-14 04:14:24 +01:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|