modified: README.md

modified:   lib/episodes/episodedetail.dart
	modified:   lib/home/appbar/importompl.dart
	modified:   lib/home/homescroll.dart
	modified:   lib/podcasts/podcastdetail.dart
	modified:   lib/podcasts/podcastlist.dart
	modified:   lib/util/episodegrid.dart
Change networkcachedimage to localimage
This commit is contained in:
stonegate 2020-02-12 23:16:46 +08:00
parent 55bbb1051b
commit 73fc6135a9
7 changed files with 207 additions and 229 deletions

View File

@ -15,7 +15,7 @@ The podcasts search engine is powered by [ListenNotes](https://listennotes.com).
## License ## License
Tsacdop is under licensed under the [MIT](https://github.com/stonega/tsacdop/blob/master/LICENSE) license. Tsacdop is licensed under the [MIT](https://github.com/stonega/tsacdop/blob/master/LICENSE) license.
## Getting Started ## Getting Started

View File

@ -1,4 +1,3 @@
import 'dart:convert';
import 'dart:math' as math; import 'dart:math' as math;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -53,7 +52,6 @@ class _EpisodeDetailState extends State<EpisodeDetail> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
backgroundColor: Colors.grey[100], backgroundColor: Colors.grey[100],
appBar: AppBar( appBar: AppBar(
@ -97,7 +95,16 @@ class _EpisodeDetailState extends State<EpisodeDetail> {
child: Row( child: Row(
children: <Widget>[ children: <Widget>[
(widget.episodeItem.explicit == 1) (widget.episodeItem.explicit == 1)
? ExplicitScale() ? Container(
decoration: BoxDecoration(
color: Colors.red[800],
shape: BoxShape.circle),
height: 25.0,
width: 25.0,
margin: EdgeInsets.only(right: 10.0),
alignment: Alignment.center,
child: Text('E',
style: TextStyle(color: Colors.white)))
: Center(), : Center(),
Container( Container(
decoration: BoxDecoration( decoration: BoxDecoration(
@ -512,54 +519,4 @@ class _ImageRotateState extends State<ImageRotate>
), ),
); );
} }
} }
class ExplicitScale extends StatefulWidget {
@override
_ExplicitScaleState createState() => _ExplicitScaleState();
}
class _ExplicitScaleState extends State<ExplicitScale>
with SingleTickerProviderStateMixin {
Animation _animation;
AnimationController _controller;
double _value;
@override
void initState() {
super.initState();
_controller = AnimationController(
vsync: this,
duration: Duration(milliseconds: 500),
);
_animation = Tween(begin: 0.0, end: 1.0).animate(_controller)
..addListener(() {
if (mounted)
setState(() {
_value = _animation.value;
});
});
_controller.forward();
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Transform.scale(
scale: _value,
child: Container(
decoration:
BoxDecoration(color: Colors.red[800], shape: BoxShape.circle),
height: 25.0,
width: 25.0,
margin: EdgeInsets.only(right: 10.0),
padding: EdgeInsets.symmetric(horizontal: 10.0),
alignment: Alignment.center,
child: Text('E', style: TextStyle(color: Colors.white))));
}
}

View File

@ -32,7 +32,7 @@ class Import extends StatelessWidget {
padding: EdgeInsets.symmetric(horizontal: 20.0), padding: EdgeInsets.symmetric(horizontal: 20.0),
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
child: child:
Text('Importing: ' + (importOmpl.rsstitle))), Text('Connetting: ' + (importOmpl.rsstitle))),
], ],
) )
: importOmpl.importState == ImportState.parse : importOmpl.importState == ImportState.parse

View File

@ -5,7 +5,6 @@ import 'dart:async';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:path_provider/path_provider.dart'; import 'package:path_provider/path_provider.dart';
import 'package:tsacdop/class/episodebrief.dart'; import 'package:tsacdop/class/episodebrief.dart';
@ -116,8 +115,11 @@ class PodcastPreview extends StatefulWidget {
} }
class _PodcastPreviewState extends State<PodcastPreview> { class _PodcastPreviewState extends State<PodcastPreview> {
String path;
Future<List<EpisodeBrief>> _getRssItemTop(PodcastLocal podcastLocal) async { Future<List<EpisodeBrief>> _getRssItemTop(PodcastLocal podcastLocal) async {
var dbHelper = DBHelper(); var dbHelper = DBHelper();
var dir = await getApplicationDocumentsDirectory();
path = dir.path;
Future<List<EpisodeBrief>> episodes = Future<List<EpisodeBrief>> episodes =
dbHelper.getRssItemTop(podcastLocal.title); dbHelper.getRssItemTop(podcastLocal.title);
return episodes; return episodes;
@ -150,7 +152,9 @@ class _PodcastPreviewState extends State<PodcastPreview> {
return (snapshot.hasData) return (snapshot.hasData)
? ShowEpisode( ? ShowEpisode(
podcast: snapshot.data, podcast: snapshot.data,
podcastLocal: widget.podcastLocal) podcastLocal: widget.podcastLocal,
path: path,
)
: Center(child: CircularProgressIndicator()); : Center(child: CircularProgressIndicator());
}, },
), ),
@ -191,7 +195,9 @@ class _PodcastPreviewState extends State<PodcastPreview> {
class ShowEpisode extends StatelessWidget { class ShowEpisode extends StatelessWidget {
final List<EpisodeBrief> podcast; final List<EpisodeBrief> podcast;
final PodcastLocal podcastLocal; final PodcastLocal podcastLocal;
ShowEpisode({Key key, this.podcast, this.podcastLocal}) : super(key: key); final String path;
ShowEpisode({Key key, this.podcast, this.podcastLocal, this.path})
: super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return CustomScrollView( return CustomScrollView(
@ -222,7 +228,8 @@ class ShowEpisode extends StatelessWidget {
ScaleRoute( ScaleRoute(
page: EpisodeDetail( page: EpisodeDetail(
episodeItem: podcast[index], episodeItem: podcast[index],
heroTag: 'scroll', heroTag: 'scroll',
//unique hero tag
)), )),
); );
}, },
@ -260,9 +267,8 @@ class ShowEpisode extends StatelessWidget {
child: Container( child: Container(
height: 30.0, height: 30.0,
width: 30.0, width: 30.0,
child: CachedNetworkImage( child: Image.file(File(
imageUrl: podcastLocal.imageUrl, "$path/${podcastLocal.title}.png")),
),
), ),
), ),
), ),

View File

@ -19,16 +19,6 @@ class _PodcastDetailState extends State<PodcastDetail> {
final GlobalKey<RefreshIndicatorState> _refreshIndicatorKey = final GlobalKey<RefreshIndicatorState> _refreshIndicatorKey =
GlobalKey<RefreshIndicatorState>(); GlobalKey<RefreshIndicatorState>();
@override
void initState() {
super.initState();
}
@override
void dispose(){
super.dispose();
}
Future _updateRssItem(PodcastLocal podcastLocal) async { Future _updateRssItem(PodcastLocal podcastLocal) async {
var dbHelper = DBHelper(); var dbHelper = DBHelper();
final response = await Dio().get(podcastLocal.rssUrl); final response = await Dio().get(podcastLocal.rssUrl);

View File

@ -1,20 +1,16 @@
import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'dart:async'; import 'dart:async';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter_html/flutter_html.dart'; import 'package:flutter_html/flutter_html.dart';
import 'package:cached_network_image/cached_network_image.dart'; import 'package:path_provider/path_provider.dart';
import 'package:tsacdop/class/podcastlocal.dart'; import 'package:tsacdop/class/podcastlocal.dart';
import 'package:tsacdop/class/sqflite_localpodcast.dart'; import 'package:tsacdop/class/sqflite_localpodcast.dart';
import 'package:tsacdop/podcasts/podcastdetail.dart'; import 'package:tsacdop/podcasts/podcastdetail.dart';
Future<List<PodcastLocal>> getPodcastLocal() async {
var dbHelper = DBHelper();
Future<List<PodcastLocal>> podcastList = dbHelper.getPodcastLocal();
return podcastList;
}
class AboutPodcast extends StatefulWidget { class AboutPodcast extends StatefulWidget {
final PodcastLocal podcastLocal; final PodcastLocal podcastLocal;
AboutPodcast({this.podcastLocal, Key key}) : super(key: key); AboutPodcast({this.podcastLocal, Key key}) : super(key: key);
@ -90,6 +86,14 @@ class PodcastList extends StatefulWidget {
} }
class _PodcastListState extends State<PodcastList> { class _PodcastListState extends State<PodcastList> {
var dir;
Future<List<PodcastLocal>> getPodcastLocal() async {
dir = await getApplicationDocumentsDirectory();
var dbHelper = DBHelper();
Future<List<PodcastLocal>> podcastList = dbHelper.getPodcastLocal();
return podcastList;
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Container(
@ -141,11 +145,8 @@ class _PodcastListState extends State<PodcastList> {
child: Container( child: Container(
height: 120.0, height: 120.0,
width: 120.0, width: 120.0,
child: CachedNetworkImage( child: Image.file(
imageUrl: snapshot.data[index].imageUrl, File("${dir.path}/${snapshot.data[index].title}.png")),
placeholder: (context, url) =>
CircularProgressIndicator(),
),
), ),
), ),
Container( Container(
@ -186,6 +187,7 @@ class Podcast extends StatelessWidget {
appBar: AppBar( appBar: AppBar(
backgroundColor: Colors.grey[100], backgroundColor: Colors.grey[100],
elevation: 0, elevation: 0,
centerTitle: true,
title: Text('Podcasts'), title: Text('Podcasts'),
), ),
body: Container(child: PodcastList()), body: Container(child: PodcastList()),

View File

@ -1,4 +1,5 @@
import 'dart:convert'; import 'dart:convert';
import 'dart:io';
import 'dart:isolate'; import 'dart:isolate';
import 'dart:ui'; import 'dart:ui';
@ -6,6 +7,7 @@ import 'package:flutter/material.dart';
import 'package:cached_network_image/cached_network_image.dart'; import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter_downloader/flutter_downloader.dart'; import 'package:flutter_downloader/flutter_downloader.dart';
import 'package:google_fonts/google_fonts.dart'; import 'package:google_fonts/google_fonts.dart';
import 'package:path_provider/path_provider.dart';
import 'package:tsacdop/class/episodebrief.dart'; import 'package:tsacdop/class/episodebrief.dart';
import 'package:tsacdop/episodes/episodedetail.dart'; import 'package:tsacdop/episodes/episodedetail.dart';
import 'package:tsacdop/util/pageroute.dart'; import 'package:tsacdop/util/pageroute.dart';
@ -24,160 +26,181 @@ class EpisodeGrid extends StatelessWidget {
this.showNumber, this.showNumber,
this.heroTag}) this.heroTag})
: super(key: key); : super(key: key);
Future<String> _getPath() async {
var dir = await getApplicationDocumentsDirectory();
return dir.path;
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return CustomScrollView( return FutureBuilder(
physics: const AlwaysScrollableScrollPhysics(), future: _getPath(),
primary: false, builder: (context, snapshot) {
slivers: <Widget>[ if (snapshot.hasData) {
SliverPadding( return CustomScrollView(
padding: const EdgeInsets.all(5.0), physics: const AlwaysScrollableScrollPhysics(),
sliver: SliverGrid( primary: false,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( slivers: <Widget>[
childAspectRatio: 1.0, SliverPadding(
crossAxisCount: 3, padding: const EdgeInsets.all(5.0),
mainAxisSpacing: 6.0, sliver: SliverGrid(
crossAxisSpacing: 6.0, gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
), childAspectRatio: 1.0,
delegate: SliverChildBuilderDelegate( crossAxisCount: 3,
(BuildContext context, int index) { mainAxisSpacing: 6.0,
Color _c; crossAxisSpacing: 6.0,
var color = json.decode(podcast[index].primaryColor); ),
(color[0] > 200 && color[1] > 200 && color[2] > 200) delegate: SliverChildBuilderDelegate(
? _c = Color.fromRGBO( (BuildContext context, int index) {
(255 - color[0]), 255 - color[1], 255 - color[2], 1.0) Color _c;
: _c = Color.fromRGBO(color[0], color[1], color[2], 1.0); var color = json.decode(podcast[index].primaryColor);
return InkWell( (color[0] > 200 && color[1] > 200 && color[2] > 200)
onTap: () { ? _c = Color.fromRGBO((255 - color[0]),
Navigator.push( 255 - color[1], 255 - color[2], 1.0)
context, : _c = Color.fromRGBO(
ScaleRoute( color[0], color[1], color[2], 1.0);
page: EpisodeDetail( return InkWell(
episodeItem: podcast[index], onTap: () {
heroTag: heroTag Navigator.push(
)), context,
); ScaleRoute(
}, page: EpisodeDetail(
child: Container( episodeItem: podcast[index],
decoration: BoxDecoration( heroTag: heroTag)),
borderRadius: BorderRadius.all(Radius.circular(5.0)), );
color: Theme.of(context).scaffoldBackgroundColor, },
border: Border.all( child: Container(
color: Colors.grey[100], decoration: BoxDecoration(
width: 3.0, borderRadius:
), BorderRadius.all(Radius.circular(5.0)),
boxShadow: [ color:
BoxShadow( Theme.of(context).scaffoldBackgroundColor,
color: Colors.grey[100], border: Border.all(
blurRadius: 1.0, color: Colors.grey[100],
spreadRadius: 0.5, width: 3.0,
),
]),
alignment: Alignment.center,
padding: EdgeInsets.all(8.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Expanded(
flex: 2,
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Hero(
tag: podcast[index].enclosureUrl + heroTag,
child: Container(
child: ClipRRect(
borderRadius:
BorderRadius.all(Radius.circular(15.0)),
child: Container(
height: 30.0,
width: 30.0,
child: CachedNetworkImage(
imageUrl: podcast[index].imageUrl,
),
),
),
), ),
), boxShadow: [
Spacer(), BoxShadow(
showNumber color: Colors.grey[100],
? Container( blurRadius: 1.0,
alignment: Alignment.topRight, spreadRadius: 0.5,
child: Text( ),
(podcast.length - index).toString(), ]),
style: GoogleFonts.teko( alignment: Alignment.center,
textStyle: TextStyle( padding: EdgeInsets.all(8.0),
fontSize: 20.0, child: Column(
color: _c, mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Expanded(
flex: 2,
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Hero(
tag: podcast[index].enclosureUrl +
heroTag,
child: Container(
child: ClipRRect(
borderRadius: BorderRadius.all(
Radius.circular(15.0)),
child: Container(
height: 30.0,
width: 30.0,
child: Image.file(File(
"${snapshot.data}/${podcast[index].feedTitle}.png")),
),
), ),
), ),
), ),
) Spacer(),
: Center(), showNumber
], ? Container(
), alignment: Alignment.topRight,
), child: Text(
Expanded( (podcast.length - index)
flex: 5, .toString(),
child: Container( style: GoogleFonts.teko(
alignment: Alignment.topLeft, textStyle: TextStyle(
padding: EdgeInsets.only(top: 2.0), fontSize: 20.0,
child: Text( color: _c,
podcast[index].title, ),
style: TextStyle( ),
fontSize: 15.0, ),
), )
maxLines: 4, : Center(),
],
),
),
Expanded(
flex: 5,
child: Container(
alignment: Alignment.topLeft,
padding: EdgeInsets.only(top: 2.0),
child: Text(
podcast[index].title,
style: TextStyle(
fontSize: 15.0,
),
maxLines: 4,
),
),
),
Expanded(
flex: 1,
child: Row(
children: <Widget>[
Align(
alignment: Alignment.bottomLeft,
child: Text(
podcast[index]
.pubDate
.substring(4, 16),
style: TextStyle(
color: _c,
fontStyle: FontStyle.italic),
),
),
Spacer(),
showDownload
? DownloadIcon(
episodeBrief: podcast[index])
: Center(),
Padding(
padding: EdgeInsets.all(1),
),
showFavorite
? Container(
alignment: Alignment.bottomRight,
child: (podcast[index].liked == 0)
? Center()
: IconTheme(
data: IconThemeData(
size: 15),
child: Icon(
Icons.favorite,
color: Colors.red,
),
),
)
: Center(),
],
),
),
],
), ),
), ),
), );
Expanded( },
flex: 1, childCount: podcast.length,
child: Row(
children: <Widget>[
Align(
alignment: Alignment.bottomLeft,
child: Text(
podcast[index].pubDate.substring(4, 16),
style: TextStyle(
color: _c, fontStyle: FontStyle.italic),
),
),
Spacer(),
showDownload
? DownloadIcon(episodeBrief: podcast[index])
: Center(),
Padding(
padding: EdgeInsets.all(1),
),
showFavorite
? Container(
alignment: Alignment.bottomRight,
child: (podcast[index].liked == 0)
? Center()
: IconTheme(
data: IconThemeData(size: 15),
child: Icon(
Icons.favorite,
color: Colors.red,
),
),
)
: Center(),
],
),
),
],
), ),
), ),
); ),
}, ],
childCount: podcast.length, );
), }
), return Center();
), });
],
);
} }
} }