Skip to content

Commit

Permalink
feat: use of smaller sized images
Browse files Browse the repository at this point in the history
cd: fix versioning of pubspec
  • Loading branch information
KRTirtho committed Oct 11, 2022
1 parent 4ef7429 commit 0ca97b4
Show file tree
Hide file tree
Showing 17 changed files with 49 additions and 77 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/spotube-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- run: |
curl -sS https://webi.sh/yq | sh
yq -i '.version |= sub("\+\d+", "${{ env.GITHUB_RUN_NUMBER }}")' pubspec.yaml
yq -i '.version |= sub("\+\d+", "-nightly+${{ env.GITHUB_RUN_NUMBER }}")' pubspec.yaml
flutter config --enable-linux-desktop
flutter pub get
dart bin/create-secrets.dart '${{ secrets.LYRICS_SECRET }}' '${{ secrets.SPOTIFY_SECRET }}'
Expand Down Expand Up @@ -60,7 +60,7 @@ jobs:
- run: |
curl -sS https://webi.sh/yq | sh
yq -i '.version |= sub("\+\d+", "${{ env.GITHUB_RUN_NUMBER }}")' pubspec.yaml
yq -i '.version |= sub("\+\d+", "-nightly+${{ env.GITHUB_RUN_NUMBER }}")' pubspec.yaml
flutter pub get
dart bin/create-secrets.dart '${{ secrets.LYRICS_SECRET }}' '${{ secrets.SPOTIFY_SECRET }}'
echo '${{ secrets.KEYSTORE }}' | base64 --decode > android/app/upload-keystore.jks
Expand Down Expand Up @@ -88,7 +88,7 @@ jobs:
cache: true
- run: |
choco install sed make yq -y
yq -i '.version |= sub("\+\d+", "${{ env.GITHUB_RUN_NUMBER }}")' pubspec.yaml
yq -i '.version |= sub("\+\d+", "-nightly+${{ env.GITHUB_RUN_NUMBER }}")' pubspec.yaml
sed -i "s/%{{SPOTUBE_VERSION}}%/${{ env.GITHUB_RUN_NUMBER }}/" windows/runner/Runner.rc
flutter config --enable-windows-desktop
flutter pub get
Expand All @@ -115,7 +115,7 @@ jobs:
with:
cache: true
- run: brew install yq
- run: yq -i '.version |= sub("\+\d+", "${{ env.GITHUB_RUN_NUMBER }}")' pubspec.yaml
- run: yq -i '.version |= sub("\+\d+", "-nightly+${{ env.GITHUB_RUN_NUMBER }}")' pubspec.yaml
- run: flutter config --enable-macos-desktop
- run: flutter pub get
- run: dart bin/create-secrets.dart '${{ secrets.LYRICS_SECRET }}' '${{ secrets.SPOTIFY_SECRET }}'
Expand Down
1 change: 1 addition & 0 deletions bin/verify-pkgbuild.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ void main() {
throw Exception("In new releases pkgrel should be 1");
}
} catch (e) {
// ignore: avoid_print
print("[Failed to parse PKGBUILD] $e");
}
});
Expand Down
7 changes: 0 additions & 7 deletions lib/components/Artist/ArtistProfile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -234,17 +234,10 @@ class ArtistProfile extends HookConsumerWidget {
...topTracks.toList().asMap().entries.map((track) {
String duration =
"${track.value.duration?.inMinutes.remainder(60)}:${PrimitiveUtils.zeroPadNumStr(track.value.duration?.inSeconds.remainder(60) ?? 0)}";
String? thumbnailUrl =
TypeConversionUtils.image_X_UrlString(
track.value.album?.images,
index: (track.value.album?.images?.length ?? 1) - 1,
placeholder: ImagePlaceholder.albumArt,
);
return TrackTile(
playback,
duration: duration,
track: track,
thumbnailUrl: thumbnailUrl,
isActive: playback.track?.id == track.value.id,
onTrackPlayButtonPressed: (currentTrack) =>
playPlaylist(
Expand Down
4 changes: 2 additions & 2 deletions lib/components/Home/Sidebar.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:badges/badges.dart';
import 'package:bitsdojo_window/bitsdojo_window.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:go_router/go_router.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:flutter/material.dart';
import 'package:spotube/components/Shared/UniversalImage.dart';
Expand All @@ -11,7 +12,6 @@ import 'package:spotube/provider/Downloader.dart';
import 'package:spotube/provider/SpotifyRequests.dart';
import 'package:spotube/provider/UserPreferences.dart';
import 'package:spotube/utils/platform.dart';
import 'package:spotube/utils/service_utils.dart';
import 'package:spotube/utils/type_conversion_utils.dart';

final sidebarExtendedStateProvider = StateProvider<bool?>((ref) => null);
Expand All @@ -35,7 +35,7 @@ class Sidebar extends HookConsumerWidget {
}

static void goToSettings(BuildContext context) {
ServiceUtils.navigate(context, "/settings");
GoRouter.of(context).go("/settings");
}

@override
Expand Down
7 changes: 3 additions & 4 deletions lib/components/Library/UserDownloads.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:auto_size_text/auto_size_text.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:spotify/spotify.dart';
Expand Down Expand Up @@ -32,13 +31,13 @@ class UserDownloads extends HookConsumerWidget {
const SizedBox(width: 10),
ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.red[50],
onPrimary: Colors.red[400],
backgroundColor: Colors.red[50],
foregroundColor: Colors.red[400],
),
child: const Text("Cancel All"),
onPressed: downloader.currentlyRunning > 0
? downloader.cancelAll
: null,
child: const Text("Cancel All"),
),
],
),
Expand Down
3 changes: 0 additions & 3 deletions lib/components/Library/UserLocalTracks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,6 @@ class UserLocalTracks extends HookConsumerWidget {
isActive: playback.track?.id == track.id,
isChecked: false,
showCheck: false,
thumbnailUrl: track.album?.images?.isNotEmpty == true
? track.album?.images?.single.url
: "assets/album-placeholder.png",
isLocal: true,
onTrackPlayButtonPressed: (currentTrack) {
return playLocalTracks(
Expand Down
2 changes: 0 additions & 2 deletions lib/components/LoaderShimmers/ShimmerLyrics.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'dart:math';

import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:skeleton_text/skeleton_text.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/components/Login/WebViewLogin.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:go_router/go_router.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:spotube/provider/Auth.dart';
import 'package:spotube/utils/platform.dart';
Expand Down Expand Up @@ -61,6 +60,7 @@ class WebViewLogin extends HookConsumerWidget {
expiration: body.expiration,
);
if (mounted()) {
// ignore: use_build_context_synchronously
ServiceUtils.navigate(context, "/");
}
}
Expand Down
5 changes: 0 additions & 5 deletions lib/components/Player/PlayerQueue.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import 'package:spotube/components/Shared/TrackTile.dart';
import 'package:spotube/hooks/useAutoScrollController.dart';
import 'package:spotube/provider/Playback.dart';
import 'package:spotube/utils/primitive_utils.dart';
import 'package:spotube/utils/type_conversion_utils.dart';

class PlayerQueue extends HookConsumerWidget {
final bool floating;
Expand Down Expand Up @@ -111,10 +110,6 @@ class PlayerQueue extends HookConsumerWidget {
playback,
track: track,
duration: duration,
thumbnailUrl: TypeConversionUtils.image_X_UrlString(
track.value.album?.images,
placeholder: ImagePlaceholder.albumArt,
),
isActive: playback.track?.id == track.value.id,
onTrackPlayButtonPressed: (currentTrack) async {
if (playback.track?.id == track.value.id) return;
Expand Down
1 change: 0 additions & 1 deletion lib/components/Player/PlayerView.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class PlayerView extends HookConsumerWidget {
String albumArt = useMemoized(
() => TypeConversionUtils.image_X_UrlString(
currentTrack?.album?.images,
index: (currentTrack?.album?.images?.length ?? 1) - 1,
placeholder: ImagePlaceholder.albumArt,
),
[currentTrack?.album?.images],
Expand Down
1 change: 0 additions & 1 deletion lib/components/Playlist/PlaylistCard.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:spotify/spotify.dart';
import 'package:spotube/components/Shared/PlaybuttonCard.dart';
Expand Down
5 changes: 0 additions & 5 deletions lib/components/Search/Search.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,6 @@ class Search extends HookConsumerWidget {
playback,
track: track,
duration: duration,
thumbnailUrl:
TypeConversionUtils.image_X_UrlString(
track.value.album?.images,
placeholder: ImagePlaceholder.albumArt,
),
isActive: playback.track?.id == track.value.id,
onTrackPlayButtonPressed: (currentTrack) async {
var isPlaylistPlaying = playback.playlist?.id !=
Expand Down
18 changes: 9 additions & 9 deletions lib/components/Shared/PlaybuttonCard.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:spotube/components/Shared/HoverBuilder.dart';
import 'package:spotube/components/Shared/SpotubeMarqueeText.dart';
Expand Down Expand Up @@ -58,6 +57,7 @@ class PlaybuttonCard extends StatelessWidget {
borderRadius: BorderRadius.circular(8),
child: UniversalImage(
path: imageUrl,
width: 200,
placeholder: (context, url) =>
Image.asset("assets/placeholder.png"),
),
Expand All @@ -69,6 +69,14 @@ class PlaybuttonCard extends StatelessWidget {
child: Builder(builder: (context) {
return ElevatedButton(
onPressed: onPlaybuttonPressed,
style: ButtonStyle(
shape: MaterialStateProperty.all(
const CircleBorder(),
),
padding: MaterialStateProperty.all(
const EdgeInsets.all(16),
),
),
child: isLoading
? const SizedBox(
height: 23,
Expand All @@ -80,14 +88,6 @@ class PlaybuttonCard extends StatelessWidget {
? Icons.pause_rounded
: Icons.play_arrow_rounded,
),
style: ButtonStyle(
shape: MaterialStateProperty.all(
const CircleBorder(),
),
padding: MaterialStateProperty.all(
const EdgeInsets.all(16),
),
),
);
}),
)
Expand Down
2 changes: 1 addition & 1 deletion lib/components/Shared/TrackCollectionView.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ class TrackCollectionView extends HookConsumerWidget {
const CircleBorder(),
),
),
onPressed: tracksSnapshot.asData?.value != null ? onPlay : null,
child: Icon(
isPlaying ? Icons.stop_rounded : Icons.play_arrow_rounded,
color: Theme.of(context).backgroundColor,
),
onPressed: tracksSnapshot.asData?.value != null ? onPlay : null,
),
),
];
Expand Down
47 changes: 25 additions & 22 deletions lib/components/Shared/TrackTile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class TrackTile extends HookConsumerWidget {
final Playback playback;
final MapEntry<int, Track> track;
final String duration;
final String? thumbnailUrl;
final void Function(Track currentTrack)? onTrackPlayButtonPressed;
final logger = getLogger(TrackTile);
final bool userPlaylist;
Expand All @@ -43,7 +42,6 @@ class TrackTile extends HookConsumerWidget {
required this.isActive,
this.playlistId,
this.userPlaylist = false,
this.thumbnailUrl,
this.onTrackPlayButtonPressed,
this.showAlbum = true,
this.isChecked = false,
Expand Down Expand Up @@ -184,6 +182,12 @@ class TrackTile extends HookConsumerWidget {
});
}

final String thumbnailUrl = TypeConversionUtils.image_X_UrlString(
track.value.album?.images,
placeholder: ImagePlaceholder.albumArt,
index: track.value.album?.images?.length == 1 ? 0 : 2,
);

return AnimatedContainer(
duration: const Duration(milliseconds: 500),
decoration: BoxDecoration(
Expand All @@ -209,28 +213,27 @@ class TrackTile extends HookConsumerWidget {
child: Text((track.key + 1).toString()),
),
),
if (thumbnailUrl != null)
Padding(
padding: EdgeInsets.symmetric(
horizontal: breakpoint.isMoreThan(Breakpoints.md) ? 8.0 : 0,
vertical: 8.0,
),
child: ClipRRect(
borderRadius: const BorderRadius.all(Radius.circular(5)),
child: UniversalImage(
path: thumbnailUrl!,
height: 40,
width: 40,
placeholder: (context, url) {
return Image.asset(
"assets/album-placeholder.png",
height: 40,
width: 40,
);
},
),
Padding(
padding: EdgeInsets.symmetric(
horizontal: breakpoint.isMoreThan(Breakpoints.md) ? 8.0 : 0,
vertical: 8.0,
),
child: ClipRRect(
borderRadius: const BorderRadius.all(Radius.circular(5)),
child: UniversalImage(
path: thumbnailUrl,
height: 40,
width: 40,
placeholder: (context, url) {
return Image.asset(
"assets/album-placeholder.png",
height: 40,
width: 40,
);
},
),
),
),
IconButton(
icon: Icon(
playback.track?.id != null &&
Expand Down
8 changes: 0 additions & 8 deletions lib/components/Shared/TracksTableView.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:queue/queue.dart';
import 'package:spotify/spotify.dart';
import 'package:spotube/components/Shared/DownloadConfirmationDialog.dart';
import 'package:spotube/components/Shared/NotFound.dart';
Expand All @@ -10,7 +9,6 @@ import 'package:spotube/hooks/useBreakpoints.dart';
import 'package:spotube/provider/Downloader.dart';
import 'package:spotube/provider/Playback.dart';
import 'package:spotube/utils/primitive_utils.dart';
import 'package:spotube/utils/type_conversion_utils.dart';

class TracksTableView extends HookConsumerWidget {
final void Function(Track currentTrack)? onTrackPlayButtonPressed;
Expand Down Expand Up @@ -149,11 +147,6 @@ class TracksTableView extends HookConsumerWidget {
],
),
...tracks.asMap().entries.map((track) {
String? thumbnailUrl = TypeConversionUtils.image_X_UrlString(
track.value.album?.images,
index: (track.value.album?.images?.length ?? 1) - 1,
placeholder: ImagePlaceholder.albumArt,
);
String duration =
"${track.value.duration?.inMinutes.remainder(60)}:${PrimitiveUtils.zeroPadNumStr(track.value.duration?.inSeconds.remainder(60) ?? 0)}";
return InkWell(
Expand Down Expand Up @@ -181,7 +174,6 @@ class TracksTableView extends HookConsumerWidget {
playlistId: playlistId,
track: track,
duration: duration,
thumbnailUrl: thumbnailUrl,
userPlaylist: userPlaylist,
isActive: playback.track?.id == track.value.id,
onTrackPlayButtonPressed: onTrackPlayButtonPressed,
Expand Down
5 changes: 3 additions & 2 deletions lib/utils/type_conversion_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ enum ImagePlaceholder {
abstract class TypeConversionUtils {
static String image_X_UrlString(
List<Image>? images, {
int index = 0,
int index = 1,
required ImagePlaceholder placeholder,
}) {
final String placeholderUrl = {
Expand All @@ -31,8 +31,9 @@ abstract class TypeConversionUtils {
ImagePlaceholder.online:
"https://avatars.dicebear.com/api/bottts/${PrimitiveUtils.uuid.v4()}.png",
}[placeholder]!;

return images != null && images.isNotEmpty
? images[0].url!
? images[index > images.length - 1 ? images.length - 1 : index].url!
: placeholderUrl;
}

Expand Down

0 comments on commit 0ca97b4

Please sign in to comment.