modified: lib/home/appbar/addpodcast.dart

modified:   lib/home/appbar/popupmenu.dart
	modified:   lib/home/audio_player.dart
	modified:   lib/home/home.dart
	modified:   test/widget_test.dart
This commit is contained in:
stonegate 2020-02-13 13:09:22 +08:00
parent 59d208bb03
commit 455d37b727
5 changed files with 231 additions and 221 deletions

View File

@ -15,7 +15,7 @@ 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 'package:tsacdop/home/appbar/popupmenu.dart';
import 'package:tsacdop/webfeed/webfeed.dart';
class MyHomePage extends StatefulWidget {
@ -29,7 +29,9 @@ class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
return ChangeNotifierProvider(
create: (context) => ImportOmpl(),
child: Scaffold(
key: _scaffoldKey,
appBar: AppBar(
elevation: 0,
@ -45,12 +47,16 @@ class _MyHomePageState extends State<MyHomePage> {
);
},
),
title: Image(image: AssetImage('assets/text.png'), height: 30,),
title: Image(
image: AssetImage('assets/text.png'),
height: 30,
),
actions: <Widget>[
PopupMenu(),
],
),
body: Home(),
),
);
}
}
@ -207,7 +213,7 @@ class _SearchResultState extends State<SearchResult> {
@override
Widget build(BuildContext context) {
final importOmpl = Provider.of<ImportOmpl>(context);
ImportOmpl importOmpl = Provider.of<ImportOmpl>(context);
savePodcast(String rss) async {
print(rss);
@ -222,7 +228,7 @@ class _SearchResultState extends State<SearchResult> {
print(_p.title);
var dir = await getApplicationDocumentsDirectory();
try{
try {
Response<List<int>> imageResponse = await Dio().get<List<int>>(
_p.itunes.image.href,
options: Options(responseType: ResponseType.bytes));
@ -247,8 +253,7 @@ class _SearchResultState extends State<SearchResult> {
importOmpl.importState = ImportState.complete;
importOmpl.importState = ImportState.stop;
print('fatch data');
}
catch(e){
} catch (e) {
Fluttertoast.showToast(
msg: 'Network error, Subscribe failed',
gravity: ToastGravity.BOTTOM,

View File

@ -42,7 +42,7 @@ class PopupMenu extends StatelessWidget {
@override
Widget build(BuildContext context) {
final importOmpl = Provider.of<ImportOmpl>(context);
ImportOmpl importOmpl = Provider.of<ImportOmpl>(context);
_refreshAll() async {
var dbHelper = DBHelper();

View File

@ -2,7 +2,6 @@ import 'dart:async';
import 'dart:io';
import 'dart:typed_data';
import 'package:provider/provider.dart';
import 'package:network_image_to_byte/network_image_to_byte.dart';
import 'package:audiofileplayer/audiofileplayer.dart';
import 'package:audiofileplayer/audio_system.dart';
@ -37,7 +36,6 @@ class _PlayerWidgetState extends State<PlayerWidget> {
String url;
String _title;
String _feedtitle;
String _imgurl;
bool _isLoading;
@override
@ -172,7 +170,6 @@ class _PlayerWidgetState extends State<PlayerWidget> {
this.url = url;
_title = Provider.of<Urlchange>(context).title;
_feedtitle = Provider.of<Urlchange>(context).feedtitle;
_imgurl = Provider.of<Urlchange>(context).imageurl;
_backgroundAudioPlaying = true;
_isLoading = true;
_getFile(url).then((result) {
@ -236,11 +233,6 @@ class _PlayerWidgetState extends State<PlayerWidget> {
}
}
Future<Uint8List> _networkImageToByte(String url) async {
Uint8List byteImage = await networkImageToByte(url);
return byteImage;
}
final _pauseButton = AndroidCustomMediaButton(
'pausenow', pausenowButtonId, 'ic_stat_pause_circle_filled');
final _replay10Button = AndroidCustomMediaButton(
@ -252,7 +244,8 @@ class _PlayerWidgetState extends State<PlayerWidget> {
Future<void> _setNotification() async {
var dir = await getApplicationDocumentsDirectory();
final Uint8List imageBytes = File('${dir.path}/$_feedtitle.png').readAsBytesSync();
final Uint8List imageBytes =
File('${dir.path}/$_feedtitle.png').readAsBytesSync();
AudioSystem.instance.setMetadata(AudioMetadata(
title: _title,
artist: _feedtitle,
@ -291,8 +284,8 @@ class _PlayerWidgetState extends State<PlayerWidget> {
AudioState.play;
});
var dir = await getApplicationDocumentsDirectory();
final Uint8List imageBytes = File('${dir.path}/$_feedtitle.png').readAsBytesSync();
//final Uint8List imageBytes = await _networkImageToByte(_imgurl);
final Uint8List imageBytes =
File('${dir.path}/$_feedtitle.png').readAsBytesSync();
AudioSystem.instance.setMetadata(AudioMetadata(
title: _title,
artist: _feedtitle,
@ -367,7 +360,9 @@ class _PlayerWidgetState extends State<PlayerWidget> {
@override
Widget build(BuildContext context) {
return !_isLoading
return ChangeNotifierProvider(
create: (context) => Urlchange(),
child: !_isLoading
? Center()
: Container(
padding: EdgeInsets.symmetric(horizontal: 10.0),
@ -381,8 +376,8 @@ class _PlayerWidgetState extends State<PlayerWidget> {
alignment: Alignment.centerLeft,
child: _remoteErrorMessage != null
? Text(_remoteErrorMessage,
style:
const TextStyle(color: const Color(0xFFFF0000)))
style: const TextStyle(
color: const Color(0xFFFF0000)))
: Text(
_remoteAudioLoading ? 'Buffring...' : '',
style: TextStyle(color: Colors.blue),
@ -417,7 +412,8 @@ class _PlayerWidgetState extends State<PlayerWidget> {
child: Row(
children: <Widget>[
Text(
_stringForSeconds(_backgroundAudioPositionSeconds) ??
_stringForSeconds(
_backgroundAudioPositionSeconds) ??
'',
style: TextStyle(fontSize: 10),
),
@ -428,9 +424,11 @@ class _PlayerWidgetState extends State<PlayerWidget> {
child: (_title.length > 50)
? Marquee(
text: _title,
style: TextStyle(fontWeight: FontWeight.bold),
style:
TextStyle(fontWeight: FontWeight.bold),
scrollAxis: Axis.horizontal,
crossAxisAlignment: CrossAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
blankSpace: 30.0,
velocity: 50.0,
pauseAfterRound: Duration(seconds: 1),
@ -443,11 +441,13 @@ class _PlayerWidgetState extends State<PlayerWidget> {
)
: Text(
_title,
style: TextStyle(fontWeight: FontWeight.bold),
style:
TextStyle(fontWeight: FontWeight.bold),
),
)),
Text(
_stringForSeconds(_backgroundAudioDurationSeconds) ??
_stringForSeconds(
_backgroundAudioDurationSeconds) ??
'',
style: TextStyle(fontSize: 10),
),
@ -502,6 +502,7 @@ class _PlayerWidgetState extends State<PlayerWidget> {
],
),
]),
),
);
}
}

View File

@ -1,10 +1,12 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:tsacdop/class/audiostate.dart';
import 'package:provider/provider.dart';
import '../podcasts/podcastlist.dart';
import 'package:tsacdop/podcasts/podcastlist.dart';
import 'hometab.dart';
import 'package:tsacdop/home/appbar/importompl.dart';
import 'audio_player.dart';
import 'package:tsacdop/home/audio_player.dart';
import 'homescroll.dart';
import 'package:tsacdop/util/pageroute.dart';
@ -16,7 +18,9 @@ class Home extends StatefulWidget {
class _HomeState extends State<Home> {
@override
Widget build(BuildContext context) {
return Column(
return ChangeNotifierProvider(
create: (context) => Urlchange(),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
@ -49,6 +53,6 @@ class _HomeState extends State<Home> {
),
PlayerWidget(),
],
);
));
}
}

View File

@ -16,15 +16,15 @@ void main() {
await tester.pumpWidget(MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
expect(find.text('Favorites'), findsOneWidget);
expect(find.text('Next'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
//await tester.tap(find.byIcon(Icons.add));
//await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
//expect(find.text('0'), findsNothing);
//expect(find.text('1'), findsOneWidget);
});
}