diff --git a/android/app/build.gradle b/android/app/build.gradle index ce2d8fe..04354d8 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -39,7 +39,7 @@ android { defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.example.mucke" - minSdkVersion 16 + minSdkVersion 19 targetSdkVersion 28 versionCode flutterVersionCode.toInteger() versionName flutterVersionName diff --git a/lib/main.dart b/lib/main.dart index bf97ed2..a85d367 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,3 +1,4 @@ +import 'package:audio_session/audio_session.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; @@ -18,6 +19,10 @@ import 'presentation/widgets/navbar.dart'; Future main() async { WidgetsFlutterBinding.ensureInitialized(); await setupGetIt(); + + final session = await AudioSession.instance; + await session.configure(const AudioSessionConfiguration.music()); + runApp(MyApp()); } diff --git a/lib/presentation/pages/home_page.dart b/lib/presentation/pages/home_page.dart index 069923c..6b55697 100644 --- a/lib/presentation/pages/home_page.dart +++ b/lib/presentation/pages/home_page.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; +import '../widgets/highlight.dart'; import '../widgets/shuffle_all_button.dart'; class HomePage extends StatefulWidget { @@ -13,9 +14,31 @@ class _HomePageState extends State { @override Widget build(BuildContext context) { print('HomePage.build'); - return Container( - child: const Center( - child: ShuffleAllButton(), + return SafeArea( + child: Column( + 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, + ), + ], ), ); } diff --git a/lib/presentation/theming.dart b/lib/presentation/theming.dart index ad1e9ee..4d8507d 100644 --- a/lib/presentation/theming.dart +++ b/lib/presentation/theming.dart @@ -19,10 +19,16 @@ ThemeData theme() => ThemeData( primaryColorBrightness: Brightness.dark, primaryColorLight: DARK2, accentColor: LIGHT1, + highlightColor: TURQUOISE, scaffoldBackgroundColor: DARK2, // https://api.flutter.dev/flutter/material/TextTheme-class.html 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( labelColor: Colors.white, diff --git a/lib/presentation/widgets/highlight.dart b/lib/presentation/widgets/highlight.dart new file mode 100644 index 0000000..8e818b6 --- /dev/null +++ b/lib/presentation/widgets/highlight.dart @@ -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), + ), + ), + ), + ], + ), + ), + ), + ), + ], + ) + ], + ), + ), + ); + } +} diff --git a/lib/presentation/widgets/shuffle_all_button.dart b/lib/presentation/widgets/shuffle_all_button.dart index 80bc4d4..91cb10e 100644 --- a/lib/presentation/widgets/shuffle_all_button.dart +++ b/lib/presentation/widgets/shuffle_all_button.dart @@ -4,16 +4,33 @@ import 'package:provider/provider.dart'; import '../state/audio_store.dart'; 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 Widget build(BuildContext context) { final AudioStore audioStore = Provider.of(context); - return RaisedButton( - child: const Text('Shuffle All'), - onPressed: () => audioStore.shuffleAll(), - color: Theme.of(context).accentColor, + return Container( + constraints: BoxConstraints.expand(height: 40.0 + verticalPad * 2), + child: Padding( + 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), + ), + ), + ), ); } } diff --git a/lib/system/datasources/audio_player_task.dart b/lib/system/datasources/audio_player_task.dart index f5a7a23..33797c7 100644 --- a/lib/system/datasources/audio_player_task.dart +++ b/lib/system/datasources/audio_player_task.dart @@ -111,7 +111,7 @@ class AudioPlayerTask extends BackgroundAudioTask { print('AudioPlayerTask.init'); audioPlayer.positionStream.listen((position) => handlePosition(position)); 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 MoorIsolate moorIsolate = MoorIsolate.fromConnectPort(connectPort); diff --git a/pubspec.lock b/pubspec.lock index b6883bb..92874dd 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -42,7 +42,14 @@ packages: name: audio_service url: "https://pub.dartlang.org" 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: dependency: transitive description: @@ -358,7 +365,7 @@ packages: name: just_audio url: "https://pub.dartlang.org" source: hosted - version: "0.3.4" + version: "0.4.0" logging: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 92317bf..c37891f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -17,8 +17,9 @@ dependencies: flutter_audio_query: ^0.3.5 - audio_service: ^0.13.0 - just_audio: ^0.3.0 + audio_service: ^0.14.0 + audio_session: ^0.0.3 + just_audio: ^0.4.0 get_it: ^4.0.2 provider: ^4.0.4