Skip to content

Commit

Permalink
Updated UI to accomodate Youtube api changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sheikhhaziq committed Jun 29, 2024
1 parent a88c1e2 commit d68385e
Show file tree
Hide file tree
Showing 102 changed files with 9,247 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.jhelum.gyawun.beta

import io.flutter.embedding.android.FlutterActivity

class MainActivity: FlutterActivity()
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added android/app/src/main/res/drawable-hdpi/branding.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added android/app/src/main/res/drawable-hdpi/splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added android/app/src/main/res/drawable-mdpi/branding.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added android/app/src/main/res/drawable-mdpi/splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions android/app/src/main/res/drawable-night/launch_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Dark theme splash screen with launcher icon -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/black" /> <!-- Black background -->
<item>
<bitmap
android:gravity="center"
android:src="@mipmap/ic_launcher" /> <!-- Use launcher icon -->
</item>
</layer-list>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added android/app/src/main/res/drawable-xhdpi/branding.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added android/app/src/main/res/drawable/background.png
21 changes: 21 additions & 0 deletions android/app/src/main/res/values-night-v31/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is off -->
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
<item name="android:forceDarkAllowed">false</item>
<item name="android:windowFullscreen">false</item>
<item name="android:windowDrawsSystemBarBackgrounds">false</item>
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
<item name="android:windowSplashScreenBrandingImage">@drawable/android12branding</item>
<item name="android:windowSplashScreenAnimatedIcon">@drawable/android12splash</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Flutter UI initializes, as well as behind your Flutter UI while its
running.
This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
</resources>
21 changes: 21 additions & 0 deletions android/app/src/main/res/values-v31/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is off -->
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:forceDarkAllowed">false</item>
<item name="android:windowFullscreen">false</item>
<item name="android:windowDrawsSystemBarBackgrounds">false</item>
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
<item name="android:windowSplashScreenBrandingImage">@drawable/android12branding</item>
<item name="android:windowSplashScreenAnimatedIcon">@drawable/android12splash</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Flutter UI initializes, as well as behind your Flutter UI while its
running.
This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
</resources>
Binary file added assets/images/background.png
Binary file added assets/images/branding.png
Binary file added assets/images/icon_512.png
Binary file added assets/images/splash_icon.png
3 changes: 3 additions & 0 deletions devtools_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
description: This file stores settings for Dart & Flutter DevTools.
documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states
extensions:
Binary file modified fastlane/metadata/android/en-US/images/phoneScreenshots/01.jpg
100644 → 100755
Binary file modified fastlane/metadata/android/en-US/images/phoneScreenshots/02.jpg
100644 → 100755
Binary file modified fastlane/metadata/android/en-US/images/phoneScreenshots/03.jpg
100644 → 100755
Binary file modified fastlane/metadata/android/en-US/images/phoneScreenshots/04.jpg
100644 → 100755
Binary file modified fastlane/metadata/android/en-US/images/phoneScreenshots/05.jpg
100644 → 100755
Binary file modified fastlane/metadata/android/en-US/images/phoneScreenshots/06.jpg
100644 → 100755
10 changes: 10 additions & 0 deletions flutter_native_splash.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
flutter_native_splash:
# color: "#ffffff"
image: assets/images/splash_icon.png
background_image: "assets/images/background.png"
branding: assets/images/branding.png
android_12:
image: assets/images/icon_512.png
branding: assets/images/branding.png
# color: "#ffffff"
# icon_background_color: "#fa50a2"
9 changes: 9 additions & 0 deletions lib/app_config.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
AppConfig appConfig = AppConfig(version: 21, codeName: '2.0.0-beta-1');

class AppConfig {
int version;
String codeName;
Uri updateUri =
Uri.parse('https://api.github.com/repos/jhelumcorp/gyawun/releases');
AppConfig({required this.version, required this.codeName});
}
102 changes: 102 additions & 0 deletions lib/generated/intl/messages_zh-CN.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart
// This is a library that provides messages for a zh_CN locale. All the
// messages from the main program should be duplicated here with the same
// function name.

// Ignore issues from commonly used lints in this file.
// ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new
// ignore_for_file:prefer_single_quotes,comment_references, directives_ordering
// ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases
// ignore_for_file:unused_import, file_names, avoid_escaping_inner_quotes
// ignore_for_file:unnecessary_string_interpolations, unnecessary_string_escapes

import 'package:intl/intl.dart';
import 'package:intl/message_lookup_by_library.dart';

final messages = new MessageLookup();

typedef String MessageIfAbsent(String messageStr, List<dynamic> args);

class MessageLookup extends MessageLookupByLibrary {
String get localeName => 'zh_CN';

final messages = _notInlinedMessages(_notInlinedMessages);
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
"about": MessageLookupByLibrary.simpleMessage("关于"),
"addToQueue": MessageLookupByLibrary.simpleMessage("添加到队列"),
"appearence": MessageLookupByLibrary.simpleMessage("外观"),
"bugReport": MessageLookupByLibrary.simpleMessage("错误报告"),
"cancel": MessageLookupByLibrary.simpleMessage("取消"),
"clearPlaybackCache": MessageLookupByLibrary.simpleMessage("清除播放缓存"),
"clearPlaybackCacheDialogText":
MessageLookupByLibrary.simpleMessage("您确定要清除播放缓存吗?"),
"confirm": MessageLookupByLibrary.simpleMessage("确认"),
"contributors": MessageLookupByLibrary.simpleMessage("贡献者"),
"country": MessageLookupByLibrary.simpleMessage("国家"),
"date": MessageLookupByLibrary.simpleMessage("日期"),
"delete": MessageLookupByLibrary.simpleMessage("删除"),
"deletePlaybackHistory": MessageLookupByLibrary.simpleMessage("删除播放历史"),
"deletePlaybackHistoryDialogText":
MessageLookupByLibrary.simpleMessage("您确定要删除播放历史记录吗?"),
"deletePlaybackHistoryText":
MessageLookupByLibrary.simpleMessage("根据播放历史推荐"),
"developer": MessageLookupByLibrary.simpleMessage("开发者"),
"done": MessageLookupByLibrary.simpleMessage("完成"),
"download": MessageLookupByLibrary.simpleMessage("下载"),
"downloadQuality": MessageLookupByLibrary.simpleMessage("下载质量"),
"downloads": MessageLookupByLibrary.simpleMessage("下载"),
"enableEqualizer": MessageLookupByLibrary.simpleMessage("启用均衡器"),
"enablePlaybackCache": MessageLookupByLibrary.simpleMessage("启用播放缓存"),
"enablePlaybackHistory": MessageLookupByLibrary.simpleMessage("启用播放历史"),
"enablePlaybackHistoryText":
MessageLookupByLibrary.simpleMessage("根据播放历史推荐"),
"equalizer": MessageLookupByLibrary.simpleMessage("均衡器"),
"featureRequest": MessageLookupByLibrary.simpleMessage("功能要求"),
"high": MessageLookupByLibrary.simpleMessage("高"),
"history": MessageLookupByLibrary.simpleMessage("播放历史"),
"home": MessageLookupByLibrary.simpleMessage("首页"),
"homescreenProvider": MessageLookupByLibrary.simpleMessage("主页供应商"),
"jhelumCorp": MessageLookupByLibrary.simpleMessage("Jhelum Corp"),
"languages": MessageLookupByLibrary.simpleMessage("语言"),
"loudnessEnhancer": MessageLookupByLibrary.simpleMessage("音效增强器"),
"low": MessageLookupByLibrary.simpleMessage("低"),
"materialColors":
MessageLookupByLibrary.simpleMessage("Material Colors"),
"medium": MessageLookupByLibrary.simpleMessage("中等"),
"name": MessageLookupByLibrary.simpleMessage("名称"),
"no": MessageLookupByLibrary.simpleMessage("No"),
"nothingInHere": MessageLookupByLibrary.simpleMessage("这里什么都没有"),
"ok": MessageLookupByLibrary.simpleMessage("OK"),
"organisation": MessageLookupByLibrary.simpleMessage("组织"),
"pitchBlack": MessageLookupByLibrary.simpleMessage("深黑模式"),
"playAll": MessageLookupByLibrary.simpleMessage("全部播放"),
"playNext": MessageLookupByLibrary.simpleMessage("播放下一个"),
"playlists": MessageLookupByLibrary.simpleMessage("播放列表"),
"primaryColor": MessageLookupByLibrary.simpleMessage("主题颜色"),
"recentlyPlayed": MessageLookupByLibrary.simpleMessage("最近播放"),
"recommended": MessageLookupByLibrary.simpleMessage("推荐"),
"rightToLeft": MessageLookupByLibrary.simpleMessage("左右反转"),
"saved": MessageLookupByLibrary.simpleMessage("已保存"),
"searchGyawun": MessageLookupByLibrary.simpleMessage("Search Gyawun"),
"searchProvider": MessageLookupByLibrary.simpleMessage("搜索供应商"),
"searchSettings": MessageLookupByLibrary.simpleMessage("搜索设置"),
"select": MessageLookupByLibrary.simpleMessage("选择"),
"selectLanguage": MessageLookupByLibrary.simpleMessage("选择语言"),
"serviceProviders": MessageLookupByLibrary.simpleMessage("服务供应商"),
"settings": MessageLookupByLibrary.simpleMessage("设置"),
"sheikhhaziq": MessageLookupByLibrary.simpleMessage("Sheikh Haziq"),
"sleepTimer": MessageLookupByLibrary.simpleMessage("睡眠定时器"),
"songs": MessageLookupByLibrary.simpleMessage("歌曲"),
"sourceCode": MessageLookupByLibrary.simpleMessage("源代码"),
"streamingQuality": MessageLookupByLibrary.simpleMessage("流媒体质量"),
"telegram": MessageLookupByLibrary.simpleMessage("Telegram"),
"themeMode": MessageLookupByLibrary.simpleMessage("主题模式"),
"title": MessageLookupByLibrary.simpleMessage("标题"),
"version": MessageLookupByLibrary.simpleMessage("版本"),
"yes": MessageLookupByLibrary.simpleMessage("Yes"),
"youtubeDownloadQuality":
MessageLookupByLibrary.simpleMessage("YouTube 下载质量"),
"youtubeStreamingQuality":
MessageLookupByLibrary.simpleMessage("YouTube 质量")
};
}
187 changes: 187 additions & 0 deletions lib/screens/download_screen/download_screen.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
import 'dart:io';

import 'package:cached_network_image/cached_network_image.dart';
import 'package:expandable_text/expandable_text.dart';
import 'package:flutter/material.dart';
import 'package:flutter_swipe_action_cell/core/cell.dart';
import 'package:get_it/get_it.dart';

import '../../services/bottom_message.dart';
import '../../services/download_manager.dart';
import '../../services/media_player.dart';
import '../../themes/colors.dart';
import '../../utils/bottom_modals.dart';
import '../../utils/extensions.dart';

class DownloadScreen extends StatelessWidget {
const DownloadScreen({super.key});

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Downloads'),
centerTitle: true,
),
body: ValueListenableBuilder(
valueListenable: GetIt.I<DownloadManager>().downloads,
builder: (context, allSongs, snapshot) {
List songs = allSongs
.where((song) =>
['DOWNLOADED', 'DELETED'].contains(song['status']))
.toList();
return SingleChildScrollView(
child: Column(
children: [
...songs.indexed.map<Widget>((indexedSong) {
int index = indexedSong.$1;
Map song = indexedSong.$2;
return FutureBuilder(
future: File(song['path']).exists(),
builder: (context, snapshot) {
if (snapshot.data == false) {
GetIt.I<DownloadManager>()
.updateStatus(song['videoId'], 'DELETED');
// return const SizedBox();
}
return SwipeActionCell(
key: ObjectKey(song['videoId']),
trailingActions: <SwipeAction>[
if (snapshot.data == true)
SwipeAction(
title: "Remove",
onTap: (CompletionHandler handler) async {
Modals.showConfirmBottomModal(
context,
message:
'Are you sure you want to remove it?',
isDanger: true,
).then((bool confirm) {
if (confirm) {
GetIt.I<DownloadManager>()
.deleteSong(
song['videoId'], song['path'])
.then((message) =>
BottomMessage.showText(
context, message));
}
});
},
color: Colors.red),
],
child:
DownloadedSongTile(songs: songs, index: index),
);
});
})
],
),
);
}),
);
}
}

class DownloadedSongTile extends StatelessWidget {
const DownloadedSongTile(
{required this.songs, required this.index, this.playlistId, super.key});
final String? playlistId;
final List songs;
final int index;
@override
Widget build(BuildContext context) {
Map song = songs[index];
List thumbnails = song['thumbnails'];
double height =
(song['aspectRatio'] != null ? 50 / song['aspectRatio'] : 50)
.toDouble();
return Material(
color: Colors.transparent,
child: InkWell(
borderRadius: BorderRadius.circular(5),
focusColor: greyColor,
onTap: () async {
await GetIt.I<MediaPlayer>().playAll(List.from(songs), index: index);
},
onSecondaryTap: () {
if (song['videoId'] != null) {
Modals.showSongBottomModal(context, song);
}
},
onLongPress: () {
if (song['videoId'] != null) {
Modals.showSongBottomModal(context, song);
}
},
child: Column(
children: [
ListTile(
title: Text(song['title'] ?? "", maxLines: 1),
leading: ClipRRect(
borderRadius: BorderRadius.circular(3),
child: CachedNetworkImage(
imageUrl: thumbnails
.where((el) => el['width'] >= 50)
.toList()
.first['url'],
height: height,
width: 50,
fit: BoxFit.cover,
),
),
subtitle: Text(
song['status'] == 'DELETED'
? 'File not found'
: _buildSubtitle(song),
maxLines: 1,
style: TextStyle(
color: song['status'] == 'DELETED'
? Colors.red
: Colors.grey.withAlpha(250),
),
overflow: TextOverflow.ellipsis,
),
trailing: song['status'] == 'DELETED'
? IconButton(
onPressed: () async {
await GetIt.I<DownloadManager>().downloadSong(song);
},
icon: const Icon(Icons.refresh))
: null,
),
if (song['type'] == 'EPISODE' && song['description'] != null)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Column(
children: [
ExpandableText(
song['description'].split('\n')?[0] ?? '',
expandText: 'Show More',
collapseText: 'Show Less',
maxLines: 3,
style: TextStyle(color: context.subtitleColor),
),
const Divider(),
],
),
)
],
),
),
);
}

String _buildSubtitle(Map item) {
List sub = [];
if (sub.isEmpty && item['artists'] != null) {
for (Map artist in item['artists']) {
sub.add(artist['name']);
}
}
if (sub.isEmpty && item['album'] != null) {
sub.add(item['album']['name']);
}
String s = sub.join(' · ');
return item['subtitle'] ?? s;
}
}
Loading

0 comments on commit d68385e

Please sign in to comment.