Skip to content

Commit

Permalink
enhanced image quality
Browse files Browse the repository at this point in the history
  • Loading branch information
sheikhhaziq committed Jul 1, 2024
1 parent d68385e commit cce43ac
Show file tree
Hide file tree
Showing 17 changed files with 235 additions and 105 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div align="center">
<img src="./android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png" width="128" height="128" style="display: block; margin: 0 auto"/>
<h1>Gyawun (Formerly Vibe Music)</h1>
<p>A Flutter application for streaming music from Jio Saavn and YouTube Music</p>
<h1>Gyawun</h1>
<p>A Flutter application for streaming music from YouTube Music</p>
<img src="https://hits.dwyl.com/jhelumcorp/gyawun.svg?style=flat-square" />
<a href="https://github.com/sheikhhaziq/gyavyn/releases/latest"><img src="https://img.shields.io/github/v/release/sheikhhaziq/gyawun?style=flat" alt="Latest release" /></a>
<a href="https://github.com/sheikhhaziq/gyawun/commits"><img src="https://img.shields.io/github/commits-since/sheikhhaziq/gyawun/latest?style=flat" alt="Commits since latest release" /></a>
Expand All @@ -24,8 +24,8 @@
<img src="./fastlane/metadata/android/en-US/images/phoneScreenshots/01.jpg" width="30%" />
<img src="./fastlane/metadata/android/en-US/images/phoneScreenshots/02.jpg" width="30%" />
<img src="./fastlane/metadata/android/en-US/images/phoneScreenshots/03.jpg" width="30%" />

<p>
<p align="center">
<img src="./fastlane/metadata/android/en-US/images/phoneScreenshots/04.jpg" width="30%" />
<img src="./fastlane/metadata/android/en-US/images/phoneScreenshots/05.jpg" width="30%" />
<img src="./fastlane/metadata/android/en-US/images/phoneScreenshots/06.jpg" width="30%" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ class _BrowseScreenState extends State<BrowseScreen> {
sections.length == 1 ||
sec.$1 == 0);
}),
const SizedBox(height: 8),
if (!nextLoading && continuation != null)
const SizedBox(height: 64),
if (nextLoading) const CircularProgressIndicator(),
if (nextLoading) const CircularProgressIndicator(),
],
),
Expand Down Expand Up @@ -214,6 +216,8 @@ class _HeaderWidgetState extends State<HeaderWidget> {
if (header['videoId'] != null || header['playlistId'] != null)
MaterialButton(
onPressed: () async {
BottomMessage.showText(
context, 'Songs will start playing soon.');
await GetIt.I<MediaPlayer>()
.startPlaylistSongs(Map.from(header));
},
Expand Down
1 change: 1 addition & 0 deletions lib/screens/home_screen/chip_screen.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:get_it/get_it.dart';
import 'package:gyawun_beta/utils/pprint.dart';

import '../../ytmusic/ytmusic.dart';
import 'section_item.dart';
Expand Down
2 changes: 2 additions & 0 deletions lib/screens/home_screen/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ class _HomeScreenState extends State<HomeScreen> {
...sections.map((section) {
return SectionItem(section: section);
}),
if (!nextLoading && continuation != null)
const SizedBox(height: 50),
if (nextLoading) const CircularProgressIndicator(),
],
)
Expand Down
2 changes: 1 addition & 1 deletion lib/screens/home_screen/search_screen/search_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import '../../../services/media_player.dart';
import '../../../themes/colors.dart';
import '../../../utils/bottom_modals.dart';
import '../../../ytmusic/ytmusic.dart';
import '../../playlist_screen/browse_screen.dart';
import '../../browse_screen/browse_screen.dart';

class SearchScreen extends StatefulWidget {
const SearchScreen({this.endpoint, this.isMore = false, super.key});
Expand Down
68 changes: 46 additions & 22 deletions lib/screens/home_screen/section_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ import 'package:expandable_text/expandable_text.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get_it/get_it.dart';
import 'package:gyawun_beta/services/bottom_message.dart';
import 'package:gyawun_beta/utils/enhanced_image.dart';

import '../../utils/extensions.dart';
import '../../services/media_player.dart';
import '../../themes/colors.dart';
import '../../utils/bottom_modals.dart';
import '../playlist_screen/browse_screen.dart';
import '../browse_screen/browse_screen.dart';

class SectionItem extends StatelessWidget {
const SectionItem({required this.section, this.isMore = false, super.key});
Expand All @@ -37,26 +39,45 @@ class SectionItem extends StatelessWidget {
)
: null,
trailing: section['trailing'] != null
? MaterialButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20)),
onPressed: () async {
if (section['trailing']['playable'] == false) {
// GetIt.I<YTMusic>().browseMore(body: section['trailing']['endpoint']);
Navigator.push(
context,
CupertinoPageRoute(
builder: (context) => BrowseScreen(
endpoint: section['trailing']['endpoint'],
isMore: true,
),
));
} else {
await GetIt.I<MediaPlayer>().startPlaylistSongs(
section['trailing']['endpoint']);
}
},
child: Text(section['trailing']['text']),
? Row(
mainAxisSize: MainAxisSize.min,
children: [
InkWell(
borderRadius: BorderRadius.circular(20),
onTap: () async {
if (section['trailing']['playable'] == false) {
Navigator.push(
context,
CupertinoPageRoute(
builder: (context) => BrowseScreen(
endpoint: section['trailing']
['endpoint'],
isMore: true,
),
));
} else {
BottomMessage.showText(context,
'Songs will start playing soon.');
await GetIt.I<MediaPlayer>()
.startPlaylistSongs(
section['trailing']['endpoint']);
}
},
child: Container(
padding: const EdgeInsets.symmetric(
horizontal: 8,
vertical: 4,
),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
border: Border.all(
color: context.subtitleColor,
),
),
child: Text(section['trailing']['text']),
),
),
],
)
: null,
),
Expand Down Expand Up @@ -302,7 +323,10 @@ class _ItemListState extends State<ItemList> {
ClipRRect(
borderRadius: BorderRadius.circular(8),
child: CachedNetworkImage(
imageUrl: items[index]['thumbnails'].first['url'],
imageUrl: getEnhancedImage(
items[index]['thumbnails'].first['url'],
width: width),
filterQuality: FilterQuality.high,
height: height,
width: width,
fit: BoxFit.cover,
Expand Down
2 changes: 1 addition & 1 deletion lib/screens/library_screen/library_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import '../../generated/l10n.dart';
import '../../services/library.dart';
import '../../themes/colors.dart';
import '../../utils/bottom_modals.dart';
import '../playlist_screen/browse_screen.dart';
import '../browse_screen/browse_screen.dart';
import 'favourite_details_screen.dart';
import 'history_screen.dart';
import 'playlist_details_screen.dart';
Expand Down
14 changes: 11 additions & 3 deletions lib/screens/main_screen/bottom_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:io';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:gyawun_beta/utils/enhanced_image.dart';
import 'package:just_audio_background/just_audio_background.dart';
import 'package:provider/provider.dart';

Expand Down Expand Up @@ -60,12 +61,19 @@ class BottomPlayer extends StatelessWidget {
fit: BoxFit.fill,
)
: CachedNetworkImage(
imageUrl: currentSong
.extras!['thumbnails'].first['url']
.replaceAll('w60-h60', 'w300-h300'),
imageUrl: getEnhancedImage(currentSong
.extras!['thumbnails'].first['url']),
height: 50,
width: 50,
fit: BoxFit.fill,
errorWidget: (context, url, error) {
return CachedNetworkImage(
imageUrl: getEnhancedImage(
currentSong.extras!['thumbnails']
.first['url'],
quality: 'medium'),
);
},
),
),
const SizedBox(width: 8),
Expand Down
1 change: 1 addition & 0 deletions lib/screens/main_screen/main_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:device_info_plus/device_info_plus.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:gyawun_beta/utils/pprint.dart';
import 'package:salomon_bottom_bar/salomon_bottom_bar.dart';

import '../../generated/l10n.dart';
Expand Down
99 changes: 63 additions & 36 deletions lib/screens/main_screen/player_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get_it/get_it.dart';
import 'package:gyawun_beta/utils/enhanced_image.dart';
import 'package:gyawun_beta/utils/pprint.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:just_audio/just_audio.dart';
import 'package:just_audio_background/just_audio_background.dart';
Expand Down Expand Up @@ -49,7 +51,16 @@ class _PlayerScreenState extends State<PlayerScreen> {
if (image == null) return Theme.of(context).scaffoldBackgroundColor;
PaletteGenerator paletteGenerator =
await PaletteGenerator.fromImageProvider(
CachedNetworkImageProvider(image));
CachedNetworkImageProvider(
image,
errorListener: (p0) {
setState(() {
image = getEnhancedImage(image!, quality: 'medium');
});
pprint(p0);
},
),
);
if (mounted) {
return paletteGenerator.dominantColor?.color ??
paletteGenerator.lightVibrantColor?.color ??
Expand Down Expand Up @@ -88,11 +99,11 @@ class _PlayerScreenState extends State<PlayerScreen> {
if (currentSong?.extras?['thumbnails'] != null &&
currentSong?.extras?['thumbnails'].isNotEmpty &&
image !=
currentSong?.extras?['thumbnails']?.first['url']
.replaceAll('w60-h60', 'w300-h300')) {
getEnhancedImage(
currentSong?.extras?['thumbnails']?.first['url'])) {
setState(() {
image = currentSong?.extras?['thumbnails']?.first['url']
.replaceAll('w60-h60', 'w300-h300');
image =
getEnhancedImage(currentSong?.extras?['thumbnails']?.first['url']);
});
}
// ignore: deprecated_member_use
Expand Down Expand Up @@ -316,35 +327,51 @@ class Artwork extends StatelessWidget {
Icons.music_note,
size: width * 0.5,
)
: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(30),
spreadRadius: 10,
blurRadius: 10,
offset: const Offset(0, 3),
),
],
),
child: ClipRRect(
borderRadius: BorderRadius.circular(8),
child: song?.extras?['offline'] == true &&
!song!.artUri.toString().startsWith('https')
? Image.file(
File.fromUri(song!.artUri!),
)
: CachedNetworkImage(
imageUrl: song!.extras!['thumbnails'].first['url']
.replaceAll('w60-h60', 'w300-h300'),
: SafeArea(
child: LayoutBuilder(builder: (context, constraints) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(30),
spreadRadius: 10,
blurRadius: 10,
offset: const Offset(0, 3),
),
),
),
],
],
),
child: ClipRRect(
borderRadius: BorderRadius.circular(8),
child: song?.extras?['offline'] == true &&
!song!.artUri.toString().startsWith('https')
? Image.file(
File.fromUri(song!.artUri!),
)
: CachedNetworkImage(
width: min(constraints.maxHeight,
constraints.maxWidth),
filterQuality: FilterQuality.high,
imageUrl: getEnhancedImage(
song!.extras!['thumbnails'].first['url']),
errorWidget: (context, url, error) {
return CachedNetworkImage(
imageUrl: getEnhancedImage(
song!
.extras!['thumbnails'].first['url'],
quality: 'medium',
),
);
},
),
),
),
],
);
}),
),
),
);
Expand Down Expand Up @@ -378,8 +405,9 @@ class NameAndControls extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
if (isRow)
AppBar(
actions: [
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
IconButton(
onPressed: () {
currentState?.openEndDrawer();
Expand All @@ -388,7 +416,6 @@ class NameAndControls extends StatelessWidget {
Icons.queue_music_outlined,
))
],
automaticallyImplyLeading: false,
),
Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
Expand Down
21 changes: 16 additions & 5 deletions lib/screens/main_screen/queue_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'dart:ui';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:get_it/get_it.dart';
import 'package:gyawun_beta/utils/enhanced_image.dart';
import 'package:just_audio_background/just_audio_background.dart';
import 'package:provider/provider.dart';

Expand Down Expand Up @@ -70,14 +71,24 @@ class QueueList extends StatelessWidget {
},
)
: CachedNetworkImage(
imageUrl: song
imageUrl: getEnhancedImage(song
.extras!['thumbnails']
.first['url']
.replaceAll(
'w60-h60', 'w300-h300'),
.first['url']),
width: 50,
height: 50,
fit: BoxFit.fill),
fit: BoxFit.fill,
errorWidget:
(context, url, error) {
return CachedNetworkImage(
imageUrl: getEnhancedImage(
song
.extras![
'thumbnails']
.first['url'],
quality: 'medium'),
);
},
),
if (index == currentIndex)
Container(
height: 50,
Expand Down
Loading

0 comments on commit cce43ac

Please sign in to comment.