From e51d8b6c56c7870874ff82d60b8c1f09b5a1c0a6 Mon Sep 17 00:00:00 2001 From: Moritz Weber Date: Thu, 15 Jul 2021 17:50:35 +0200 Subject: [PATCH] flavors --- .vscode/launch.json | 32 ++++++- android/app/build.gradle | 12 ++- lib/presentation/pages/currently_playing.dart | 6 +- lib/presentation/pages/home_page.dart | 16 +++- lib/presentation/pages/settings_page.dart | 94 ++++++++++--------- lib/presentation/widgets/header.dart | 12 ++- 6 files changed, 112 insertions(+), 60 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index b8a1c3b..1462c7a 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -7,25 +7,51 @@ { "name": "Debug", "request": "launch", - "type": "dart" + "type": "dart", + "args": [ + "--flavor", + "dev", + ], }, { "name": "Test", "type": "dart", "request": "launch", "program": "./test/", + "args": [ + "--flavor", + "dev", + ], }, { "name": "Profile", "type": "dart", "request": "launch", - "flutterMode": "profile" + "flutterMode": "profile", + "args": [ + "--flavor", + "dev", + ], }, { "name": "Release", "type": "dart", "request": "launch", - "flutterMode": "release" + "flutterMode": "release", + "args": [ + "--flavor", + "dev", + ], + }, + { + "name": "PRODUCTION", + "type": "dart", + "request": "launch", + "flutterMode": "release", + "args": [ + "--flavor", + "prod", + ], }, ] } \ No newline at end of file diff --git a/android/app/build.gradle b/android/app/build.gradle index bd84776..0d8421b 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 "rocks.mucke" + // applicationId "rocks.mucke" minSdkVersion 19 targetSdkVersion 29 versionCode flutterVersionCode.toInteger() @@ -47,6 +47,16 @@ android { testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } + flavorDimensions "app" + productFlavors { + dev { + applicationId = "rocks.mucke.dev" + } + prod { + applicationId = "rocks.mucke" + } + } + buildTypes { release { // TODO: Add your own signing config for the release build. diff --git a/lib/presentation/pages/currently_playing.dart b/lib/presentation/pages/currently_playing.dart index 81b5ce8..60a330a 100644 --- a/lib/presentation/pages/currently_playing.dart +++ b/lib/presentation/pages/currently_playing.dart @@ -154,7 +154,7 @@ class CurrentlyPlayingPage extends StatelessWidget { ); } - void _openMoreMenu(BuildContext context) { + Future _openMoreMenu(BuildContext context) async { final AudioStore audioStore = GetIt.I(); final MusicDataStore musicDataStore = GetIt.I(); final NavigationStore navStore = GetIt.I(); @@ -163,10 +163,10 @@ class CurrentlyPlayingPage extends StatelessWidget { if (song == null) return; // EXPLORATORY - final albums = musicDataStore.albumStream.value ?? []; + final albums = await musicDataStore.albumStream.first; final album = albums.singleWhere((a) => a.title == song.album); - final artists = musicDataStore.artistStream.value ?? []; + final artists = await musicDataStore.artistStream.first; final artist = artists.singleWhere((a) => a.name == album.artist); showModalBottomSheet( diff --git a/lib/presentation/pages/home_page.dart b/lib/presentation/pages/home_page.dart index 7238c29..f6ba206 100644 --- a/lib/presentation/pages/home_page.dart +++ b/lib/presentation/pages/home_page.dart @@ -4,6 +4,7 @@ import '../theming.dart'; import '../widgets/header.dart'; import '../widgets/highlight.dart'; import '../widgets/shuffle_all_button.dart'; +import 'settings_page.dart'; class HomePage extends StatefulWidget { const HomePage({Key? key}) : super(key: key); @@ -19,9 +20,18 @@ class _HomePageState extends State { return SafeArea( child: Column( children: [ - const Padding( - padding: EdgeInsets.only(top: 8.0, left: HORIZONTAL_PADDING), - child: Header(title: 'Home'), + Padding( + padding: const EdgeInsets.only(top: 8.0, left: HORIZONTAL_PADDING), + child: Header( + title: 'Home', + onPressed: () { + Navigator.of(context).push( + MaterialPageRoute( + builder: (BuildContext context) => const SettingsPage(), + ), + ); + }, + ), ), Padding( padding: const EdgeInsets.symmetric(horizontal: HORIZONTAL_PADDING), diff --git a/lib/presentation/pages/settings_page.dart b/lib/presentation/pages/settings_page.dart index 8580220..92db4b4 100644 --- a/lib/presentation/pages/settings_page.dart +++ b/lib/presentation/pages/settings_page.dart @@ -14,52 +14,56 @@ class SettingsPage extends StatelessWidget { Widget build(BuildContext context) { final MusicDataStore store = GetIt.I(); - return ListView( - children: [ - Container( - height: 12.0, + return SafeArea( + child: Material( + child: ListView( + children: [ + Container( + height: 12.0, + ), + const Padding( + padding: EdgeInsets.symmetric( + horizontal: 16.0, + vertical: 4.0, + ), + child: Text( + 'Library', + style: TEXT_HEADER, + ), + ), + ListTile( + title: const Text('Update library'), + subtitle: Observer(builder: (_) { + final int artistCount = store.artistStream.value?.length ?? 0; + final int albumCount = store.albumStream.value?.length ?? 0; + final int songCount = store.songStream.value?.length ?? 0; + return Text('$artistCount artists, $albumCount albums, $songCount songs'); + }), + onTap: () => store.updateDatabase(), + trailing: Observer(builder: (_) { + if (store.isUpdatingDatabase) { + return const CircularProgressIndicator(); + } + return Container( + height: 0, + width: 0, + ); + }), + ), + const Divider( + height: 4.0, + ), + ListTile( + title: const Text('Select library folders'), + trailing: const Icon(Icons.chevron_right), + onTap: () => _openFilePicker(store), + ), + const Divider( + height: 4.0, + ), + ], ), - const Padding( - padding: EdgeInsets.symmetric( - horizontal: 16.0, - vertical: 4.0, - ), - child: Text( - 'Library', - style: TEXT_HEADER, - ), - ), - ListTile( - title: const Text('Update library'), - subtitle: Observer(builder: (_) { - final int artistCount = store.artistStream.value?.length ?? 0; - final int albumCount = store.albumStream.value?.length ?? 0; - final int songCount = store.songStream.value?.length ?? 0; - return Text('$artistCount artists, $albumCount albums, $songCount songs'); - }), - onTap: () => store.updateDatabase(), - trailing: Observer(builder: (_) { - if (store.isUpdatingDatabase) { - return const CircularProgressIndicator(); - } - return Container( - height: 0, - width: 0, - ); - }), - ), - const Divider( - height: 4.0, - ), - ListTile( - title: const Text('Select library folders'), - trailing: const Icon(Icons.chevron_right), - onTap: () => _openFilePicker(store), - ), - const Divider( - height: 4.0, - ), - ], + ), ); } diff --git a/lib/presentation/widgets/header.dart b/lib/presentation/widgets/header.dart index a9b9177..279c07d 100644 --- a/lib/presentation/widgets/header.dart +++ b/lib/presentation/widgets/header.dart @@ -3,19 +3,21 @@ import 'package:flutter/material.dart'; import '../theming.dart'; class Header extends StatelessWidget { - const Header({Key? key, required this.title}) : super(key: key); + const Header({Key? key, required this.title, this.onPressed}) : super(key: key); final String title; + final Function? onPressed; @override Widget build(BuildContext context) { return Row( children: [ Text(title, style: TEXT_HEADER), - IconButton( - icon: const Icon(Icons.more_vert), - onPressed: () {}, - ), + if (onPressed != null) + IconButton( + icon: const Icon(Icons.more_vert), + onPressed: () => onPressed!(), + ), ], mainAxisAlignment: MainAxisAlignment.spaceBetween, );