From c0987e5f356992c70505ff811056d70647bf21ea Mon Sep 17 00:00:00 2001 From: timoknapp Date: Sun, 15 Jan 2023 12:50:17 +0100 Subject: [PATCH 1/6] feat: introducing dark mode --- .../gradle/wrapper/gradle-wrapper.properties | 3 +- lib/components/autocomplete_item.dart | 2 +- lib/components/bottom_bar.dart | 8 ++- lib/components/input_area.dart | 12 ++++ lib/components/main_area.dart | 6 ++ lib/components/small_button.dart | 57 +++++++++++++++---- lib/screens/home.dart | 20 ++++++- lib/screens/loading.dart | 2 +- lib/util/constants.dart | 6 +- pubspec.lock | 47 +++++++-------- 10 files changed, 116 insertions(+), 47 deletions(-) diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index 562c5e4..2e6e589 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Fri Jun 23 08:50:38 CEST 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip diff --git a/lib/components/autocomplete_item.dart b/lib/components/autocomplete_item.dart index 7a78681..890eb6d 100644 --- a/lib/components/autocomplete_item.dart +++ b/lib/components/autocomplete_item.dart @@ -10,7 +10,7 @@ class AutocompleteItem extends StatelessWidget { @override Widget build(BuildContext context) { return Card( - color: lighterGrey, + color: backgroundColorLightMode2, child: ListTile( title: Text(text), onTap: onClick, diff --git a/lib/components/bottom_bar.dart b/lib/components/bottom_bar.dart index 53efb2d..bca61fc 100644 --- a/lib/components/bottom_bar.dart +++ b/lib/components/bottom_bar.dart @@ -12,6 +12,7 @@ class BottomBar extends StatelessWidget { final Track track; final AudioPlayer audioPlayer; final Duration currentAudioPosition; + final Color backgroundColor; BottomBar({ this.playPause, @@ -21,6 +22,7 @@ class BottomBar extends StatelessWidget { this.track, this.audioPlayer, this.currentAudioPosition, + this.backgroundColor, }); String printDuration() { @@ -39,7 +41,7 @@ class BottomBar extends StatelessWidget { @override Widget build(BuildContext context) { return Container( - color: lighterGrey, + color: backgroundColor, width: MediaQuery.of(context).size.width * 1, height: 65, child: Row( @@ -55,6 +57,7 @@ class BottomBar extends StatelessWidget { child: SmallButton( autoFocus: false, icon: Icon(Icons.fast_rewind), + color: primaryOrange, onClick: track != null ? backward : null, ), ), @@ -64,6 +67,7 @@ class BottomBar extends StatelessWidget { icon: Icon(audioPlayer.state != PlayerState.playing ? Icons.play_arrow : Icons.pause), + color: primaryOrange, onClick: track != null ? playPause : null, ), ), @@ -71,6 +75,7 @@ class BottomBar extends StatelessWidget { child: SmallButton( autoFocus: false, icon: Icon(Icons.fast_forward), + color: primaryOrange, onClick: track != null ? forward : null, ), ), @@ -78,6 +83,7 @@ class BottomBar extends StatelessWidget { child: SmallButton( autoFocus: false, icon: Icon(Icons.stop), + color: primaryOrange, onClick: stop, ), ), diff --git a/lib/components/input_area.dart b/lib/components/input_area.dart index aff2255..8d0ef06 100644 --- a/lib/components/input_area.dart +++ b/lib/components/input_area.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:sound_on_fire/components/autocomplete_item.dart'; import 'package:sound_on_fire/components/keyboard.dart'; +import 'package:sound_on_fire/components/small_button.dart'; import 'package:sound_on_fire/util/constants.dart'; class InputArea extends StatelessWidget { @@ -10,12 +11,16 @@ class InputArea extends StatelessWidget { @required this.onKeyboardAction, @required this.isAlphabeticalKeyboard, @required this.isLoading, + @required this.isDarkModeEnabled, + @required this.toggleDarkMode, }); final List autocompleteItems; final Function onKeyboardAction; final bool isAlphabeticalKeyboard; final bool isLoading; + final bool isDarkModeEnabled; + final Function toggleDarkMode; @override Widget build(BuildContext context) { @@ -48,6 +53,13 @@ class InputArea extends StatelessWidget { Image( image: AssetImage('images/pb_soundcloud2.png'), ), + SizedBox(height: 3), + SmallButton( + text: isDarkModeEnabled ? "LIGHT" : "DARK", + icon: isDarkModeEnabled ? Icon(Icons.light_mode_sharp) : Icon(Icons.dark_mode_sharp), + onClick: () => this.toggleDarkMode(), + border: true, + ), SizedBox(height: 10), isLoading ? SpinKitDualRing( diff --git a/lib/components/main_area.dart b/lib/components/main_area.dart index 26cb1d5..efbbca4 100644 --- a/lib/components/main_area.dart +++ b/lib/components/main_area.dart @@ -12,6 +12,8 @@ class MainArea extends StatelessWidget { @required ScrollController scrollController, @required this.trackTiles, @required this.isLoading, + @required this.isDarkModeEnabled, + @required this.toggleDarkMode, }) : _scrollController = scrollController; final List autocompleteItems; @@ -20,6 +22,8 @@ class MainArea extends StatelessWidget { final ScrollController _scrollController; final List trackTiles; final bool isLoading; + final bool isDarkModeEnabled; + final Function toggleDarkMode; @override Widget build(BuildContext context) { @@ -35,6 +39,8 @@ class MainArea extends StatelessWidget { onKeyboardAction: onKeyboardAction, isAlphabeticalKeyboard: isAlphabeticalKeyboard, isLoading: isLoading, + isDarkModeEnabled: isDarkModeEnabled, + toggleDarkMode: toggleDarkMode, ), ResultArea( scrollController: _scrollController, diff --git a/lib/components/small_button.dart b/lib/components/small_button.dart index 1e8d9f8..a0097f8 100644 --- a/lib/components/small_button.dart +++ b/lib/components/small_button.dart @@ -7,6 +7,7 @@ class SmallButton extends StatelessWidget { final Icon icon; final bool autoFocus; final bool border; + final Color color; const SmallButton({ this.text, @@ -14,29 +15,61 @@ class SmallButton extends StatelessWidget { this.icon, this.autoFocus = false, this.border = false, + this.color = Colors.black, }); @override Widget build(BuildContext context) { - return ButtonTheme( - height: 35, - minWidth: 40, - materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, - child: FlatButton( - shape: border + return TextButtonTheme( + data: TextButtonThemeData( + style: TextButton.styleFrom( + minimumSize: Size(40, 35), + tapTargetSize: MaterialTapTargetSize.shrinkWrap, + padding: EdgeInsets.symmetric(horizontal: 5), + foregroundColor: color, + shape: border ? RoundedRectangleBorder( side: BorderSide( - color: Colors.grey[300], - width: 1, - style: BorderStyle.solid), - borderRadius: BorderRadius.circular(10), + color: Colors.grey[300], + width: 1, + style: BorderStyle.solid + ), + borderRadius: BorderRadius.all(Radius.circular(10)), ) : null, - padding: EdgeInsets.symmetric(horizontal: 5), - child: icon != null ? icon : Text(text), + ), + ), + child: TextButton( + // style: flatButtonStyle, onPressed: onClick, autofocus: autoFocus, + child: icon != null ? icon : Text(text), ), ); } + + // @override + // Widget build(BuildContext context) { + // return ButtonTheme( + // height: 35, + // minWidth: 40, + // materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, + // child: FlatButton( + // shape: border + // ? RoundedRectangleBorder( + // side: BorderSide( + // color: Colors.grey[300], + // width: 1, + // style: BorderStyle.solid + // ), + // borderRadius: BorderRadius.circular(10), + // ) + // : null, + // padding: EdgeInsets.symmetric(horizontal: 5), + // child: icon != null ? icon : Text(text), + // onPressed: onClick, + // autofocus: autoFocus, + // ), + // ); + // } } diff --git a/lib/screens/home.dart b/lib/screens/home.dart index e1c5f36..4d3f430 100644 --- a/lib/screens/home.dart +++ b/lib/screens/home.dart @@ -26,6 +26,9 @@ class _HomeScreenState extends State with WidgetsBindingObserver { static AudioPlayer audioPlayer; bool isLoading = false; + bool isDarkModeEnabled = false; + Color backgroundColor1 = backgroundColorLightMode1; + Color backgroundColor2 = backgroundColorLightMode2; int searchLimit = 10; int amountCorruptTracks = 0; String searchQuery = ""; @@ -314,10 +317,22 @@ class _HomeScreenState extends State with WidgetsBindingObserver { } } + void toggleDarkMode() { + print(isDarkModeEnabled); + if (isDarkModeEnabled) { + print("light"); + } else print("dark"); + setState(() { + isDarkModeEnabled = !isDarkModeEnabled; + backgroundColor1 = isDarkModeEnabled ? backgroundColorDarkMode1 : backgroundColorLightMode1; + backgroundColor2 = isDarkModeEnabled ? backgroundColorDarkMode2 : backgroundColorLightMode2; + }); + } + @override Widget build(BuildContext context) { return Scaffold( - backgroundColor: lightGrey, + backgroundColor: backgroundColor1, body: RawKeyboardListener( focusNode: FocusNode(skipTraversal: true), onKey: _handleHardKeyEvents, @@ -336,8 +351,11 @@ class _HomeScreenState extends State with WidgetsBindingObserver { scrollController: _scrollController, trackTiles: trackTiles, isLoading: isLoading, + isDarkModeEnabled: isDarkModeEnabled, + toggleDarkMode: toggleDarkMode, ), BottomBar( + backgroundColor: backgroundColor2, playPause: playPause, backward: fastRewind, forward: fastForward, diff --git a/lib/screens/loading.dart b/lib/screens/loading.dart index ef6c88a..21c577b 100644 --- a/lib/screens/loading.dart +++ b/lib/screens/loading.dart @@ -54,7 +54,7 @@ class _LoadingScreenState extends State { @override Widget build(BuildContext context) { return Scaffold( - backgroundColor: lightGrey, + backgroundColor: backgroundColorLightMode1, body: Center( child: Column( children: [ diff --git a/lib/util/constants.dart b/lib/util/constants.dart index beb806f..b8986ae 100644 --- a/lib/util/constants.dart +++ b/lib/util/constants.dart @@ -29,8 +29,10 @@ const MaterialColor primaryMaterialColor = const MaterialColor( }, ); const primaryOrange = Color(0xffff5500); -var lightGrey = Colors.grey[200]; -var lighterGrey = Colors.grey[100]; +var backgroundColorLightMode1 = Colors.grey[200]; +var backgroundColorLightMode2 = Colors.grey[100]; +var backgroundColorDarkMode1 = Colors.black; +var backgroundColorDarkMode2 = Colors.black12; const soundCloudHost = "https://soundcloud.com"; const soundCloudApiHost = "https://api-v2.soundcloud.com"; diff --git a/pubspec.lock b/pubspec.lock index dc7927a..e0b9e0e 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,56 +7,56 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.8.2" + version: "2.9.0" audioplayers: dependency: "direct main" description: name: audioplayers url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "2.0.0" audioplayers_android: dependency: transitive description: name: audioplayers_android url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "1.1.4" audioplayers_darwin: dependency: transitive description: name: audioplayers_darwin url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "2.0.0" audioplayers_linux: dependency: transitive description: name: audioplayers_linux url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.0.3" audioplayers_platform_interface: dependency: transitive description: name: audioplayers_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "3.0.0" audioplayers_web: dependency: transitive description: name: audioplayers_web url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "2.1.1" audioplayers_windows: dependency: transitive description: name: audioplayers_windows url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.1.2" beautifulsoup: dependency: "direct main" description: @@ -77,21 +77,14 @@ packages: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" - charcode: - dependency: transitive - description: - name: charcode - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.1" + version: "1.2.1" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" collection: dependency: transitive description: @@ -126,7 +119,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.3.1" ffi: dependency: transitive description: @@ -197,7 +190,7 @@ packages: name: intl url: "https://pub.dartlang.org" source: hosted - version: "0.17.0" + version: "0.18.0" js: dependency: transitive description: @@ -211,21 +204,21 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.11" + version: "0.12.12" material_color_utilities: dependency: transitive description: name: material_color_utilities url: "https://pub.dartlang.org" source: hosted - version: "0.1.4" + version: "0.1.5" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.0" package_info: dependency: "direct main" description: @@ -239,7 +232,7 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.8.2" path_provider: dependency: transitive description: @@ -328,7 +321,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.2" + version: "1.9.0" stack_trace: dependency: transitive description: @@ -349,21 +342,21 @@ packages: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.2.1" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.9" + version: "0.4.12" timeago: dependency: "direct main" description: From 19a823d9b7be28cd010a60686b21a67c7c8036a5 Mon Sep 17 00:00:00 2001 From: timoknapp Date: Sun, 15 Jan 2023 11:50:58 +0000 Subject: [PATCH 2/6] chore(version): bump commit hash --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 5c45e37..29a154c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,7 +11,7 @@ description: A SoundCloud app for FireTV. # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.3.9+170 +version: 1.3.9+171 environment: sdk: ">=2.10.0 <3.0.0" From 56056aaf84733765d8824e18bd8d968bb2c8b0a8 Mon Sep 17 00:00:00 2001 From: timoknapp Date: Sun, 15 Jan 2023 13:20:04 +0100 Subject: [PATCH 3/6] chore: upgrade to flutter 3.3.10 stable release --- .github/workflows/development.yml | 2 +- .github/workflows/release_trigger.yml | 2 +- lib/components/small_button.dart | 25 ------------------------- 3 files changed, 2 insertions(+), 27 deletions(-) diff --git a/.github/workflows/development.yml b/.github/workflows/development.yml index 3cf05b3..14e0123 100644 --- a/.github/workflows/development.yml +++ b/.github/workflows/development.yml @@ -51,7 +51,7 @@ jobs: - name: Setup Flutter uses: subosito/flutter-action@v2 with: - flutter-version: '3.0.3' + flutter-version: '3.3.10' channel: "stable" # or: 'dev' or 'beta' - name: Prepare & Build diff --git a/.github/workflows/release_trigger.yml b/.github/workflows/release_trigger.yml index 523e6a2..dadf070 100644 --- a/.github/workflows/release_trigger.yml +++ b/.github/workflows/release_trigger.yml @@ -57,7 +57,7 @@ jobs: - name: Setup Flutter uses: subosito/flutter-action@v2 with: - flutter-version: '3.0.3' + flutter-version: '3.3.10' channel: "stable" # or: 'dev' or 'beta' - name: Prepare & Build diff --git a/lib/components/small_button.dart b/lib/components/small_button.dart index a0097f8..6b00bc7 100644 --- a/lib/components/small_button.dart +++ b/lib/components/small_button.dart @@ -47,29 +47,4 @@ class SmallButton extends StatelessWidget { ), ); } - - // @override - // Widget build(BuildContext context) { - // return ButtonTheme( - // height: 35, - // minWidth: 40, - // materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, - // child: FlatButton( - // shape: border - // ? RoundedRectangleBorder( - // side: BorderSide( - // color: Colors.grey[300], - // width: 1, - // style: BorderStyle.solid - // ), - // borderRadius: BorderRadius.circular(10), - // ) - // : null, - // padding: EdgeInsets.symmetric(horizontal: 5), - // child: icon != null ? icon : Text(text), - // onPressed: onClick, - // autofocus: autoFocus, - // ), - // ); - // } } From 608562f6aff56ae499dfd474a86a0b87ce2e262d Mon Sep 17 00:00:00 2001 From: timoknapp Date: Sun, 15 Jan 2023 12:20:34 +0000 Subject: [PATCH 4/6] chore(version): bump commit hash --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 29a154c..c4ea3e9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,7 +11,7 @@ description: A SoundCloud app for FireTV. # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.3.9+171 +version: 1.3.9+172 environment: sdk: ">=2.10.0 <3.0.0" From 2b1aac916aed5787af7946e45b3902ad5f92642e Mon Sep 17 00:00:00 2001 From: timoknapp Date: Mon, 16 Jan 2023 12:33:12 +0000 Subject: [PATCH 5/6] chore(version): bump commit hash --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index c4ea3e9..ddc0a9e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,7 +11,7 @@ description: A SoundCloud app for FireTV. # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.3.9+172 +version: 1.3.9+173 environment: sdk: ">=2.10.0 <3.0.0" From 65b54d8f3b75c39e1e39fe243d39ecdff42cf512 Mon Sep 17 00:00:00 2001 From: timoknapp Date: Thu, 26 Jan 2023 15:24:34 +0000 Subject: [PATCH 6/6] chore(version): bump commit hash --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 3129bc6..cd5beba 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,7 +11,7 @@ description: A SoundCloud app for FireTV. # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.3.9+173 +version: 1.3.9+174 environment: sdk: ">=2.10.0 <3.0.0"