Minor change.

This commit is contained in:
stonegate 2020-08-16 16:05:18 +08:00
parent 017e15b129
commit 626763850b
6 changed files with 143 additions and 119 deletions

View File

@ -1,5 +1,4 @@
import 'dart:developer' as developer;
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
@ -75,7 +74,6 @@ class _EpisodeDetailState extends State<EpisodeDetail> {
super.initState();
_showMenu = true;
_showTitle = false;
//_getSDescription(widget.episodeItem.enclosureUrl);
_controller = ScrollController();
_controller.addListener(_scrollListener);
}
@ -220,7 +218,7 @@ class _EpisodeDetailState extends State<EpisodeDetail> {
color: Colors.cyan[300],
borderRadius: BorderRadius.all(
Radius.circular(16.0))),
height: 32.0,
height: 28.0,
margin: EdgeInsets.only(right: 10.0),
padding:
EdgeInsets.symmetric(horizontal: 10.0),
@ -236,7 +234,7 @@ class _EpisodeDetailState extends State<EpisodeDetail> {
color: Colors.lightBlue[300],
borderRadius: BorderRadius.all(
Radius.circular(16.0))),
height: 32.0,
height: 28.0,
margin: EdgeInsets.only(right: 10.0),
padding: EdgeInsets.symmetric(horizontal: 10.0),
alignment: Alignment.center,
@ -253,32 +251,38 @@ class _EpisodeDetailState extends State<EpisodeDetail> {
if (snapshot.hasData &&
snapshot.data.seekValue < 0.9 &&
snapshot.data.seconds > 10) {
return OutlineButton(
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(100.0),
side: BorderSide(
color: context.accentColor)),
highlightedBorderColor: Colors.green[700],
onPressed: () => audio.episodeLoad(
widget.episodeItem,
startPosition:
(snapshot.data.seconds * 1000)
.toInt()),
child: Row(
children: [
SizedBox(
width: 20,
height: 20,
child: CustomPaint(
painter: ListenedPainter(
context.textColor,
stroke: 2.0),
return ButtonTheme(
height: 28,
padding:
EdgeInsets.symmetric(horizontal: 0),
child: OutlineButton(
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(100.0),
side: BorderSide(
color: context.accentColor)),
highlightedBorderColor:
Colors.green[700],
onPressed: () => audio.episodeLoad(
widget.episodeItem,
startPosition:
(snapshot.data.seconds * 1000)
.toInt()),
child: Row(
children: [
SizedBox(
width: 20,
height: 20,
child: CustomPaint(
painter: ListenedPainter(
context.textColor,
stroke: 2.0),
),
),
),
SizedBox(width: 5),
Text(snapshot.data.seconds.toTime),
],
SizedBox(width: 5),
Text(snapshot.data.seconds.toTime),
],
),
),
);
} else {

View File

@ -1,5 +1,3 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_downloader/flutter_downloader.dart';
import 'package:provider/provider.dart';

View File

@ -1,5 +1,4 @@
import 'dart:async';
import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

View File

@ -24,7 +24,8 @@ class PlayedHistory extends StatefulWidget {
class _PlayedHistoryState extends State<PlayedHistory>
with SingleTickerProviderStateMixin {
Future<List<PlayHistory>> getPlayHistory(int top) async {
/// Get play history.
Future<List<PlayHistory>> _getPlayHistory(int top) async {
var dbHelper = DBHelper();
List<PlayHistory> playHistory;
playHistory = await dbHelper.getPlayHistory(top);
@ -34,16 +35,24 @@ class _PlayedHistoryState extends State<PlayedHistory>
return playHistory;
}
bool _loadMore = false;
_loadMoreData() async {
// await Future.delayed(Duration(seconds: 3));
if (mounted) {
setState(() {
_top = _top + 100;
_loadMore = true;
});
}
await Future.delayed(Duration(milliseconds: 500));
if (mounted) {
setState(() {
_top = _top + 10;
_loadMore = false;
});
}
}
int _top = 100;
int _top = 10;
Future<List<SubHistory>> getSubHistory() async {
var dbHelper = DBHelper();
@ -177,100 +186,115 @@ class _PlayedHistoryState extends State<PlayedHistory>
},
body: TabBarView(controller: _controller, children: <Widget>[
FutureBuilder<List<PlayHistory>>(
future: getPlayHistory(_top),
future: _getPlayHistory(_top),
builder: (context, snapshot) {
var _width = MediaQuery.of(context).size.width;
var width = MediaQuery.of(context).size.width;
return snapshot.hasData
? NotificationListener<ScrollNotification>(
onNotification: (scrollInfo) {
if (scrollInfo.metrics.pixels ==
scrollInfo.metrics.maxScrollExtent &&
snapshot.data.length == _top) _loadMoreData();
snapshot.data.length == _top) {
if (!_loadMore) {
_loadMoreData();
}
}
return true;
},
child: ListView.builder(
//shrinkWrap: true,
scrollDirection: Axis.vertical,
itemCount: snapshot.data.length,
itemCount: snapshot.data.length + 1,
itemBuilder: (context, index) {
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),
style: TextStyle(
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,
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),
style: TextStyle(
color: Colors.white),
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),
),
),
],
),
),
),
],
),
);
],
),
);
}
}),
)
: Center(

View File

@ -25,7 +25,7 @@ class PlayHistory {
EpisodeBrief _episode;
EpisodeBrief get episode => _episode;
getEpisode() async {
Future<void> getEpisode() async {
_episode = await _dbHelper.getRssItemWithUrl(url);
}
}

View File

@ -1,9 +1,8 @@
import 'dart:io';
import 'dart:math' as math;
import 'package:flutter/material.dart';
import 'package:tsacdop/type/episodebrief.dart';
import '../type/episodebrief.dart';
import 'episodegrid.dart';
import 'extension_helper.dart';