updates and HomePage mocking

This commit is contained in:
Moritz Weber 2020-08-28 11:28:58 +02:00
parent 3a3d0810f5
commit ce8b2be1fe
9 changed files with 170 additions and 15 deletions

View file

@ -39,7 +39,7 @@ android {
defaultConfig { defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.mucke" applicationId "com.example.mucke"
minSdkVersion 16 minSdkVersion 19
targetSdkVersion 28 targetSdkVersion 28
versionCode flutterVersionCode.toInteger() versionCode flutterVersionCode.toInteger()
versionName flutterVersionName versionName flutterVersionName

View file

@ -1,3 +1,4 @@
import 'package:audio_session/audio_session.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:flutter_mobx/flutter_mobx.dart';
@ -18,6 +19,10 @@ import 'presentation/widgets/navbar.dart';
Future<void> main() async { Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
await setupGetIt(); await setupGetIt();
final session = await AudioSession.instance;
await session.configure(const AudioSessionConfiguration.music());
runApp(MyApp()); runApp(MyApp());
} }

View file

@ -1,5 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../widgets/highlight.dart';
import '../widgets/shuffle_all_button.dart'; import '../widgets/shuffle_all_button.dart';
class HomePage extends StatefulWidget { class HomePage extends StatefulWidget {
@ -13,9 +14,31 @@ class _HomePageState extends State<HomePage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
print('HomePage.build'); print('HomePage.build');
return Container( return SafeArea(
child: const Center( child: Column(
child: ShuffleAllButton(), children: [
Row(
children: [
Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 8.0,
horizontal: 12.0,
),
child: Text(
'mucke',
style: Theme.of(context).textTheme.headline1,
),
),
),
],
),
const Highlight(),
const ShuffleAllButton(
verticalPad: 10.0,
horizontalPad: 12.0,
),
],
), ),
); );
} }

View file

@ -19,10 +19,16 @@ ThemeData theme() => ThemeData(
primaryColorBrightness: Brightness.dark, primaryColorBrightness: Brightness.dark,
primaryColorLight: DARK2, primaryColorLight: DARK2,
accentColor: LIGHT1, accentColor: LIGHT1,
highlightColor: TURQUOISE,
scaffoldBackgroundColor: DARK2, scaffoldBackgroundColor: DARK2,
// https://api.flutter.dev/flutter/material/TextTheme-class.html // https://api.flutter.dev/flutter/material/TextTheme-class.html
textTheme: const TextTheme( textTheme: const TextTheme(
headline6: TextStyle(fontSize: 20.0), headline1: TextStyle(fontSize: 28.0, fontWeight: FontWeight.w900, color: LIGHT1),
headline2: TextStyle(fontSize: 24.0, fontWeight: FontWeight.w900, color: Colors.white),
headline3: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w900, color: Colors.white),
headline4: TextStyle(fontSize: 18.0, fontWeight: FontWeight.w600, color: Colors.white),
headline5: TextStyle(fontSize: 18.0, fontWeight: FontWeight.w400, color: Colors.white70),
headline6: TextStyle(fontSize: 18.0),
), ),
tabBarTheme: const TabBarTheme( tabBarTheme: const TabBarTheme(
labelColor: Colors.white, labelColor: Colors.white,

View file

@ -0,0 +1,96 @@
import 'package:flutter/material.dart';
class Highlight extends StatelessWidget {
const Highlight({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 10.0,
horizontal: 12.0,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(bottom: 6.0),
child: Text(
'Album of the Day',
style: Theme.of(context).textTheme.headline3,
),
),
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Expanded(
flex: 1,
child: AspectRatio(
aspectRatio: 1,
child: Card(
elevation: 2.0,
clipBehavior: Clip.antiAlias,
margin: const EdgeInsets.all(0),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(6.0),
),
child: const Image(
image: AssetImage('assets/no_cover.png'),
fit: BoxFit.cover,
),
),
),
),
Expanded(
flex: 2,
child: AspectRatio(
aspectRatio: 2 / 1,
child: Padding(
padding: const EdgeInsets.only(
left: 8.0, right: 8.0, top: 0.0, bottom: 1.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'All Our Gods Have Abandoned Us',
style: Theme.of(context).textTheme.headline4,
maxLines: 2,
overflow: TextOverflow.ellipsis
),
Text(
'Architects',
style: Theme.of(context).textTheme.headline5,
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
const Spacer(),
Container(
height: 36.0,
child: OutlineButton.icon(
onPressed: () {},
icon: const Icon(Icons.play_arrow),
label: const Text('PLAY'),
borderSide: BorderSide(
color: Theme.of(context).accentColor),
padding: const EdgeInsets.all(0),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(6.0),
),
),
),
],
),
),
),
),
],
)
],
),
),
);
}
}

View file

@ -4,16 +4,33 @@ import 'package:provider/provider.dart';
import '../state/audio_store.dart'; import '../state/audio_store.dart';
class ShuffleAllButton extends StatelessWidget { class ShuffleAllButton extends StatelessWidget {
const ShuffleAllButton({Key key}) : super(key: key); const ShuffleAllButton({Key key, this.verticalPad, this.horizontalPad}) : super(key: key);
final double verticalPad;
final double horizontalPad;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final AudioStore audioStore = Provider.of<AudioStore>(context); final AudioStore audioStore = Provider.of<AudioStore>(context);
return RaisedButton( return Container(
child: const Text('Shuffle All'), constraints: BoxConstraints.expand(height: 40.0 + verticalPad * 2),
onPressed: () => audioStore.shuffleAll(), child: Padding(
color: Theme.of(context).accentColor, padding: EdgeInsets.symmetric(
vertical: verticalPad,
horizontal: horizontalPad,
),
child: RaisedButton.icon(
icon: const Icon(Icons.shuffle),
label: const Text('SHUFFLE ALL'),
onPressed: () => audioStore.shuffleAll(),
color: Theme.of(context).accentColor,
highlightColor: Theme.of(context).highlightColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(6.0),
),
),
),
); );
} }
} }

View file

@ -111,7 +111,7 @@ class AudioPlayerTask extends BackgroundAudioTask {
print('AudioPlayerTask.init'); print('AudioPlayerTask.init');
audioPlayer.positionStream.listen((position) => handlePosition(position)); audioPlayer.positionStream.listen((position) => handlePosition(position));
audioPlayer.playerStateStream.listen((event) => handlePlayerState(event)); audioPlayer.playerStateStream.listen((event) => handlePlayerState(event));
audioPlayer.currentIndexStream.listen((event) => playbackIndex = event); audioPlayer.sequenceStateStream.listen((event) => playbackIndex = event.currentIndex);
final connectPort = IsolateNameServer.lookupPortByName(MOOR_ISOLATE); final connectPort = IsolateNameServer.lookupPortByName(MOOR_ISOLATE);
final MoorIsolate moorIsolate = MoorIsolate.fromConnectPort(connectPort); final MoorIsolate moorIsolate = MoorIsolate.fromConnectPort(connectPort);

View file

@ -42,7 +42,14 @@ packages:
name: audio_service name: audio_service
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.13.0" version: "0.14.0"
audio_session:
dependency: "direct main"
description:
name: audio_session
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.3"
boolean_selector: boolean_selector:
dependency: transitive dependency: transitive
description: description:
@ -358,7 +365,7 @@ packages:
name: just_audio name: just_audio
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.3.4" version: "0.4.0"
logging: logging:
dependency: transitive dependency: transitive
description: description:

View file

@ -17,8 +17,9 @@ dependencies:
flutter_audio_query: ^0.3.5 flutter_audio_query: ^0.3.5
audio_service: ^0.13.0 audio_service: ^0.14.0
just_audio: ^0.3.0 audio_session: ^0.0.3
just_audio: ^0.4.0
get_it: ^4.0.2 get_it: ^4.0.2
provider: ^4.0.4 provider: ^4.0.4