diff --git a/lib/episodedetail.dart b/lib/episodes/episodedetail.dart similarity index 99% rename from lib/episodedetail.dart rename to lib/episodes/episodedetail.dart index dd32837..eaa48a3 100644 --- a/lib/episodedetail.dart +++ b/lib/episodes/episodedetail.dart @@ -6,10 +6,9 @@ import 'package:provider/provider.dart'; import 'package:flutter_html/flutter_html.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:url_launcher/url_launcher.dart'; - -import 'class/audiostate.dart'; -import 'class/episodebrief.dart'; -import 'class/sqflite_localpodcast.dart'; +import 'package:tsacdop/class/audiostate.dart'; +import 'package:tsacdop/class/episodebrief.dart'; +import 'package:tsacdop/class/sqflite_localpodcast.dart'; import 'episodedownload.dart'; enum DownloadState { stop, load, donwload, complete, error } diff --git a/lib/episodedownload.dart b/lib/episodes/episodedownload.dart similarity index 98% rename from lib/episodedownload.dart rename to lib/episodes/episodedownload.dart index 1d981d9..936d7ae 100644 --- a/lib/episodedownload.dart +++ b/lib/episodes/episodedownload.dart @@ -8,8 +8,8 @@ import 'package:path_provider/path_provider.dart'; import 'package:flutter_downloader/flutter_downloader.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:fluttertoast/fluttertoast.dart'; -import 'class/episodebrief.dart'; -import 'class/sqflite_localpodcast.dart'; +import 'package:tsacdop/class/episodebrief.dart'; +import 'package:tsacdop/class/sqflite_localpodcast.dart'; class DownloadButton extends StatefulWidget { final EpisodeBrief episodeBrief; diff --git a/lib/about.dart b/lib/home/appbar/about.dart similarity index 100% rename from lib/about.dart rename to lib/home/appbar/about.dart diff --git a/lib/addpodcast.dart b/lib/home/appbar/addpodcast.dart similarity index 79% rename from lib/addpodcast.dart rename to lib/home/appbar/addpodcast.dart index 56c0cb5..6398960 100644 --- a/lib/addpodcast.dart +++ b/lib/home/appbar/addpodcast.dart @@ -1,20 +1,21 @@ import 'dart:io'; +import 'dart:convert'; +import 'dart:async'; import 'package:flutter/material.dart'; import 'package:color_thief_flutter/color_thief_flutter.dart'; -import 'class/importompl.dart'; import 'package:dio/dio.dart'; import 'package:provider/provider.dart'; import 'package:path_provider/path_provider.dart'; import 'package:image/image.dart' as img; -import 'dart:convert'; -import 'dart:async'; -import 'class/searchpodcast.dart'; -import 'class/podcastlocal.dart'; -import 'class/sqflite_localpodcast.dart'; -import 'home.dart'; + +import 'package:tsacdop/class/importompl.dart'; +import 'package:tsacdop/class/searchpodcast.dart'; +import 'package:tsacdop/class/podcastlocal.dart'; +import 'package:tsacdop/class/sqflite_localpodcast.dart'; +import 'package:tsacdop/home/home.dart'; import 'popupmenu.dart'; -import 'webfeed/webfeed.dart'; +import 'package:tsacdop/webfeed/webfeed.dart'; class MyHomePage extends StatefulWidget { @override @@ -142,7 +143,7 @@ class _MyHomePageDelegate extends SearchDelegate { margin: EdgeInsets.only(top: 400), child: SizedBox( height: 10, - child: Image.asset( + child: Image.asset( 'assets/listennote.png', fit: BoxFit.fill, ), @@ -203,52 +204,49 @@ class _SearchResultState extends State { return primaryColor; } - @override Widget build(BuildContext context) { final importOmpl = Provider.of(context); savePodcast(String rss) async { - print(rss); - if (mounted) setState(() => _adding = true); - - importOmpl.importState = - ImportState.import; + print(rss); + if (mounted) setState(() => _adding = true); - Response response = await Dio().get(rss); - if (mounted) setState(() => _issubscribe = true); + importOmpl.importState = ImportState.import; - var _p = RssFeed.parse(response.data); + Response response = await Dio().get(rss); + if (mounted) setState(() => _issubscribe = true); - print(_p.title); - var dir = await getApplicationDocumentsDirectory(); + var _p = RssFeed.parse(response.data); - Response> imageResponse = await Dio().get>( - _p.itunes.image.href, - options: Options(responseType: ResponseType.bytes)); + print(_p.title); + var dir = await getApplicationDocumentsDirectory(); - img.Image image = img.decodeImage(imageResponse.data); - img.Image thumbnail = img.copyResize(image, width: 300); - File("${dir.path}/${_p.title}.png") - ..writeAsBytesSync(img.encodePng(thumbnail)); + Response> imageResponse = await Dio().get>( + _p.itunes.image.href, + options: Options(responseType: ResponseType.bytes)); - String _primaryColor = await getColor(File("${dir.path}/${_p.title}.png")); - PodcastLocal podcastLocal = PodcastLocal( - _p.title, _p.itunes.image.href, rss, _primaryColor, _p.author); - podcastLocal.description = _p.description; + img.Image image = img.decodeImage(imageResponse.data); + img.Image thumbnail = img.copyResize(image, width: 300); + File("${dir.path}/${_p.title}.png") + ..writeAsBytesSync(img.encodePng(thumbnail)); + + String _primaryColor = + await getColor(File("${dir.path}/${_p.title}.png")); + PodcastLocal podcastLocal = PodcastLocal( + _p.title, _p.itunes.image.href, rss, _primaryColor, _p.author); + podcastLocal.description = _p.description; var dbHelper = DBHelper(); - await dbHelper.savePodcastLocal(podcastLocal); + await dbHelper.savePodcastLocal(podcastLocal); - importOmpl.importState = - ImportState.parse; + importOmpl.importState = ImportState.parse; - await dbHelper.savePodcastRss(response.data); + await dbHelper.savePodcastRss(response.data); + + importOmpl.importState = ImportState.complete; + importOmpl.importState = ImportState.stop; + print('fatch data'); + } - importOmpl.importState = - ImportState.complete; - importOmpl.importState = - ImportState.stop; - print('fatch data'); - } return Container( padding: EdgeInsets.symmetric(horizontal: 12.0), child: ListTile( @@ -270,9 +268,8 @@ class _SearchResultState extends State { child: Text('Subscribe', style: TextStyle(color: Colors.blue)), onPressed: () { - importOmpl.rssTitle = - widget.onlinePodcast.title; - savePodcast(widget.onlinePodcast.rss); + importOmpl.rssTitle = widget.onlinePodcast.title; + savePodcast(widget.onlinePodcast.rss); }) : OutlineButton( child: SizedBox( diff --git a/lib/importompl.dart b/lib/home/appbar/importompl.dart similarity index 63% rename from lib/importompl.dart rename to lib/home/appbar/importompl.dart index 367ba75..b52cd6c 100644 --- a/lib/importompl.dart +++ b/lib/home/appbar/importompl.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; -import 'class/importompl.dart'; +import 'package:tsacdop/class/importompl.dart'; class Import extends StatelessWidget { @override @@ -13,9 +13,7 @@ class Import extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ - SizedBox( - height: 2.0, - child: LinearProgressIndicator()), + SizedBox(height: 2.0, child: LinearProgressIndicator()), Container( padding: EdgeInsets.symmetric(horizontal: 20.0), height: 20.0, @@ -28,9 +26,7 @@ class Import extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ - SizedBox( - height: 2.0, - child: LinearProgressIndicator()), + SizedBox(height: 2.0, child: LinearProgressIndicator()), Container( height: 20.0, padding: EdgeInsets.symmetric(horizontal: 20.0), @@ -45,8 +41,7 @@ class Import extends StatelessWidget { mainAxisSize: MainAxisSize.min, children: [ SizedBox( - height: 2.0, - child: LinearProgressIndicator()), + height: 2.0, child: LinearProgressIndicator()), Container( height: 20.0, padding: EdgeInsets.symmetric(horizontal: 20.0), @@ -55,23 +50,25 @@ class Import extends StatelessWidget { ), ], ) - : importOmpl.importState == ImportState.error - ? Column( - mainAxisAlignment: MainAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - SizedBox( - height: 2.0, - child: LinearProgressIndicator()), - Container( - height: 20.0, - padding: EdgeInsets.symmetric(horizontal: 20.0), - alignment: Alignment.centerLeft, - child: Text('Error: ' + (importOmpl.rsstitle)), - ), - ], - ) - : Center()), + : importOmpl.importState == ImportState.error + ? Column( + mainAxisAlignment: MainAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + SizedBox( + height: 2.0, + child: LinearProgressIndicator()), + Container( + height: 20.0, + padding: + EdgeInsets.symmetric(horizontal: 20.0), + alignment: Alignment.centerLeft, + child: + Text('Error: ' + (importOmpl.rsstitle)), + ), + ], + ) + : Center()), ); } } diff --git a/lib/popupmenu.dart b/lib/home/appbar/popupmenu.dart similarity index 95% rename from lib/popupmenu.dart rename to lib/home/appbar/popupmenu.dart index 342ed78..e4566b0 100644 --- a/lib/popupmenu.dart +++ b/lib/home/appbar/popupmenu.dart @@ -1,5 +1,6 @@ import 'dart:io'; import 'dart:async'; + import 'package:flutter/material.dart'; import 'package:dio/dio.dart'; import 'package:provider/provider.dart'; @@ -9,11 +10,12 @@ import 'package:flutter/services.dart'; import 'package:path_provider/path_provider.dart'; import 'package:color_thief_flutter/color_thief_flutter.dart'; import 'package:image/image.dart' as img; + import 'about.dart'; -import 'class/podcastlocal.dart'; -import 'class/sqflite_localpodcast.dart'; -import 'class/importompl.dart'; -import 'webfeed/webfeed.dart'; +import 'package:tsacdop/class/podcastlocal.dart'; +import 'package:tsacdop/class/sqflite_localpodcast.dart'; +import 'package:tsacdop/class/importompl.dart'; +import 'package:tsacdop/webfeed/webfeed.dart'; class OmplOutline { final String text; diff --git a/lib/audio_player.dart b/lib/home/audio_player.dart similarity index 99% rename from lib/audio_player.dart rename to lib/home/audio_player.dart index 22d0718..69ddfcb 100644 --- a/lib/audio_player.dart +++ b/lib/home/audio_player.dart @@ -10,7 +10,7 @@ import 'package:logging/logging.dart'; import 'package:flutter/material.dart'; import 'package:marquee/marquee.dart'; import 'package:flutter_downloader/flutter_downloader.dart'; -import 'class/audiostate.dart'; +import 'package:tsacdop/class/audiostate.dart'; final Logger _logger = Logger('audiofileplayer'); diff --git a/lib/home.dart b/lib/home/home.dart similarity index 90% rename from lib/home.dart rename to lib/home/home.dart index 5bf5c84..b6c30b6 100644 --- a/lib/home.dart +++ b/lib/home/home.dart @@ -1,11 +1,12 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'podcastlist.dart'; + +import '../podcasts/podcastlist.dart'; import 'hometab.dart'; -import 'importompl.dart'; +import 'package:tsacdop/home/appbar/importompl.dart'; import 'audio_player.dart'; import 'homescroll.dart'; -import 'pageroute.dart'; +import 'package:tsacdop/util/pageroute.dart'; class Home extends StatefulWidget { @override diff --git a/lib/homescroll.dart b/lib/home/homescroll.dart similarity index 97% rename from lib/homescroll.dart rename to lib/home/homescroll.dart index 68a334d..c540761 100644 --- a/lib/homescroll.dart +++ b/lib/home/homescroll.dart @@ -8,14 +8,14 @@ import 'package:provider/provider.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:path_provider/path_provider.dart'; -import 'class/episodebrief.dart'; -import 'class/podcastlocal.dart'; -import 'class/importompl.dart'; -import 'class/sqflite_localpodcast.dart'; +import 'package:tsacdop/class/episodebrief.dart'; +import 'package:tsacdop/class/podcastlocal.dart'; +import 'package:tsacdop/class/importompl.dart'; +import 'package:tsacdop/class/sqflite_localpodcast.dart'; -import 'episodedetail.dart'; -import 'podcastdetail.dart'; -import 'pageroute.dart'; +import 'package:tsacdop/episodes/episodedetail.dart'; +import 'package:tsacdop/podcasts/podcastdetail.dart'; +import 'package:tsacdop/util/pageroute.dart'; class ScrollPodcasts extends StatefulWidget { @override diff --git a/lib/hometab.dart b/lib/home/hometab.dart similarity index 96% rename from lib/hometab.dart rename to lib/home/hometab.dart index df953c3..09cd168 100644 --- a/lib/hometab.dart +++ b/lib/home/hometab.dart @@ -1,9 +1,9 @@ import 'dart:ui'; import 'package:flutter/material.dart'; -import 'class/episodebrief.dart'; -import 'class/sqflite_localpodcast.dart'; -import 'episodegrid.dart'; +import 'package:tsacdop/class/episodebrief.dart'; +import 'package:tsacdop/class/sqflite_localpodcast.dart'; +import 'package:tsacdop/util/episodegrid.dart'; class MainTab extends StatefulWidget { @override diff --git a/lib/main.dart b/lib/main.dart index 08ca83f..3165788 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -2,9 +2,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_statusbarcolor/flutter_statusbarcolor.dart'; import 'package:provider/provider.dart'; import 'package:flutter_downloader/flutter_downloader.dart'; -import 'addpodcast.dart'; -import 'class/audiostate.dart'; -import 'class/importompl.dart'; +import 'package:tsacdop/home/appbar/addpodcast.dart'; +import 'package:tsacdop/class/audiostate.dart'; +import 'package:tsacdop/class/importompl.dart'; void main() async { runApp( diff --git a/lib/podcastdetail.dart b/lib/podcasts/podcastdetail.dart similarity index 90% rename from lib/podcastdetail.dart rename to lib/podcasts/podcastdetail.dart index cba155f..c5c06af 100644 --- a/lib/podcastdetail.dart +++ b/lib/podcasts/podcastdetail.dart @@ -3,10 +3,10 @@ import 'package:flutter/material.dart'; import 'package:dio/dio.dart'; import 'dart:async'; -import 'class/podcastlocal.dart'; -import 'class/episodebrief.dart'; -import 'class/sqflite_localpodcast.dart'; -import 'episodegrid.dart'; +import 'package:tsacdop/class/podcastlocal.dart'; +import 'package:tsacdop/class/episodebrief.dart'; +import 'package:tsacdop/class/sqflite_localpodcast.dart'; +import 'package:tsacdop/util/episodegrid.dart'; class PodcastDetail extends StatefulWidget { PodcastDetail({Key key, this.podcastLocal}) : super(key: key); diff --git a/lib/podcastlist.dart b/lib/podcasts/podcastlist.dart similarity index 97% rename from lib/podcastlist.dart rename to lib/podcasts/podcastlist.dart index 323a85b..095f051 100644 --- a/lib/podcastlist.dart +++ b/lib/podcasts/podcastlist.dart @@ -5,9 +5,9 @@ import 'package:flutter/foundation.dart'; import 'package:flutter_html/flutter_html.dart'; import 'package:cached_network_image/cached_network_image.dart'; -import 'class/podcastlocal.dart'; -import 'class/sqflite_localpodcast.dart'; -import 'podcastdetail.dart'; +import 'package:tsacdop/class/podcastlocal.dart'; +import 'package:tsacdop/class/sqflite_localpodcast.dart'; +import 'package:tsacdop/podcasts/podcastdetail.dart'; Future> getPodcastLocal() async { var dbHelper = DBHelper(); diff --git a/lib/episodegrid.dart b/lib/util/episodegrid.dart similarity index 98% rename from lib/episodegrid.dart rename to lib/util/episodegrid.dart index 9fcab9c..6224d62 100644 --- a/lib/episodegrid.dart +++ b/lib/util/episodegrid.dart @@ -6,9 +6,9 @@ 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 'class/episodebrief.dart'; -import 'episodedetail.dart'; -import 'pageroute.dart'; +import 'package:tsacdop/class/episodebrief.dart'; +import 'package:tsacdop/episodes/episodedetail.dart'; +import 'package:tsacdop/util/pageroute.dart'; class EpisodeGrid extends StatelessWidget { final List podcast; diff --git a/lib/pageroute.dart b/lib/util/pageroute.dart similarity index 100% rename from lib/pageroute.dart rename to lib/util/pageroute.dart