Skip to content

Commit

Permalink
bottam player animation added
Browse files Browse the repository at this point in the history
  • Loading branch information
AnandhuA committed Nov 11, 2024
1 parent b180745 commit cd57097
Show file tree
Hide file tree
Showing 13 changed files with 167 additions and 21 deletions.
4 changes: 4 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>


<application
android:label="musiq"
android:icon="@mipmap/launcher_icon"
android:requestLegacyExternalStorage="true"
android:usesCleartextTraffic="true">

<activity
Expand Down
43 changes: 43 additions & 0 deletions lib/data/download_song.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import 'dart:io';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:path_provider/path_provider.dart';
import 'package:http/http.dart' as http;
import 'package:permission_handler/permission_handler.dart';

class DownloadSongRepo {
static Future<void> downloadSong({
required String downloadUrl,
required String fileName,
}) async {
try {

if (await Permission.storage.request().isGranted) {

Directory? directory = await getExternalStorageDirectory();
String downloadPath = "${directory!.path}/Musiq/";

Directory(downloadPath).createSync(recursive: true);

final response = await http.get(Uri.parse(downloadUrl));
if (response.statusCode == 200) {
String filePath = '$downloadPath$fileName';

File file = File(filePath);
await file.writeAsBytes(response.bodyBytes);
Fluttertoast.showToast(msg: "Download complete: $filePath");
print("Download complete: $filePath");
} else {
print("Failed to download. Status code: ${response.statusCode}");
Fluttertoast.showToast(
msg: "Failed to download. Status code: ${response.statusCode}");
}
} else {
print("Storage permission denied.");
Fluttertoast.showToast(msg: "Storage permission denied.");
}
} catch (e) {
print("Error downloading song: $e");
Fluttertoast.showToast(msg: "Error downloading song: $e");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import 'package:flutter/material.dart';
import 'package:musiq/presentation/commanWidgets/empty_screen.dart';

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

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
automaticallyImplyLeading: false,
leading: IconButton(
onPressed: () {
Navigator.pop(context);
},
icon: Icon(
Icons.arrow_back_ios_new_sharp,
),
),
),
body: emptyScreen(
context: context,
text1: "show",
size1: 15,
text2: "Nothing",
size2: 20,
text3: "Downloads",
size3: 20,
),
);
}
}
16 changes: 14 additions & 2 deletions lib/presentation/screens/LibraryScreen/library_screen.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:musiq/presentation/screens/LibraryScreen/last_played_list.dart';
import 'package:musiq/presentation/screens/favoriteScreen/favorite_screen.dart';
import 'package:musiq/presentation/screens/libraryScreen/LastPlayed/last_played_list.dart';
import 'package:musiq/presentation/screens/libraryScreen/downloadList/download_list.dart';
import 'package:musiq/presentation/screens/libraryScreen/favoriteScreen/favorite_screen.dart';

class LibraryScreen extends StatelessWidget {
const LibraryScreen({super.key});
Expand Down Expand Up @@ -31,6 +32,17 @@ class LibraryScreen extends StatelessWidget {
},
leading: Icon(Icons.history_sharp),
title: Text("Last Played"),
),
ListTile(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => DownloadList(),
));
},
leading: Icon(Icons.download),
title: Text("Downloads"),
)
],
),
Expand Down
8 changes: 4 additions & 4 deletions lib/presentation/screens/artist/artist_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -266,14 +266,14 @@ class ArtistScreen extends StatelessWidget {
),
GridView.builder(
physics:
NeverScrollableScrollPhysics(), // Prevent inner scrolling
NeverScrollableScrollPhysics(),
shrinkWrap:
true, // Allow GridView to take only as much space as needed
true,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3, // Number of columns
crossAxisCount: 3,
mainAxisSpacing: 10,
crossAxisSpacing: 10,
childAspectRatio: 0.9, // Aspect ratio for items
childAspectRatio: 0.9,
),
itemCount: model.data?.singles?.length ?? 0,
itemBuilder: (context, index) {
Expand Down
9 changes: 5 additions & 4 deletions lib/presentation/screens/loginScreen/login_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ class LoginScreen extends StatelessWidget {
context.read<FavoriteBloc>().add(FeatchFavoriteSongEvent());
} else if (state is LoginError) {
customSnackbar(
context: context,
message: state.errorMessage,
bgColor: Colors.red,
textColor: AppColors.white);
context: context,
message: state.errorMessage,
bgColor: Colors.red,
textColor: AppColors.white,
);
}
},
child: SafeArea(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,30 @@ class _MiniPlayerState extends State<MiniPlayer> {
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => PlayerScreen(
songs: AppGlobals().lastPlayedSongNotifier.value,
currentpostion: _currentPosition,
initialIndex: AppGlobals().currentSongIndex,
shuffle: AppGlobals().audioHandler.isShuffleOn(),
),
PageRouteBuilder(
pageBuilder: (context, animation, secondaryAnimation) {
return PlayerScreen(
songs: AppGlobals().lastPlayedSongNotifier.value,
currentpostion: _currentPosition,
initialIndex: AppGlobals().currentSongIndex,
shuffle: AppGlobals().audioHandler.isShuffleOn(),
);
},
transitionsBuilder:
(context, animation, secondaryAnimation, child) {
const begin = Offset(0.0, 1.0);
const end = Offset.zero;
const curve = Curves.easeInOut;

var tween = Tween(begin: begin, end: end)
.chain(CurveTween(curve: curve));
var offsetAnimation = animation.drive(tween);

return SlideTransition(
position: offsetAnimation,
child: child,
);
},
),
);
},
Expand Down
10 changes: 9 additions & 1 deletion lib/presentation/screens/player_screen/player_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import 'package:musiq/core/colors.dart';
import 'package:musiq/core/global_variables.dart';
import 'package:musiq/core/helper_funtions.dart';
import 'package:musiq/core/sized.dart';
import 'package:musiq/data/download_song.dart';
import 'package:musiq/models/song_model/song.dart';
import 'package:musiq/presentation/commanWidgets/custom_app_bar.dart';
import 'package:musiq/presentation/commanWidgets/favorite_icon.dart';
Expand Down Expand Up @@ -439,7 +440,14 @@ class _PlayerScreenState extends State<PlayerScreen> {
),
const Spacer(),
IconButton(
onPressed: () {},
onPressed: () {
DownloadSongRepo.downloadSong(
downloadUrl:
currentSong.downloadUrl?.last.link ??
"",
fileName: currentSong.name ?? "Nothing",
);
},
icon: const Icon(
Icons.download,
),
Expand Down
3 changes: 3 additions & 0 deletions lib/presentation/screens/settingsScreen/setting_screen.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:developer';

import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:lottie/lottie.dart';
Expand Down Expand Up @@ -29,6 +31,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
Future<void> getVersion() async {
PackageInfo packageInfo = await PackageInfo.fromPlatform();
version = packageInfo.version;
log("-------------$version");
String buildNumber = packageInfo.buildNumber;
print('Version: $version, Build Number: $buildNumber');
setState(() {});
Expand Down
28 changes: 27 additions & 1 deletion lib/services/app_initializer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import 'package:musiq/models/song_model/primary.dart';
import 'package:musiq/models/song_model/song.dart';
import 'package:musiq/presentation/screens/splashScreen/splash_screen.dart';
import 'package:musiq/services/audio_handler.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:uni_links2/uni_links.dart';

class AppInitializer {
Expand All @@ -21,6 +22,7 @@ class AppInitializer {
Future<void> initializeApp(BuildContext context) async {
_initDeepLinkListener(context);
_registerHiveAdapters();
await _requestStoragePermission();
try {
await Hive.initFlutter();
await Hive.openBox<Song>('lastPlayedBox');
Expand Down Expand Up @@ -73,7 +75,7 @@ class AppInitializer {
if (!Hive.isAdapterRegistered(PrimaryAdapter().typeId)) {
Hive.registerAdapter(PrimaryAdapter());
}
if (!Hive.isAdapterRegistered(AllAdapter().typeId)) {
if (!Hive.isAdapterRegistered(AllAdapter().typeId)) {
Hive.registerAdapter(AllAdapter());
}
}
Expand All @@ -92,4 +94,28 @@ class AppInitializer {
void dispose() {
_linkSubscription?.cancel();
}

Future<void> _requestStoragePermission() async {
PermissionStatus status = await Permission.storage.status;
log("Initial permission status: $status");

if (status.isPermanentlyDenied) {
log("Permission permanently denied. Redirecting to settings...");
await openAppSettings();
return;
}

status = await Permission.storage.request();

log("Permission status after request: $status");

if (status.isGranted) {
log("Storage permission granted.");
} else if (status.isDenied) {
log("Storage permission denied.");
} else if (status.isPermanentlyDenied) {
log("Storage permission permanently denied. Please enable it in settings.");
await openAppSettings();
}
}
}
4 changes: 2 additions & 2 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -756,10 +756,10 @@ packages:
dependency: "direct main"
description:
name: package_info_plus
sha256: df3eb3e0aed5c1107bb0fdb80a8e82e778114958b1c5ac5644fb1ac9cae8a998
sha256: da8d9ac8c4b1df253d1a328b7bf01ae77ef132833479ab40763334db13b91cce
url: "https://pub.dev"
source: hosted
version: "8.1.0"
version: "8.1.1"
package_info_plus_platform_interface:
dependency: transitive
description:
Expand Down

0 comments on commit cd57097

Please sign in to comment.