Skip to content

Commit

Permalink
feat: platform slider and progress indicator integration
Browse files Browse the repository at this point in the history
  • Loading branch information
KRTirtho committed Oct 31, 2022
1 parent 512446d commit 46b00ba
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 68 deletions.
7 changes: 4 additions & 3 deletions lib/components/Artist/ArtistProfile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ class ArtistProfile extends HookConsumerWidget {
return const SizedBox(
height: 20,
width: 20,
child: CircularProgressIndicator(),
child:
PlatformCircularProgressIndicator(),
);
}

Expand Down Expand Up @@ -214,7 +215,7 @@ class ArtistProfile extends HookConsumerWidget {
);

if (topTracksQuery.isLoading || !topTracksQuery.hasData) {
return const CircularProgressIndicator.adaptive();
return const PlatformCircularProgressIndicator();
} else if (topTracksQuery.hasError) {
return Center(
child: Text(topTracksQuery.error.toString()),
Expand Down Expand Up @@ -313,7 +314,7 @@ class ArtistProfile extends HookConsumerWidget {
);

if (relatedArtists.isLoading || !relatedArtists.hasData) {
return const CircularProgressIndicator.adaptive();
return const PlatformCircularProgressIndicator();
} else if (relatedArtists.hasError) {
return Center(
child: Text(relatedArtists.error.toString()),
Expand Down
11 changes: 6 additions & 5 deletions lib/components/Home/Sidebar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class Sidebar extends HookConsumerWidget {
),
Text(
"Spotube",
style: Theme.of(context).textTheme.headline4,
style: PlatformTheme.of(context).textTheme?.headline,
),
PlatformIconButton(
icon: const Icon(Icons.menu_rounded),
Expand Down Expand Up @@ -207,7 +207,7 @@ class SidebarFooter extends HookConsumerWidget {
children: [
if (auth.isLoggedIn && data == null)
const Center(
child: CircularProgressIndicator(),
child: PlatformCircularProgressIndicator(),
)
else if (data != null)
Flexible(
Expand All @@ -233,9 +233,10 @@ class SidebarFooter extends HookConsumerWidget {
maxLines: 1,
softWrap: false,
overflow: TextOverflow.fade,
style: const TextStyle(
fontWeight: FontWeight.bold,
),
style: PlatformTheme.of(context)
.textTheme
?.body
?.copyWith(fontWeight: FontWeight.bold),
),
),
],
Expand Down
2 changes: 1 addition & 1 deletion lib/components/Library/UserDownloads.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class UserDownloads extends HookConsumerWidget {
trailing: const SizedBox(
width: 30,
height: 30,
child: CircularProgressIndicator.adaptive(),
child: PlatformCircularProgressIndicator(),
),
subtitle: Text(
TypeConversionUtils.artists_X_String(
Expand Down
6 changes: 3 additions & 3 deletions lib/components/Player/Player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ class Player extends HookConsumerWidget {
android: null,
ios: Border(
top: BorderSide(
color: CupertinoTheme.of(context).barBackgroundColor,
color: PlatformTheme.of(context).borderColor ?? Colors.transparent,
width: 1,
),
),
macos: Border(
top: BorderSide(
color: MacosTheme.of(context).dividerColor,
color: PlatformTheme.of(context).borderColor ?? Colors.transparent,
width: 1,
),
),
Expand Down Expand Up @@ -130,7 +130,7 @@ class Player extends HookConsumerWidget {
}
}
},
child: Slider.adaptive(
child: PlatformSlider(
min: 0,
max: 1,
value: volume.value,
Expand Down
4 changes: 2 additions & 2 deletions lib/components/Player/PlayerControls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class PlayerControls extends HookConsumerWidget {
children: [
Tooltip(
message: "Slide to seek forward or backward",
child: Slider.adaptive(
child: PlatformSlider(
focusNode: FocusNode(),
// cannot divide by zero
// there's an edge case for value being bigger
Expand Down Expand Up @@ -174,7 +174,7 @@ class PlayerControls extends HookConsumerWidget {
? const SizedBox(
height: 20,
width: 20,
child: CircularProgressIndicator(),
child: PlatformCircularProgressIndicator(),
)
: Icon(
playback.isPlaying
Expand Down
3 changes: 2 additions & 1 deletion lib/components/Playlist/PlaylistGenreView.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:platform_ui/platform_ui.dart';
import 'package:spotify/spotify.dart';
import 'package:spotube/components/Playlist/PlaylistCard.dart';
import 'package:spotube/components/Shared/PageWindowTitleBar.dart';
Expand Down Expand Up @@ -47,7 +48,7 @@ class PlaylistGenreView extends ConsumerWidget {
return const Center(child: Text("Error occurred"));
}
if (!snapshot.hasData) {
return const CircularProgressIndicator.adaptive();
return const PlatformCircularProgressIndicator();
}
return Center(
child: Wrap(
Expand Down
10 changes: 5 additions & 5 deletions lib/components/Search/Search.dart
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class Search extends HookConsumerWidget {
),
if (searchTrack.isLoading &&
!searchTrack.isFetchingNextPage)
const CircularProgressIndicator()
const PlatformCircularProgressIndicator()
else if (searchTrack.hasError)
Text(
searchTrack.error?[searchTrack.pageParams.last])
Expand Down Expand Up @@ -190,7 +190,7 @@ class Search extends HookConsumerWidget {
? null
: () => searchTrack.fetchNextPage(),
child: searchTrack.isFetchingNextPage
? const CircularProgressIndicator()
? const PlatformCircularProgressIndicator()
: const Text("Load more"),
),
),
Expand All @@ -202,7 +202,7 @@ class Search extends HookConsumerWidget {
const SizedBox(height: 10),
if (searchPlaylist.isLoading &&
!searchPlaylist.isFetchingNextPage)
const CircularProgressIndicator()
const PlatformCircularProgressIndicator()
else if (searchPlaylist.hasError)
Text(searchPlaylist
.error?[searchPlaylist.pageParams.last])
Expand Down Expand Up @@ -256,7 +256,7 @@ class Search extends HookConsumerWidget {
const SizedBox(height: 10),
if (searchArtist.isLoading &&
!searchArtist.isFetchingNextPage)
const CircularProgressIndicator()
const PlatformCircularProgressIndicator()
else if (searchArtist.hasError)
Text(searchArtist
.error?[searchArtist.pageParams.last])
Expand Down Expand Up @@ -310,7 +310,7 @@ class Search extends HookConsumerWidget {
const SizedBox(height: 10),
if (searchAlbum.isLoading &&
!searchAlbum.isFetchingNextPage)
const CircularProgressIndicator()
const PlatformCircularProgressIndicator()
else if (searchAlbum.hasError)
Text(
searchAlbum.error?[searchAlbum.pageParams.last])
Expand Down
8 changes: 5 additions & 3 deletions lib/components/Shared/HeartButton.dart
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class TrackHeartButton extends HookConsumerWidget {
);
final toggler = useTrackToggleLike(track, ref);
if (toggler.item3.isLoading || !toggler.item3.hasData) {
return const CircularProgressIndicator();
return const PlatformCircularProgressIndicator();
}

return HeartButton(
Expand Down Expand Up @@ -182,7 +182,8 @@ class PlaylistHeartButton extends HookConsumerWidget {
titleImage,
).dominantColor;

if (me.isLoading || !me.hasData) return const CircularProgressIndicator();
if (me.isLoading || !me.hasData)
return const PlatformCircularProgressIndicator();

return HeartButton(
isLiked: isLikedQuery.data ?? false,
Expand Down Expand Up @@ -236,7 +237,8 @@ class AlbumHeartButton extends HookConsumerWidget {
},
);

if (me.isLoading || !me.hasData) return const CircularProgressIndicator();
if (me.isLoading || !me.hasData)
return const PlatformCircularProgressIndicator();

return HeartButton(
isLiked: isLiked,
Expand Down
48 changes: 6 additions & 42 deletions lib/components/Shared/PlaybuttonCard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,7 @@ class PlaybuttonCard extends HookWidget {

@override
Widget build(BuildContext context) {
final backgroundColor = usePlatformProperty<Color?>(
(context) => PlatformProperty(
android: Theme.of(context).backgroundColor,
ios: CupertinoTheme.of(context).scaffoldBackgroundColor,
macos: MacosTheme.of(context).brightness == Brightness.dark
? Colors.grey[800]
: Colors.blueGrey[50],
linux: Theme.of(context).backgroundColor,
windows: FluentUI.FluentTheme.maybeOf(context)?.scaffoldBackgroundColor,
),
);
final backgroundColor = PlatformTheme.of(context).secondaryBackgroundColor;

final boxShadow = usePlatformProperty<BoxShadow?>(
(context) => PlatformProperty(
Expand All @@ -64,28 +54,9 @@ class PlaybuttonCard extends HookWidget {
),
);

final titleStyle = usePlatformProperty<TextStyle?>(
(context) => PlatformProperty(
android: Theme.of(context).textTheme.bodyMedium,
ios: CupertinoTheme.of(context).textTheme.textStyle,
macos: MacosTheme.of(context).typography.body,
linux: Theme.of(context).textTheme.bodyMedium,
windows: FluentUI.FluentTheme.maybeOf(context)?.typography.body,
),
);
final titleStyle = PlatformTextTheme.of(context).body;

final descriptionStyle = usePlatformProperty<TextStyle?>(
(context) => PlatformProperty(
android: Theme.of(context).textTheme.caption,
ios: CupertinoTheme.of(context)
.textTheme
.textStyle
.copyWith(fontSize: 13),
macos: MacosTheme.of(context).typography.caption1,
linux: Theme.of(context).textTheme.caption,
windows: FluentUI.FluentTheme.maybeOf(context)?.typography.caption,
),
);
final descriptionStyle = PlatformTextTheme.of(context).caption;

final splash = usePlatformProperty<InteractiveInkFeatureFactory?>(
(context) => PlatformProperty.multiPlatformGroup({
Expand All @@ -98,15 +69,7 @@ class PlaybuttonCard extends HookWidget {
}),
);

final iconBgColor = usePlatformProperty<Color?>(
(context) => PlatformProperty(
android: Theme.of(context).primaryColor,
ios: CupertinoTheme.of(context).primaryColor,
macos: MacosTheme.of(context).primaryColor,
linux: Theme.of(context).primaryColor,
windows: FluentUI.FluentTheme.maybeOf(context)?.accentColor,
),
);
final iconBgColor = PlatformTheme.of(context).primaryColor;

return Container(
margin: margin,
Expand Down Expand Up @@ -174,7 +137,8 @@ class PlaybuttonCard extends HookWidget {
? const SizedBox(
height: 23,
width: 23,
child: CircularProgressIndicator(),
child:
PlatformCircularProgressIndicator(),
)
: Icon(
isPlaying
Expand Down
2 changes: 1 addition & 1 deletion lib/components/Shared/TrackTile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class TrackTile extends HookConsumerWidget {
width: 300,
child: !snapshot.hasData
? const Center(
child: CircularProgressIndicator.adaptive())
child: PlatformCircularProgressIndicator())
: ListView.builder(
shrinkWrap: true,
itemCount: snapshot.data!.length,
Expand Down
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class SpotubeState extends ConsumerState<Spotube> with WidgetsBindingObserver {
};
}, []);

platform = TargetPlatform.macOS;
platform = TargetPlatform.windows;

return PlatformApp.router(
routeInformationParser: router.routeInformationParser,
Expand Down
5 changes: 4 additions & 1 deletion lib/themes/light-theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ final macosTheme = MacosThemeData.light().copyWith(
),
iconTheme: MacosIconThemeData(size: 16),
iconButtonTheme: MacosIconButtonThemeData(),
typography: MacosTypography(color: Colors.green),
);
final macosDarkTheme = MacosThemeData.dark().copyWith(
typography: MacosTypography(color: Colors.red),
);
final macosDarkTheme = MacosThemeData.dark();
final iosTheme = CupertinoThemeData();

0 comments on commit 46b00ba

Please sign in to comment.