Skip to content

Commit

Permalink
Fixed Enabled/disabled color of toggles are misleading #178
Browse files Browse the repository at this point in the history
  • Loading branch information
anandnet committed Apr 6, 2024
1 parent 7754115 commit 4c0e5ff
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 21 deletions.
18 changes: 11 additions & 7 deletions lib/ui/player/mini_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ class MiniPlayer extends StatelessWidget {
.inactiveTrackColor,
bufferedBarColor: Theme.of(context)
.sliderTheme
.activeTrackColor,
.valueIndicatorColor,
progressBarColor: Theme.of(context)
.sliderTheme
.valueIndicatorColor,
.activeTrackColor,
thumbColor:
Theme.of(context).sliderTheme.thumbColor,
timeLabelTextStyle:
Expand Down Expand Up @@ -249,7 +249,8 @@ class MiniPlayer extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
padding: const EdgeInsets.only(right: 20,left: 10),
padding: const EdgeInsets.only(
right: 20, left: 10),
height: 20,
width: 180,
child: Obx(() {
Expand All @@ -264,7 +265,8 @@ class MiniPlayer extends StatelessWidget {
child: Icon(
volume == 0
? Icons.volume_off
: volume > 0 && volume < 50
: volume > 0 &&
volume < 50
? Icons.volume_down
: Icons.volume_up,
size: 20,
Expand All @@ -274,7 +276,6 @@ class MiniPlayer extends StatelessWidget {
child: SliderTheme(
data: SliderTheme.of(context)
.copyWith(
activeTrackColor: Colors.white,
trackHeight: 2,
thumbShape:
const RoundSliderThumbShape(
Expand All @@ -285,9 +286,12 @@ class MiniPlayer extends StatelessWidget {
overlayRadius: 10.0),
),
child: Slider(
value: playerController.volume.value/100,
value: playerController
.volume.value /
100,
onChanged: (value) {
playerController.setVolume((value*100).toInt());
playerController.setVolume(
(value * 100).toInt());
},
),
),
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/player/player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -439,9 +439,9 @@ class Player extends StatelessWidget {
baseBarColor:
Theme.of(context).sliderTheme.inactiveTrackColor,
bufferedBarColor:
Theme.of(context).sliderTheme.activeTrackColor,
progressBarColor:
Theme.of(context).sliderTheme.valueIndicatorColor,
progressBarColor:
Theme.of(context).sliderTheme.activeTrackColor,
thumbColor: Theme.of(context).sliderTheme.thumbColor,
timeLabelTextStyle:
Theme.of(context).textTheme.titleMedium,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,11 @@ class PlayListNAlbumScreenController extends GetxController {

Future<void> fetchSongsfromDatabase(id) async {
box = await Hive.openBox(id);
songList.value = box.values
final List<MediaItem> songList_ = box.values
.map<MediaItem?>((item) => MediaItemBuilder.fromJson(item))
.whereType<MediaItem>()
.toList();
songList.value = id == "LIBRP" ? songList_.reversed.toList() : songList_;
isContentFetched.value = true;
checkDownloadStatus();
}
Expand Down Expand Up @@ -312,7 +313,7 @@ class PlayListNAlbumScreenController extends GetxController {

songList.removeWhere((song) => song.id == element.id);
}
if (!isoffline) await box_.close();
if (!isoffline) await box_.close();
}

List<MediaItem> selectedSongs() {
Expand Down
47 changes: 37 additions & 10 deletions lib/ui/utils/theme_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class ThemeController extends GetxController {
);

final baseTheme = ThemeData(
useMaterial3: false,
useMaterial3: false,
primaryColor: primarySwatch![500],
colorScheme: ColorScheme.fromSwatch(
accentColor: primarySwatch[200],
Expand Down Expand Up @@ -128,6 +128,15 @@ class ThemeController extends GetxController {
letterSpacing: 1,
fontWeight: FontWeight.bold),
),
switchTheme: SwitchThemeData(
thumbColor: MaterialStateProperty.resolveWith<Color>(
(Set<MaterialState> states) {
if (states.contains(MaterialState.selected)) {
return primarySwatch[100]!.withLightness(50);
}
return Colors.white.withOpacity(0.3);
}),
),
indicatorColor: Colors.white,
progressIndicatorTheme: ProgressIndicatorThemeData(
linearTrackColor: (primarySwatch[300])!.computeLuminance() > 0.3
Expand All @@ -146,8 +155,8 @@ class ThemeController extends GetxController {
color: primarySwatch[100], fontWeight: FontWeight.bold)),
sliderTheme: SliderThemeData(
inactiveTrackColor: primarySwatch[300],
activeTrackColor: primarySwatch[400],
valueIndicatorColor: textColor,
activeTrackColor: textColor,
valueIndicatorColor: primarySwatch[400],
thumbColor: Colors.white,
)
//scaffoldBackgroundColor: primarySwatch[700]
Expand All @@ -166,7 +175,7 @@ class ThemeController extends GetxController {
systemNavigationBarContrastEnforced: true),
);
final baseTheme = ThemeData(
useMaterial3: false,
useMaterial3: false,
brightness: Brightness.dark,
canvasColor: Colors.black,
primaryColor: Colors.black,
Expand Down Expand Up @@ -210,11 +219,20 @@ class ThemeController extends GetxController {
//base bar color
inactiveTrackColor: Colors.white30,
//buffered progress
activeTrackColor: Colors.black38,
activeTrackColor: Colors.white,
//progress bar color
valueIndicatorColor: Colors.white,
valueIndicatorColor: Colors.black38,
thumbColor: Colors.white,
),
switchTheme: SwitchThemeData(
thumbColor: MaterialStateProperty.resolveWith<Color>(
(Set<MaterialState> states) {
if (states.contains(MaterialState.selected)) {
return Colors.white.withLightness(50);
}
return Colors.white.withOpacity(0.3);
}),
),
inputDecorationTheme: const InputDecorationTheme(
focusColor: Colors.white,
focusedBorder: UnderlineInputBorder(
Expand All @@ -233,7 +251,7 @@ class ThemeController extends GetxController {
systemNavigationBarContrastEnforced: false),
);
final baseTheme = ThemeData(
useMaterial3: false,
useMaterial3: false,
brightness: Brightness.light,
canvasColor: Colors.white,
colorScheme: ColorScheme.fromSwatch(
Expand Down Expand Up @@ -273,15 +291,24 @@ class ThemeController extends GetxController {
color: Colors.grey[800], fontWeight: FontWeight.bold)),
bottomSheetTheme: const BottomSheetThemeData(
backgroundColor: Colors.white, modalBarrierColor: Colors.white),
sliderTheme: SliderThemeData(
sliderTheme:SliderThemeData(
//base bar color
inactiveTrackColor: Colors.black38,
//buffered progress
activeTrackColor: Colors.white38,
activeTrackColor: Colors.grey[800],
//progress bar color
valueIndicatorColor: Colors.grey[800],
valueIndicatorColor: Colors.white38,
thumbColor: Colors.grey[800],
),
switchTheme: SwitchThemeData(
thumbColor: MaterialStateProperty.resolveWith<Color>(
(Set<MaterialState> states) {
if (states.contains(MaterialState.selected)) {
return Colors.white.withLightness(50);
}
return Colors.grey.withOpacity(0.3);
}),
),
inputDecorationTheme: const InputDecorationTheme(
focusColor: Colors.black,
focusedBorder: UnderlineInputBorder(
Expand Down

0 comments on commit 4c0e5ff

Please sign in to comment.