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:
parent
55bbb1051b
commit
73fc6135a9
|
@ -15,7 +15,7 @@ The podcasts search engine is powered by [ListenNotes](https://listennotes.com).
|
|||
|
||||
## 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
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import 'dart:convert';
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
@ -53,7 +52,6 @@ class _EpisodeDetailState extends State<EpisodeDetail> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.grey[100],
|
||||
appBar: AppBar(
|
||||
|
@ -97,7 +95,16 @@ class _EpisodeDetailState extends State<EpisodeDetail> {
|
|||
child: Row(
|
||||
children: <Widget>[
|
||||
(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(),
|
||||
Container(
|
||||
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))));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -32,7 +32,7 @@ class Import extends StatelessWidget {
|
|||
padding: EdgeInsets.symmetric(horizontal: 20.0),
|
||||
alignment: Alignment.centerLeft,
|
||||
child:
|
||||
Text('Importing: ' + (importOmpl.rsstitle))),
|
||||
Text('Connetting: ' + (importOmpl.rsstitle))),
|
||||
],
|
||||
)
|
||||
: importOmpl.importState == ImportState.parse
|
||||
|
|
|
@ -5,7 +5,6 @@ import 'dart:async';
|
|||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
import 'package:tsacdop/class/episodebrief.dart';
|
||||
|
@ -116,8 +115,11 @@ class PodcastPreview extends StatefulWidget {
|
|||
}
|
||||
|
||||
class _PodcastPreviewState extends State<PodcastPreview> {
|
||||
String path;
|
||||
Future<List<EpisodeBrief>> _getRssItemTop(PodcastLocal podcastLocal) async {
|
||||
var dbHelper = DBHelper();
|
||||
var dir = await getApplicationDocumentsDirectory();
|
||||
path = dir.path;
|
||||
Future<List<EpisodeBrief>> episodes =
|
||||
dbHelper.getRssItemTop(podcastLocal.title);
|
||||
return episodes;
|
||||
|
@ -150,7 +152,9 @@ class _PodcastPreviewState extends State<PodcastPreview> {
|
|||
return (snapshot.hasData)
|
||||
? ShowEpisode(
|
||||
podcast: snapshot.data,
|
||||
podcastLocal: widget.podcastLocal)
|
||||
podcastLocal: widget.podcastLocal,
|
||||
path: path,
|
||||
)
|
||||
: Center(child: CircularProgressIndicator());
|
||||
},
|
||||
),
|
||||
|
@ -191,7 +195,9 @@ class _PodcastPreviewState extends State<PodcastPreview> {
|
|||
class ShowEpisode extends StatelessWidget {
|
||||
final List<EpisodeBrief> podcast;
|
||||
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
|
||||
Widget build(BuildContext context) {
|
||||
return CustomScrollView(
|
||||
|
@ -222,7 +228,8 @@ class ShowEpisode extends StatelessWidget {
|
|||
ScaleRoute(
|
||||
page: EpisodeDetail(
|
||||
episodeItem: podcast[index],
|
||||
heroTag: 'scroll',
|
||||
heroTag: 'scroll',
|
||||
//unique hero tag
|
||||
)),
|
||||
);
|
||||
},
|
||||
|
@ -260,9 +267,8 @@ class ShowEpisode extends StatelessWidget {
|
|||
child: Container(
|
||||
height: 30.0,
|
||||
width: 30.0,
|
||||
child: CachedNetworkImage(
|
||||
imageUrl: podcastLocal.imageUrl,
|
||||
),
|
||||
child: Image.file(File(
|
||||
"$path/${podcastLocal.title}.png")),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
@ -19,16 +19,6 @@ class _PodcastDetailState extends State<PodcastDetail> {
|
|||
final GlobalKey<RefreshIndicatorState> _refreshIndicatorKey =
|
||||
GlobalKey<RefreshIndicatorState>();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose(){
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Future _updateRssItem(PodcastLocal podcastLocal) async {
|
||||
var dbHelper = DBHelper();
|
||||
final response = await Dio().get(podcastLocal.rssUrl);
|
||||
|
|
|
@ -1,20 +1,16 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'dart:async';
|
||||
import 'package:flutter/foundation.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/sqflite_localpodcast.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 {
|
||||
final PodcastLocal podcastLocal;
|
||||
AboutPodcast({this.podcastLocal, Key key}) : super(key: key);
|
||||
|
@ -90,6 +86,14 @@ class PodcastList extends StatefulWidget {
|
|||
}
|
||||
|
||||
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
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
|
@ -141,11 +145,8 @@ class _PodcastListState extends State<PodcastList> {
|
|||
child: Container(
|
||||
height: 120.0,
|
||||
width: 120.0,
|
||||
child: CachedNetworkImage(
|
||||
imageUrl: snapshot.data[index].imageUrl,
|
||||
placeholder: (context, url) =>
|
||||
CircularProgressIndicator(),
|
||||
),
|
||||
child: Image.file(
|
||||
File("${dir.path}/${snapshot.data[index].title}.png")),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
|
@ -186,6 +187,7 @@ class Podcast extends StatelessWidget {
|
|||
appBar: AppBar(
|
||||
backgroundColor: Colors.grey[100],
|
||||
elevation: 0,
|
||||
centerTitle: true,
|
||||
title: Text('Podcasts'),
|
||||
),
|
||||
body: Container(child: PodcastList()),
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'dart:isolate';
|
||||
import 'dart:ui';
|
||||
|
||||
|
@ -6,6 +7,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter_downloader/flutter_downloader.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:tsacdop/class/episodebrief.dart';
|
||||
import 'package:tsacdop/episodes/episodedetail.dart';
|
||||
import 'package:tsacdop/util/pageroute.dart';
|
||||
|
@ -24,160 +26,181 @@ class EpisodeGrid extends StatelessWidget {
|
|||
this.showNumber,
|
||||
this.heroTag})
|
||||
: super(key: key);
|
||||
|
||||
Future<String> _getPath() async {
|
||||
var dir = await getApplicationDocumentsDirectory();
|
||||
return dir.path;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CustomScrollView(
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
primary: false,
|
||||
slivers: <Widget>[
|
||||
SliverPadding(
|
||||
padding: const EdgeInsets.all(5.0),
|
||||
sliver: SliverGrid(
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
childAspectRatio: 1.0,
|
||||
crossAxisCount: 3,
|
||||
mainAxisSpacing: 6.0,
|
||||
crossAxisSpacing: 6.0,
|
||||
),
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(BuildContext context, int index) {
|
||||
Color _c;
|
||||
var color = json.decode(podcast[index].primaryColor);
|
||||
(color[0] > 200 && color[1] > 200 && color[2] > 200)
|
||||
? _c = Color.fromRGBO(
|
||||
(255 - color[0]), 255 - color[1], 255 - color[2], 1.0)
|
||||
: _c = Color.fromRGBO(color[0], color[1], color[2], 1.0);
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
ScaleRoute(
|
||||
page: EpisodeDetail(
|
||||
episodeItem: podcast[index],
|
||||
heroTag: heroTag
|
||||
)),
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.all(Radius.circular(5.0)),
|
||||
color: Theme.of(context).scaffoldBackgroundColor,
|
||||
border: Border.all(
|
||||
color: Colors.grey[100],
|
||||
width: 3.0,
|
||||
),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey[100],
|
||||
blurRadius: 1.0,
|
||||
spreadRadius: 0.5,
|
||||
),
|
||||
]),
|
||||
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,
|
||||
),
|
||||
),
|
||||
),
|
||||
return FutureBuilder(
|
||||
future: _getPath(),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
return CustomScrollView(
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
primary: false,
|
||||
slivers: <Widget>[
|
||||
SliverPadding(
|
||||
padding: const EdgeInsets.all(5.0),
|
||||
sliver: SliverGrid(
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
childAspectRatio: 1.0,
|
||||
crossAxisCount: 3,
|
||||
mainAxisSpacing: 6.0,
|
||||
crossAxisSpacing: 6.0,
|
||||
),
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(BuildContext context, int index) {
|
||||
Color _c;
|
||||
var color = json.decode(podcast[index].primaryColor);
|
||||
(color[0] > 200 && color[1] > 200 && color[2] > 200)
|
||||
? _c = Color.fromRGBO((255 - color[0]),
|
||||
255 - color[1], 255 - color[2], 1.0)
|
||||
: _c = Color.fromRGBO(
|
||||
color[0], color[1], color[2], 1.0);
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
ScaleRoute(
|
||||
page: EpisodeDetail(
|
||||
episodeItem: podcast[index],
|
||||
heroTag: heroTag)),
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius:
|
||||
BorderRadius.all(Radius.circular(5.0)),
|
||||
color:
|
||||
Theme.of(context).scaffoldBackgroundColor,
|
||||
border: Border.all(
|
||||
color: Colors.grey[100],
|
||||
width: 3.0,
|
||||
),
|
||||
),
|
||||
Spacer(),
|
||||
showNumber
|
||||
? Container(
|
||||
alignment: Alignment.topRight,
|
||||
child: Text(
|
||||
(podcast.length - index).toString(),
|
||||
style: GoogleFonts.teko(
|
||||
textStyle: TextStyle(
|
||||
fontSize: 20.0,
|
||||
color: _c,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey[100],
|
||||
blurRadius: 1.0,
|
||||
spreadRadius: 0.5,
|
||||
),
|
||||
]),
|
||||
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: Image.file(File(
|
||||
"${snapshot.data}/${podcast[index].feedTitle}.png")),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
: 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,
|
||||
Spacer(),
|
||||
showNumber
|
||||
? Container(
|
||||
alignment: Alignment.topRight,
|
||||
child: Text(
|
||||
(podcast.length - index)
|
||||
.toString(),
|
||||
style: GoogleFonts.teko(
|
||||
textStyle: TextStyle(
|
||||
fontSize: 20.0,
|
||||
color: _c,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
: 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,
|
||||
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,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
childCount: podcast.length,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
return Center();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue