mirror of
https://github.com/stonega/tsacdop
synced 2025-02-17 20:10:37 +01:00
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:
parent
59d208bb03
commit
455d37b727
@ -15,7 +15,7 @@ import 'package:tsacdop/class/searchpodcast.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/home/home.dart';
|
import 'package:tsacdop/home/home.dart';
|
||||||
import 'popupmenu.dart';
|
import 'package:tsacdop/home/appbar/popupmenu.dart';
|
||||||
import 'package:tsacdop/webfeed/webfeed.dart';
|
import 'package:tsacdop/webfeed/webfeed.dart';
|
||||||
|
|
||||||
class MyHomePage extends StatefulWidget {
|
class MyHomePage extends StatefulWidget {
|
||||||
@ -29,7 +29,9 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return ChangeNotifierProvider(
|
||||||
|
create: (context) => ImportOmpl(),
|
||||||
|
child: Scaffold(
|
||||||
key: _scaffoldKey,
|
key: _scaffoldKey,
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
elevation: 0,
|
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>[
|
actions: <Widget>[
|
||||||
PopupMenu(),
|
PopupMenu(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
body: Home(),
|
body: Home(),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -207,7 +213,7 @@ class _SearchResultState extends State<SearchResult> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final importOmpl = Provider.of<ImportOmpl>(context);
|
ImportOmpl importOmpl = Provider.of<ImportOmpl>(context);
|
||||||
|
|
||||||
savePodcast(String rss) async {
|
savePodcast(String rss) async {
|
||||||
print(rss);
|
print(rss);
|
||||||
@ -222,7 +228,7 @@ class _SearchResultState extends State<SearchResult> {
|
|||||||
|
|
||||||
print(_p.title);
|
print(_p.title);
|
||||||
var dir = await getApplicationDocumentsDirectory();
|
var dir = await getApplicationDocumentsDirectory();
|
||||||
try{
|
try {
|
||||||
Response<List<int>> imageResponse = await Dio().get<List<int>>(
|
Response<List<int>> imageResponse = await Dio().get<List<int>>(
|
||||||
_p.itunes.image.href,
|
_p.itunes.image.href,
|
||||||
options: Options(responseType: ResponseType.bytes));
|
options: Options(responseType: ResponseType.bytes));
|
||||||
@ -247,8 +253,7 @@ class _SearchResultState extends State<SearchResult> {
|
|||||||
importOmpl.importState = ImportState.complete;
|
importOmpl.importState = ImportState.complete;
|
||||||
importOmpl.importState = ImportState.stop;
|
importOmpl.importState = ImportState.stop;
|
||||||
print('fatch data');
|
print('fatch data');
|
||||||
}
|
} catch (e) {
|
||||||
catch(e){
|
|
||||||
Fluttertoast.showToast(
|
Fluttertoast.showToast(
|
||||||
msg: 'Network error, Subscribe failed',
|
msg: 'Network error, Subscribe failed',
|
||||||
gravity: ToastGravity.BOTTOM,
|
gravity: ToastGravity.BOTTOM,
|
||||||
|
@ -42,7 +42,7 @@ class PopupMenu extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final importOmpl = Provider.of<ImportOmpl>(context);
|
ImportOmpl importOmpl = Provider.of<ImportOmpl>(context);
|
||||||
|
|
||||||
_refreshAll() async {
|
_refreshAll() async {
|
||||||
var dbHelper = DBHelper();
|
var dbHelper = DBHelper();
|
||||||
|
@ -2,7 +2,6 @@ import 'dart:async';
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:network_image_to_byte/network_image_to_byte.dart';
|
|
||||||
|
|
||||||
import 'package:audiofileplayer/audiofileplayer.dart';
|
import 'package:audiofileplayer/audiofileplayer.dart';
|
||||||
import 'package:audiofileplayer/audio_system.dart';
|
import 'package:audiofileplayer/audio_system.dart';
|
||||||
@ -37,7 +36,6 @@ class _PlayerWidgetState extends State<PlayerWidget> {
|
|||||||
String url;
|
String url;
|
||||||
String _title;
|
String _title;
|
||||||
String _feedtitle;
|
String _feedtitle;
|
||||||
String _imgurl;
|
|
||||||
bool _isLoading;
|
bool _isLoading;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -172,7 +170,6 @@ class _PlayerWidgetState extends State<PlayerWidget> {
|
|||||||
this.url = url;
|
this.url = url;
|
||||||
_title = Provider.of<Urlchange>(context).title;
|
_title = Provider.of<Urlchange>(context).title;
|
||||||
_feedtitle = Provider.of<Urlchange>(context).feedtitle;
|
_feedtitle = Provider.of<Urlchange>(context).feedtitle;
|
||||||
_imgurl = Provider.of<Urlchange>(context).imageurl;
|
|
||||||
_backgroundAudioPlaying = true;
|
_backgroundAudioPlaying = true;
|
||||||
_isLoading = true;
|
_isLoading = true;
|
||||||
_getFile(url).then((result) {
|
_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(
|
final _pauseButton = AndroidCustomMediaButton(
|
||||||
'pausenow', pausenowButtonId, 'ic_stat_pause_circle_filled');
|
'pausenow', pausenowButtonId, 'ic_stat_pause_circle_filled');
|
||||||
final _replay10Button = AndroidCustomMediaButton(
|
final _replay10Button = AndroidCustomMediaButton(
|
||||||
@ -252,7 +244,8 @@ class _PlayerWidgetState extends State<PlayerWidget> {
|
|||||||
|
|
||||||
Future<void> _setNotification() async {
|
Future<void> _setNotification() async {
|
||||||
var dir = await getApplicationDocumentsDirectory();
|
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(
|
AudioSystem.instance.setMetadata(AudioMetadata(
|
||||||
title: _title,
|
title: _title,
|
||||||
artist: _feedtitle,
|
artist: _feedtitle,
|
||||||
@ -291,8 +284,8 @@ class _PlayerWidgetState extends State<PlayerWidget> {
|
|||||||
AudioState.play;
|
AudioState.play;
|
||||||
});
|
});
|
||||||
var dir = await getApplicationDocumentsDirectory();
|
var dir = await getApplicationDocumentsDirectory();
|
||||||
final Uint8List imageBytes = File('${dir.path}/$_feedtitle.png').readAsBytesSync();
|
final Uint8List imageBytes =
|
||||||
//final Uint8List imageBytes = await _networkImageToByte(_imgurl);
|
File('${dir.path}/$_feedtitle.png').readAsBytesSync();
|
||||||
AudioSystem.instance.setMetadata(AudioMetadata(
|
AudioSystem.instance.setMetadata(AudioMetadata(
|
||||||
title: _title,
|
title: _title,
|
||||||
artist: _feedtitle,
|
artist: _feedtitle,
|
||||||
@ -367,7 +360,9 @@ class _PlayerWidgetState extends State<PlayerWidget> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return !_isLoading
|
return ChangeNotifierProvider(
|
||||||
|
create: (context) => Urlchange(),
|
||||||
|
child: !_isLoading
|
||||||
? Center()
|
? Center()
|
||||||
: Container(
|
: Container(
|
||||||
padding: EdgeInsets.symmetric(horizontal: 10.0),
|
padding: EdgeInsets.symmetric(horizontal: 10.0),
|
||||||
@ -381,8 +376,8 @@ class _PlayerWidgetState extends State<PlayerWidget> {
|
|||||||
alignment: Alignment.centerLeft,
|
alignment: Alignment.centerLeft,
|
||||||
child: _remoteErrorMessage != null
|
child: _remoteErrorMessage != null
|
||||||
? Text(_remoteErrorMessage,
|
? Text(_remoteErrorMessage,
|
||||||
style:
|
style: const TextStyle(
|
||||||
const TextStyle(color: const Color(0xFFFF0000)))
|
color: const Color(0xFFFF0000)))
|
||||||
: Text(
|
: Text(
|
||||||
_remoteAudioLoading ? 'Buffring...' : '',
|
_remoteAudioLoading ? 'Buffring...' : '',
|
||||||
style: TextStyle(color: Colors.blue),
|
style: TextStyle(color: Colors.blue),
|
||||||
@ -417,7 +412,8 @@ class _PlayerWidgetState extends State<PlayerWidget> {
|
|||||||
child: Row(
|
child: Row(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Text(
|
Text(
|
||||||
_stringForSeconds(_backgroundAudioPositionSeconds) ??
|
_stringForSeconds(
|
||||||
|
_backgroundAudioPositionSeconds) ??
|
||||||
'',
|
'',
|
||||||
style: TextStyle(fontSize: 10),
|
style: TextStyle(fontSize: 10),
|
||||||
),
|
),
|
||||||
@ -428,9 +424,11 @@ class _PlayerWidgetState extends State<PlayerWidget> {
|
|||||||
child: (_title.length > 50)
|
child: (_title.length > 50)
|
||||||
? Marquee(
|
? Marquee(
|
||||||
text: _title,
|
text: _title,
|
||||||
style: TextStyle(fontWeight: FontWeight.bold),
|
style:
|
||||||
|
TextStyle(fontWeight: FontWeight.bold),
|
||||||
scrollAxis: Axis.horizontal,
|
scrollAxis: Axis.horizontal,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment:
|
||||||
|
CrossAxisAlignment.start,
|
||||||
blankSpace: 30.0,
|
blankSpace: 30.0,
|
||||||
velocity: 50.0,
|
velocity: 50.0,
|
||||||
pauseAfterRound: Duration(seconds: 1),
|
pauseAfterRound: Duration(seconds: 1),
|
||||||
@ -443,11 +441,13 @@ class _PlayerWidgetState extends State<PlayerWidget> {
|
|||||||
)
|
)
|
||||||
: Text(
|
: Text(
|
||||||
_title,
|
_title,
|
||||||
style: TextStyle(fontWeight: FontWeight.bold),
|
style:
|
||||||
|
TextStyle(fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
Text(
|
Text(
|
||||||
_stringForSeconds(_backgroundAudioDurationSeconds) ??
|
_stringForSeconds(
|
||||||
|
_backgroundAudioDurationSeconds) ??
|
||||||
'',
|
'',
|
||||||
style: TextStyle(fontSize: 10),
|
style: TextStyle(fontSize: 10),
|
||||||
),
|
),
|
||||||
@ -502,6 +502,7 @@ class _PlayerWidgetState extends State<PlayerWidget> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.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 'hometab.dart';
|
||||||
import 'package:tsacdop/home/appbar/importompl.dart';
|
import 'package:tsacdop/home/appbar/importompl.dart';
|
||||||
import 'audio_player.dart';
|
import 'package:tsacdop/home/audio_player.dart';
|
||||||
import 'homescroll.dart';
|
import 'homescroll.dart';
|
||||||
import 'package:tsacdop/util/pageroute.dart';
|
import 'package:tsacdop/util/pageroute.dart';
|
||||||
|
|
||||||
@ -16,7 +18,9 @@ class Home extends StatefulWidget {
|
|||||||
class _HomeState extends State<Home> {
|
class _HomeState extends State<Home> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Column(
|
return ChangeNotifierProvider(
|
||||||
|
create: (context) => Urlchange(),
|
||||||
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
@ -49,6 +53,6 @@ class _HomeState extends State<Home> {
|
|||||||
),
|
),
|
||||||
PlayerWidget(),
|
PlayerWidget(),
|
||||||
],
|
],
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -16,15 +16,15 @@ void main() {
|
|||||||
await tester.pumpWidget(MyApp());
|
await tester.pumpWidget(MyApp());
|
||||||
|
|
||||||
// Verify that our counter starts at 0.
|
// Verify that our counter starts at 0.
|
||||||
expect(find.text('0'), findsOneWidget);
|
expect(find.text('Favorites'), findsOneWidget);
|
||||||
expect(find.text('1'), findsNothing);
|
expect(find.text('Next'), findsNothing);
|
||||||
|
|
||||||
// Tap the '+' icon and trigger a frame.
|
// Tap the '+' icon and trigger a frame.
|
||||||
await tester.tap(find.byIcon(Icons.add));
|
//await tester.tap(find.byIcon(Icons.add));
|
||||||
await tester.pump();
|
//await tester.pump();
|
||||||
|
|
||||||
// Verify that our counter has incremented.
|
// Verify that our counter has incremented.
|
||||||
expect(find.text('0'), findsNothing);
|
//expect(find.text('0'), findsNothing);
|
||||||
expect(find.text('1'), findsOneWidget);
|
//expect(find.text('1'), findsOneWidget);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user