modified: lib/class/sqflite_localpodcast.dart
modified: lib/episodes/episodedetail.dart modified: lib/home/appbar/addpodcast.dart modified: lib/home/audio_player.dart modified: lib/home/audiopanel.dart modified: lib/home/home.dart modified: lib/util/pageroute.dart
This commit is contained in:
parent
4566ab4400
commit
5d43a7e641
|
@ -402,4 +402,27 @@ class DBHelper {
|
|||
String description = list[0]['description'];
|
||||
return description;
|
||||
}
|
||||
|
||||
Future<EpisodeBrief> getRssItemWithUrl(String url) async {
|
||||
var dbClient = await database;
|
||||
EpisodeBrief episode;
|
||||
List<Map> list = await dbClient.rawQuery(
|
||||
"""SELECT E.title, E.enclosure_url, E.enclosure_length, E.pubDate,
|
||||
E.feed_title, E.duration, E.explicit, E.liked, E.downloaded, P.imageUrl,
|
||||
P.primaryColor FROM Episodes E INNER JOIN PodcastLocal P ON E.feed_title = P.title
|
||||
WHERE E.enclosure_url = ?""",[url]);
|
||||
episode = EpisodeBrief(
|
||||
list.first['title'],
|
||||
list.first['enclosure_url'],
|
||||
list.first['enclosure_length'],
|
||||
list.first['pubDate'],
|
||||
list.first['feed_title'],
|
||||
list.first['imageUrl'],
|
||||
list.first['primaryColor'],
|
||||
list.first['liked'],
|
||||
list.first['downloaded'],
|
||||
list.first['duration'],
|
||||
list.first['explicit']);
|
||||
return episode;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import 'package:flutter_html/flutter_html.dart';
|
|||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:tsacdop/class/audiostate.dart';
|
||||
import 'package:tsacdop/class/episodebrief.dart';
|
||||
import 'package:tsacdop/class/sqflite_localpodcast.dart';
|
||||
|
|
|
@ -16,9 +16,7 @@ import 'package:tsacdop/class/podcastlocal.dart';
|
|||
import 'package:tsacdop/class/sqflite_localpodcast.dart';
|
||||
import 'package:tsacdop/home/home.dart';
|
||||
import 'package:tsacdop/home/appbar/popupmenu.dart';
|
||||
import 'package:tsacdop/util/pageroute.dart';
|
||||
import 'package:tsacdop/webfeed/webfeed.dart';
|
||||
import 'package:tsacdop/home/audiopanel.dart';
|
||||
|
||||
class MyHomePage extends StatefulWidget {
|
||||
@override
|
||||
|
|
|
@ -12,7 +12,11 @@ import 'package:marquee/marquee.dart';
|
|||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:flutter_downloader/flutter_downloader.dart';
|
||||
import 'package:tsacdop/class/audiostate.dart';
|
||||
import 'package:tsacdop/class/episodebrief.dart';
|
||||
import 'package:tsacdop/episodes/episodedetail.dart';
|
||||
import 'package:tsacdop/home/audiopanel.dart';
|
||||
import 'package:tsacdop/class/sqflite_localpodcast.dart';
|
||||
import 'package:tsacdop/util/pageroute.dart';
|
||||
|
||||
final Logger _logger = Logger('audiofileplayer');
|
||||
|
||||
|
@ -41,6 +45,8 @@ class _PlayerWidgetState extends State<PlayerWidget> {
|
|||
bool _isLoading;
|
||||
String _primaryColor;
|
||||
Color _c;
|
||||
String _imagePath;
|
||||
bool _loadDir;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
@ -48,8 +54,31 @@ class _PlayerWidgetState extends State<PlayerWidget> {
|
|||
AudioSystem.instance.addMediaEventListener(_mediaEventListener);
|
||||
_isLoading = false;
|
||||
_remoteAudioLoading = true;
|
||||
_loadDir = false;
|
||||
getPath();
|
||||
}
|
||||
|
||||
//get path to load podcast image in expanded panel
|
||||
getPath() async {
|
||||
var dir = await getApplicationDocumentsDirectory();
|
||||
_imagePath = dir.path;
|
||||
setState(() {
|
||||
_loadDir = true;
|
||||
});
|
||||
}
|
||||
|
||||
//open episoddetail page
|
||||
_gotoEpisode() async {
|
||||
var dbHelper = DBHelper();
|
||||
EpisodeBrief episodeBrief = await dbHelper.getRssItemWithUrl(url);
|
||||
Navigator.push(
|
||||
context,
|
||||
SlideUptRoute(
|
||||
page: EpisodeDetail(episodeItem: episodeBrief, heroTag: 'playpanel')),
|
||||
);
|
||||
}
|
||||
|
||||
//init audio player from url
|
||||
void _initbackgroundAudioPlayer(String url) {
|
||||
_remoteErrorMessage = null;
|
||||
_remoteAudioLoading = true;
|
||||
|
@ -100,6 +129,7 @@ class _PlayerWidgetState extends State<PlayerWidget> {
|
|||
..play();
|
||||
}
|
||||
|
||||
//init audio player form local file
|
||||
void _initbackgroundAudioPlayerLocal(String path) {
|
||||
_remoteErrorMessage = null;
|
||||
_remoteAudioLoading = true;
|
||||
|
@ -150,6 +180,7 @@ class _PlayerWidgetState extends State<PlayerWidget> {
|
|||
..play();
|
||||
}
|
||||
|
||||
//if downloaded
|
||||
Future<String> _getFile(String url) async {
|
||||
final task = await FlutterDownloader.loadTasksWithRawQuery(
|
||||
query: "SELECT * FROM task WHERE url = '$url' AND status = 3");
|
||||
|
@ -160,6 +191,7 @@ class _PlayerWidgetState extends State<PlayerWidget> {
|
|||
return 'NotDownload';
|
||||
}
|
||||
|
||||
//get local audio file
|
||||
ByteData getAudio(String path) {
|
||||
File audioFile = File(path);
|
||||
Uint8List audio = audioFile.readAsBytesSync();
|
||||
|
@ -378,8 +410,8 @@ class _PlayerWidgetState extends State<PlayerWidget> {
|
|||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
height: 100.0,
|
||||
padding: EdgeInsets.all(30),
|
||||
height: 80.0,
|
||||
padding: EdgeInsets.all(20),
|
||||
alignment: Alignment.center,
|
||||
child: (_title.length > 10)
|
||||
? Marquee(
|
||||
|
@ -404,7 +436,7 @@ class _PlayerWidgetState extends State<PlayerWidget> {
|
|||
),
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.only(left: 40, right: 40, top: 20),
|
||||
padding: EdgeInsets.only(left: 30, right: 30),
|
||||
child: SliderTheme(
|
||||
data: SliderTheme.of(context).copyWith(
|
||||
activeTrackColor: Colors.blue[100],
|
||||
|
@ -513,6 +545,44 @@ class _PlayerWidgetState extends State<PlayerWidget> {
|
|||
],
|
||||
),
|
||||
),
|
||||
Spacer(),
|
||||
Container(
|
||||
height: 50.0,
|
||||
margin: EdgeInsets.symmetric(vertical: 10.0),
|
||||
padding: EdgeInsets.symmetric(horizontal: 10.0),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.all(Radius.circular(10.0)),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: EdgeInsets.all(10.0),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.all(Radius.circular(15.0)),
|
||||
child: Container(
|
||||
height: 30.0,
|
||||
width: 30.0,
|
||||
color: Colors.white,
|
||||
child: _loadDir
|
||||
? Image.file(
|
||||
File("$_imagePath/$_feedtitle.png"))
|
||||
: Center(),
|
||||
),
|
||||
),
|
||||
),
|
||||
Spacer(),
|
||||
Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
onTap: () => _gotoEpisode(),
|
||||
child: Icon(Icons.info),
|
||||
),
|
||||
),
|
||||
],
|
||||
))
|
||||
]),
|
||||
);
|
||||
Widget _miniPanel() => Container(
|
||||
|
|
|
@ -99,7 +99,7 @@ class _AudioPanelState extends State<AudioPanel>
|
|||
setState(() {
|
||||
_animation =
|
||||
Tween<double>(begin: initSize, end: minSize).animate(_controller);
|
||||
initSize = minSize;
|
||||
initSize = minSize;
|
||||
});
|
||||
_controller.forward();
|
||||
}
|
||||
|
|
|
@ -10,16 +10,7 @@ import 'package:tsacdop/home/audio_player.dart';
|
|||
import 'homescroll.dart';
|
||||
import 'package:tsacdop/util/pageroute.dart';
|
||||
|
||||
class Home extends StatefulWidget {
|
||||
@override
|
||||
_HomeState createState() => _HomeState();
|
||||
}
|
||||
|
||||
class _HomeState extends State<Home> {
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
}
|
||||
class Home extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
|
|
@ -27,6 +27,32 @@ class SlideLeftRoute extends PageRouteBuilder {
|
|||
);
|
||||
}
|
||||
|
||||
class SlideUptRoute extends PageRouteBuilder {
|
||||
final Widget page;
|
||||
SlideUptRoute({this.page})
|
||||
: super(
|
||||
pageBuilder: (
|
||||
BuildContext context,
|
||||
Animation<double> animation,
|
||||
Animation<double> secondaryAnimation,
|
||||
) =>
|
||||
page,
|
||||
transitionsBuilder: (
|
||||
BuildContext context,
|
||||
Animation<double> animation,
|
||||
Animation<double> secondaryAnimation,
|
||||
Widget child,
|
||||
) =>
|
||||
SlideTransition(
|
||||
position: Tween<Offset>(
|
||||
begin: const Offset(0, 1),
|
||||
end: Offset.zero,
|
||||
).animate(animation),
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
//Scale Pageroute
|
||||
class ScaleRoute extends PageRouteBuilder {
|
||||
final Widget page;
|
||||
|
|
Loading…
Reference in New Issue