Skip to content

Commit

Permalink
UI improvements and bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
amangautam1 committed Jun 11, 2018
1 parent 7a8ca55 commit 7a77437
Show file tree
Hide file tree
Showing 14 changed files with 52 additions and 51 deletions.
16 changes: 8 additions & 8 deletions .idea/libraries/Dart_Packages.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/libraries/Flutter_Plugins.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion android/app/build.gradle
Expand Up @@ -27,7 +27,7 @@ android {
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
versionName "0.61"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

Expand Down
4 changes: 1 addition & 3 deletions lib/main.dart
Expand Up @@ -6,14 +6,12 @@ import 'package:musicplayer/musichome.dart';

void main() => runApp(new MyApp());

final ThemeData themedata=new ThemeData(
brightness: Brightness.dark
);

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
debugShowCheckedModeBanner: false,
home: new MusicHome(),
);
}
Expand Down
22 changes: 14 additions & 8 deletions lib/musichome.dart
Expand Up @@ -13,6 +13,7 @@ import 'package:musicplayer/views/artists.dart';
import 'package:musicplayer/views/home.dart';
import 'package:musicplayer/views/playlists.dart';
import 'package:musicplayer/views/songs.dart';
import 'package:shared_preferences/shared_preferences.dart';

class MusicHome extends StatefulWidget {
List<Song> songs;
Expand Down Expand Up @@ -108,7 +109,7 @@ class _musicState extends State<MusicHome> {
});
}
}

GlobalKey<ScaffoldState> scaffoldState = new GlobalKey();
@override
Widget build(BuildContext context) {
var bottomOptions = <BottomNavigationBarItem>[];
Expand All @@ -123,6 +124,7 @@ class _musicState extends State<MusicHome> {
}
return new WillPopScope(
child:new Scaffold(
key: scaffoldState,
appBar: _selectedDrawerIndex == 0
? null
: new AppBar(
Expand All @@ -133,21 +135,25 @@ class _musicState extends State<MusicHome> {
),
floatingActionButton: new FloatingActionButton(
child: new Icon(Icons.play_circle_filled),
onPressed: () {
if (last == null) {
Scaffold.of(context).showSnackBar(new SnackBar(content: Text("Play your first song.")));
onPressed: () async{
var pref=await SharedPreferences.getInstance();
var fp=pref.getBool("played");
print("fp=====$fp");
if (fp==null) {
scaffoldState.currentState.showSnackBar(new SnackBar(content: Text("Play your first song.")));
} else {
Navigator
.of(context)
.push(new MaterialPageRoute(builder: (context) {
if (LastPlay.songs == null) {
if (MyQueue.songs == null) {
List<Song> list = new List();
list.add(last);
LastPlay.songs = list;
MyQueue.songs = list;
return new NowPlaying(db, list, 0, 0);
} else
return new NowPlaying(db, LastPlay.songs, LastPlay.index, 1);
return new NowPlaying(db, MyQueue.songs, MyQueue.index, 1);
}));

}
}),
drawer: new Drawer(
Expand Down Expand Up @@ -198,7 +204,7 @@ class _musicState extends State<MusicHome> {
),
new FlatButton(
onPressed: () {
LastPlay.player.stop();
MyQueue.player.stop();
Navigator.of(context).pop(true);
},
child: new Text('Yes'),
Expand Down
6 changes: 3 additions & 3 deletions lib/pages/card_detail.dart
Expand Up @@ -140,7 +140,7 @@ class stateCardDetail extends State<CardDetail> {
style: new TextStyle(
fontSize: 12.0, color: Colors.grey)),
onTap: () {
LastPlay.songs = songs;
MyQueue.songs = songs;
Navigator.of(context).push(new MaterialPageRoute(
builder: (context) =>
new NowPlaying(widget.db, songs, i, 0)));
Expand All @@ -152,10 +152,10 @@ class stateCardDetail extends State<CardDetail> {
),
floatingActionButton: new FloatingActionButton(
onPressed: () {
LastPlay.songs = songs;
MyQueue.songs = songs;
Navigator.of(context).push(new MaterialPageRoute(
builder: (context) =>
new NowPlaying(widget.db, LastPlay.songs, 0, 0)));
new NowPlaying(widget.db, MyQueue.songs, 0, 0)));
},
child: new Icon(Icons.shuffle),
),
Expand Down
4 changes: 2 additions & 2 deletions lib/pages/list_songs.dart
Expand Up @@ -118,10 +118,10 @@ class _listSong extends State<ListSongs> {
style: new TextStyle(
fontSize: 12.0, color: Colors.grey)),
onTap: () {
LastPlay.songs = songs;
MyQueue.songs = songs;
Navigator.of(context).push(new MaterialPageRoute(
builder: (context) => new NowPlaying(
widget.db, LastPlay.songs, i, 0)));
widget.db, MyQueue.songs, i, 0)));
},
),
],
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/material_search.dart
Expand Up @@ -50,7 +50,7 @@ class _statesearch extends State<SearchSong> {
widget.songs.retainWhere((song) =>
(song.title + " " + song.album + " " + song.artist) == selected);
Navigator.pop(context);
LastPlay.songs = widget.songs;
MyQueue.songs = widget.songs;
Navigator.of(context).push(new MaterialPageRoute(builder: (context) {
return new NowPlaying(widget.db, widget.songs, 0, 0);
}));
Expand Down
14 changes: 8 additions & 6 deletions lib/pages/now_playing.dart
Expand Up @@ -6,7 +6,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:musicplayer/database/database_client.dart';
import 'package:musicplayer/util/lastplay.dart';
import 'package:local_notifications/local_notifications.dart';
import 'package:shared_preferences/shared_preferences.dart';

class NowPlaying extends StatefulWidget {
int mode;
Expand Down Expand Up @@ -40,7 +40,9 @@ class _stateNowPlaying extends State<NowPlaying> {
void initPlayer() async {
if (player == null) {
player = MusicFinder();
LastPlay.player=player;
MyQueue.player=player;
var pref=await SharedPreferences.getInstance();
pref.setBool("played", true);
}
// int i= await widget.db.isfav(song);
setState(() {
Expand Down Expand Up @@ -76,7 +78,7 @@ class _stateNowPlaying extends State<NowPlaying> {


void updatePage(int index) {
LastPlay.index = index;
MyQueue.index = index;
song = widget.songs[index];
song.timestamp = new DateTime.now().millisecondsSinceEpoch;
if (song.count == null) {
Expand Down Expand Up @@ -169,7 +171,7 @@ class _stateNowPlaying extends State<NowPlaying> {
new ListTile(
leading: new CircleAvatar(
child: widget.songs[i].id ==
LastPlay.songs[LastPlay.index].id
MyQueue.songs[MyQueue.index].id
? new Icon(Icons.insert_chart)
: getImage(widget.songs[i]) != null
? new Image.file(
Expand All @@ -196,9 +198,9 @@ class _stateNowPlaying extends State<NowPlaying> {
),
onTap: () {
setState(() {
LastPlay.index = i;
MyQueue.index = i;
player.stop();
updatePage(LastPlay.index);
updatePage(MyQueue.index);
Navigator.pop(context);
});
},
Expand Down
2 changes: 1 addition & 1 deletion lib/util/lastplay.dart
@@ -1,7 +1,7 @@
import 'package:flute_music_player/flute_music_player.dart';


class LastPlay {
class MyQueue {
static List<Song> songs;
static Song song;
static int index;
Expand Down
8 changes: 2 additions & 6 deletions lib/views/home.dart
Expand Up @@ -152,7 +152,7 @@ class stateHome extends State<Home> {
new FloatingActionButton(
heroTag: "shuffle",
onPressed: () {
LastPlay.songs = songs;
MyQueue.songs = songs;
Navigator.of(context).push(
new MaterialPageRoute(builder: (context) {
return new NowPlaying(widget.db, songs,
Expand Down Expand Up @@ -240,10 +240,8 @@ class stateHome extends State<Home> {
// padding: EdgeInsets.fromLTRB(16.0, 12.0, 16.0, 8.0),
padding: EdgeInsets.fromLTRB(4.0, 8.0, 0.0, 0.0),
child: Column(
//TODO: Align labels to the bottom and center (103)
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
//TODO: Handle overflowing labels (103)
Text(
albums[i].album,
style: new TextStyle(fontSize: 18.0),
Expand Down Expand Up @@ -308,10 +306,8 @@ class stateHome extends State<Home> {
// padding: EdgeInsets.fromLTRB(16.0, 12.0, 16.0, 8.0),
padding: EdgeInsets.fromLTRB(4.0, 8.0, 0.0, 0.0),
child: Column(
//TODO: Align labels to the bottom and center (103)
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
//TODO: Handle overflowing labels (103)
Text(
recents[i].title,
style: new TextStyle(fontSize: 18.0),
Expand All @@ -331,7 +327,7 @@ class stateHome extends State<Home> {
],
),
onTap: () {
LastPlay.songs = recents;
MyQueue.songs = recents;
Navigator
.of(context)
.push(new MaterialPageRoute(builder: (context) {
Expand Down
4 changes: 2 additions & 2 deletions lib/views/songs.dart
Expand Up @@ -74,10 +74,10 @@ class _songsState extends State<Songs> {
style: new TextStyle(
fontSize: 12.0, color: Colors.grey)),
onTap: () {
LastPlay.songs = songs;
MyQueue.songs = songs;
Navigator.of(context).push(new MaterialPageRoute(
builder: (context) => new NowPlaying(
widget.db, LastPlay.songs, i, 0)));
widget.db, MyQueue.songs, i, 0)));
},
),
],
Expand Down
14 changes: 7 additions & 7 deletions pubspec.lock
Expand Up @@ -172,13 +172,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.0-alpha.9"
local_notifications:
dependency: "direct main"
description:
name: local_notifications
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.6"
logging:
dependency: transitive
description:
Expand Down Expand Up @@ -291,6 +284,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.29.0+1"
shared_preferences:
dependency: "direct main"
description:
name: shared_preferences
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.2"
shelf:
dependency: transitive
description:
Expand Down
3 changes: 1 addition & 2 deletions pubspec.yaml
Expand Up @@ -13,8 +13,7 @@ dependencies:
path_provider:
material_search: ^0.2.7
url_launcher: 3.0.1
local_notifications: 0.0.6

shared_preferences: ^0.4.2

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit 7a77437

Please sign in to comment.