Skip to content

Commit

Permalink
improved code
Browse files Browse the repository at this point in the history
  • Loading branch information
gokadzev committed Mar 26, 2023
1 parent 93eb0ce commit 6a64f8a
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 55 deletions.
5 changes: 1 addition & 4 deletions lib/screens/local_music_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:musify/API/musify.dart';
import 'package:musify/services/audio_manager.dart';
import 'package:musify/services/offline_audio.dart';
import 'package:musify/style/app_colors.dart';
import 'package:musify/style/app_themes.dart';
import 'package:musify/widgets/spinner.dart';
import 'package:on_audio_query/on_audio_query.dart';
Expand Down Expand Up @@ -114,9 +113,7 @@ class _LocalMusicPageState extends State<LocalMusicPage> {
),
child: Text(
AppLocalizations.of(context)!.playAll.toUpperCase(),
style: TextStyle(
color: isAccentWhite(),
),
style: Theme.of(context).textTheme.bodyMedium,
),
),
],
Expand Down
46 changes: 16 additions & 30 deletions lib/screens/playlist_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'dart:math';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:musify/API/musify.dart';
import 'package:musify/style/app_colors.dart';
import 'package:musify/style/app_themes.dart';
import 'package:musify/utilities/flutter_toast.dart';
import 'package:musify/widgets/playlist_cube.dart';
Expand Down Expand Up @@ -119,11 +118,7 @@ class _PlaylistPageState extends State<PlaylistPage> {
child: Text(
widget.playlist['title'].toString(),
textAlign: TextAlign.center,
style: TextStyle(
color: colorScheme.primary,
fontSize: 18,
fontWeight: FontWeight.w600,
),
style: Theme.of(context).textTheme.bodyMedium,
),
);
}
Expand All @@ -132,36 +127,27 @@ class _PlaylistPageState extends State<PlaylistPage> {
return Text(
widget.playlist['header_desc'].toString(),
textAlign: TextAlign.center,
style: TextStyle(
color: colorScheme.primary,
fontSize: 10,
fontWeight: FontWeight.w600,
),
style: Theme.of(context).textTheme.bodySmall,
);
}

Widget _buildPlayAllButton() {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 10),
child: ElevatedButton(
onPressed: () {
setActivePlaylist(widget.playlist);
showToast(
AppLocalizations.of(context)!.queueInitText,
);
},
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all<Color>(
colorScheme.primary,
),
),
child: Text(
AppLocalizations.of(context)!.playAll.toUpperCase(),
style: TextStyle(
color: isAccentWhite(),
),
return ElevatedButton(
onPressed: () {
setActivePlaylist(widget.playlist);
showToast(
AppLocalizations.of(context)!.queueInitText,
);
},
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all<Color>(
colorScheme.primary,
),
),
child: Text(
AppLocalizations.of(context)!.playAll.toUpperCase(),
style: Theme.of(context).textTheme.bodyMedium,
),
);
}

Expand Down
5 changes: 1 addition & 4 deletions lib/screens/setup_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:musify/services/data_manager.dart';
import 'package:musify/services/settings_manager.dart';
import 'package:musify/style/app_colors.dart';
import 'package:musify/style/app_themes.dart';
import 'package:musify/widgets/marque.dart';

Expand Down Expand Up @@ -54,9 +53,7 @@ class _SetupPageState extends State<SetupPage> {
),
child: Text(
AppLocalizations.of(context)!.add.toUpperCase(),
style: TextStyle(
color: isAccentWhite(),
),
style: Theme.of(context).textTheme.bodyMedium,
),
),
),
Expand Down
5 changes: 1 addition & 4 deletions lib/screens/user_liked_songs_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'package:fluentui_system_icons/fluentui_system_icons.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:musify/API/musify.dart';
import 'package:musify/style/app_colors.dart';
import 'package:musify/style/app_themes.dart';
import 'package:musify/widgets/song_bar.dart';

Expand Down Expand Up @@ -105,9 +104,7 @@ class _UserLikedSongsState extends State<UserLikedSongs> {
),
child: Text(
AppLocalizations.of(context)!.playAll.toUpperCase(),
style: TextStyle(
color: isAccentWhite(),
),
style: Theme.of(context).textTheme.bodyMedium,
),
),
],
Expand Down
3 changes: 1 addition & 2 deletions lib/screens/user_playlists_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'package:fluentui_system_icons/fluentui_system_icons.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:musify/API/musify.dart';
import 'package:musify/style/app_colors.dart';
import 'package:musify/style/app_themes.dart';
import 'package:musify/utilities/flutter_toast.dart';
import 'package:musify/widgets/playlist_cube.dart';
Expand Down Expand Up @@ -67,7 +66,7 @@ class _UserPlaylistsPageState extends State<UserPlaylistsPage> {
backgroundColor: colorScheme.primary,
child: Icon(
FluentIcons.add_24_filled,
color: isAccentWhite(),
color: Theme.of(context).textTheme.bodyMedium!.color,
),
),
body: SingleChildScrollView(
Expand Down
7 changes: 0 additions & 7 deletions lib/style/app_colors.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:flutter/material.dart';
import 'package:musify/style/app_themes.dart';

final availableColors = <Color>[
const Color(0xFF9ACD32),
Expand Down Expand Up @@ -88,9 +87,3 @@ MaterialColor getPrimarySwatch(Color color) {
),
});
}

Color isAccentWhite() {
return colorScheme.primary != const Color(0xFFFFFFFF)
? Colors.white
: Colors.black;
}
5 changes: 3 additions & 2 deletions lib/style/app_themes.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:dynamic_color/dynamic_color.dart';
import 'package:flutter/material.dart';
import 'package:hive/hive.dart';
import 'package:musify/style/app_colors.dart';
Expand Down Expand Up @@ -27,7 +28,7 @@ ThemeData getAppDarkTheme() {
bottomSheetTheme: const BottomSheetThemeData(
backgroundColor: Color(0xFF121212),
),
colorScheme: colorScheme,
colorScheme: colorScheme.harmonized(),
visualDensity: VisualDensity.adaptivePlatformDensity,
fontFamily: 'Ubuntu',
useMaterial3: true,
Expand Down Expand Up @@ -86,7 +87,7 @@ ThemeData getAppLightTheme() {
return ThemeData(
scaffoldBackgroundColor: Colors.white,
canvasColor: Colors.white,
colorScheme: colorScheme,
colorScheme: colorScheme.harmonized(),
bottomSheetTheme: const BottomSheetThemeData(backgroundColor: Colors.white),
appBarTheme: AppBarTheme(
backgroundColor: Colors.white,
Expand Down
6 changes: 4 additions & 2 deletions lib/utilities/flutter_toast.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:musify/style/app_colors.dart';
import 'package:musify/style/app_themes.dart';

void showToast(String text) {
Fluttertoast.showToast(
backgroundColor: colorScheme.primary,
textColor: isAccentWhite(),
textColor: colorScheme.primary != const Color(0xFFFFFFFF)
? Colors.white
: Colors.black,
msg: text,
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.BOTTOM,
Expand Down

0 comments on commit 6a64f8a

Please sign in to comment.