Skip to content

Commit

Permalink
Complete now playing screen
Browse files Browse the repository at this point in the history
fix: FileNotFound errors for null albumArt

WIP: Gradle build tools upgrade
  • Loading branch information
ashwinkey04 committed Jan 20, 2022
1 parent ab030ea commit 3141365
Show file tree
Hide file tree
Showing 16 changed files with 224 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/flutter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
- uses: actions/checkout@v1
- uses: actions/setup-java@v1
with:
java-version: '8.x'
java-version: '11'
- uses: subosito/[email protected]
with:
channel: 'stable'
Expand Down
4 changes: 3 additions & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 30
compileSdkVersion 31

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}

lintOptions {
disable 'InvalidPackage'
checkReleaseBuilds false
abortOnError false
}

defaultConfig {
Expand Down
6 changes: 3 additions & 3 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ buildscript {
ext.kotlin_version = '1.5.31'
repositories {
google()
jcenter()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:4.2.0'
classpath 'com.android.tools.build:gradle:7.0.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}

Expand Down
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip
Binary file removed assets/images/album.png
Binary file not shown.
Binary file added assets/images/logo_dark.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 assets/images/logo_light.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 removed assets/images/musical.png
Binary file not shown.
4 changes: 2 additions & 2 deletions lib/provider/audio_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ Widget getMediaAlbumArt(MediaItem song, Color iconColor) {

Future<File> getDefaultArt() async {
final file =
File('${(await getApplicationDocumentsDirectory()).path}/musical.png');
File('${(await getApplicationDocumentsDirectory()).path}/logo_dark.png');
if (!(await file.exists())) {
final _byteData = await rootBundle.load('assets/images/musical.png');
final _byteData = await rootBundle.load('assets/images/logo_dark.png');
await file.writeAsBytes(_byteData.buffer
.asUint8List(_byteData.offsetInBytes, _byteData.lengthInBytes));
}
Expand Down
20 changes: 10 additions & 10 deletions lib/provider/audio_query.dart
Original file line number Diff line number Diff line change
Expand Up @@ -140,19 +140,19 @@ class OfflineAudioQuery {
int quality = 100,
ArtworkFormat format = ArtworkFormat.JPEG,
}) async {
final File file = File('$tempPath/$fileName.jpg');
final Uint8List _imageBytes = await audioQuery.queryArtwork(
id,
type,
format: format,
size: size,
quality: quality,
);
if (_imageBytes == null || _imageBytes.isEmpty)
return (await getDefaultArt()).path;

final File file = File('$tempPath/$fileName.jpg');
if (!await file.exists()) {
await file.create();
final Uint8List _imageBytes = await audioQuery.queryArtwork(
id,
type,
format: format,
size: size,
quality: quality,
);
if (_imageBytes == null || _imageBytes.isEmpty)
return (await getDefaultArt()).path;
file.writeAsBytesSync(_imageBytes);
}
return file.path;
Expand Down
16 changes: 11 additions & 5 deletions lib/view/home_scaffold.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,17 @@ class _HomeScaffoldState extends State<HomeScaffold> {
title: Center(
child: Padding(
padding: const EdgeInsets.all(2.0),
child: Image.asset(
'assets/images/musical.png',
width: 40,
height: 40,
),
child: themeProvider.darkTheme
? Image.asset(
'assets/images/logo_light.png',
width: 35,
height: 40,
)
: Image.asset(
'assets/images/logo_dark.png',
width: 35,
height: 40,
),
))),
body: Stack(
children: <Widget>[
Expand Down
73 changes: 57 additions & 16 deletions lib/view/playback_controls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:raag/provider/audio_helper.dart';
import 'package:raag/provider/player_provider.dart';
import 'package:raag/widgets/animated_text.dart';
import 'package:raag/widgets/collapsed_controls.dart';
import 'package:raag/widgets/seekbar.dart';
import 'package:sliding_up_panel/sliding_up_panel.dart';
Expand Down Expand Up @@ -76,26 +77,61 @@ class _PlayBackControlsState extends State<PlayBackControls>
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Container(
color: Theme.of(context).dividerColor,
decoration: BoxDecoration(
color: Theme.of(context).dividerColor,
borderRadius:
BorderRadius.all(Radius.circular(10)),
boxShadow: [
BoxShadow(
color:
Theme.of(context).colorScheme.secondary,
blurRadius: 25,
spreadRadius: 5.0,
),
]),
width: sh * .35,
height: sh * .35,
child: getMediaAlbumArt(mediaItem,
Theme.of(context).colorScheme.secondary)),
Center(
child: Container(
width: sw * .8,
child: Text(
mediaItem?.title ?? 'Not playing',
style: Theme.of(context)
.textTheme
.headline1
.copyWith(fontSize: sh * .036),
textAlign: TextAlign.center,
softWrap: false,
width: sw * .8,
child: AnimatedText(
text: '${mediaItem.title ?? "Unknown"}',
pauseAfterRound: const Duration(seconds: 3),
showFadingOnlyWhenScrolling: false,
fadingEdgeEndFraction: 0.1,
fadingEdgeStartFraction: 0.1,
startAfter: const Duration(seconds: 2),
style: Theme.of(context)
.textTheme
.headline1
.copyWith(fontSize: sh * .036),
)
// child: Text(
// mediaItem?.title ?? 'Not playing',
// style: Theme.of(context)
// .textTheme
// .headline1
// .copyWith(fontSize: sh * .036),
// textAlign: TextAlign.center,
// softWrap: false,
// ),
),
),
Column(
mainAxisSize: MainAxisSize.min,
children: [
SeekBar(),
SizedBox(
height: 20,
),
),
PlayBackControlButtons(
provider: playerProvider,
isCollapsed: false,
panelController: panelController),
],
),
SeekBar(),
],
);
})),
Expand All @@ -105,8 +141,8 @@ class _PlayBackControlsState extends State<PlayBackControls>
}
}

class PlaybackControls extends StatefulWidget {
const PlaybackControls({
class PlayBackControlButtons extends StatefulWidget {
const PlayBackControlButtons({
Key key,
@required this.provider,
@required this.isCollapsed,
Expand All @@ -118,10 +154,10 @@ class PlaybackControls extends StatefulWidget {
final PanelController panelController;

@override
State<PlaybackControls> createState() => _PlaybackControlsState();
State<PlayBackControlButtons> createState() => _PlayBackControlButtonsState();
}

class _PlaybackControlsState extends State<PlaybackControls> {
class _PlayBackControlButtonsState extends State<PlayBackControlButtons> {
@override
Widget build(BuildContext context) {
return StreamBuilder<PlaybackState>(
Expand All @@ -142,6 +178,7 @@ class _PlaybackControlsState extends State<PlaybackControls> {
height: 40,
width: 40,
decoration: new BoxDecoration(
color: Theme.of(context).backgroundColor,
shape: BoxShape.circle,
border: new Border.all(
color: Theme.of(context).dividerColor,
Expand Down Expand Up @@ -171,6 +208,7 @@ class _PlaybackControlsState extends State<PlaybackControls> {
height: 50,
width: 50,
decoration: new BoxDecoration(
color: Theme.of(context).backgroundColor,
shape: BoxShape.circle,
border: new Border.all(
color: Theme.of(context).dividerColor,
Expand All @@ -197,6 +235,7 @@ class _PlaybackControlsState extends State<PlaybackControls> {
height: 70,
width: 70,
decoration: new BoxDecoration(
color: Theme.of(context).backgroundColor,
shape: BoxShape.circle,
border: new Border.all(
color: Theme.of(context).dividerColor,
Expand Down Expand Up @@ -233,6 +272,7 @@ class _PlaybackControlsState extends State<PlaybackControls> {
height: 50,
width: 50,
decoration: new BoxDecoration(
color: Theme.of(context).backgroundColor,
shape: BoxShape.circle,
border: new Border.all(
color: Theme.of(context).dividerColor,
Expand All @@ -259,6 +299,7 @@ class _PlaybackControlsState extends State<PlaybackControls> {
height: 40,
width: 40,
decoration: new BoxDecoration(
color: Theme.of(context).backgroundColor,
shape: BoxShape.circle,
border: new Border.all(
color: Theme.of(context).dividerColor,
Expand Down
2 changes: 1 addition & 1 deletion lib/view/splash_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class _SplashScreenState extends State<SplashScreen> {
return Container(
color: Theme.of(context).backgroundColor,
child: Image.asset(
'assets/images/musical.png',
'assets/images/logo_dark.png',
width: 160,
height: 160,
));
Expand Down
Loading

0 comments on commit 3141365

Please sign in to comment.