Snippets
Created by
Kevin Armstrong
last modified
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import './album_list.dart';
import './album_art.dart';
class Detail extends StatefulWidget {
final Album album;
Detail(this.album);
@override
_DetailState createState() => new _DetailState();
}
class _DetailState extends State<Detail> {
bool showLyrics = false;
@override
Widget build(BuildContext context) {
Album album = widget.album;
return Stack(
alignment: Alignment.bottomCenter,
children: <Widget>[
new Positioned(
top: 40.0,
left: 15.0,
right: 15.0,
bottom: 0.0,
child: Container(
width: double.infinity,
height: double.infinity,
alignment: Alignment.topCenter,
padding: EdgeInsets.all(15.0),
decoration: BoxDecoration(
color: Colors.white30,
borderRadius: BorderRadius.circular(10.0),
),
),
),
new Positioned(
top: 50.0,
left: 0.0,
right: 0.0,
bottom: 0.0,
child: Container(
width: double.infinity,
height: double.infinity,
alignment: Alignment.topCenter,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10.0),
),
child: Material(
color: Colors.white,
borderRadius: BorderRadius.circular(10.0),
child: SingleChildScrollView(
physics: AlwaysScrollableScrollPhysics(),
child: Column(
children: <Widget>[
GestureDetector(
onTap: (){
Navigator.pop(context);
},
child: Icon(Icons.keyboard_arrow_down, color: Colors.grey, size: 40.0,)
),
Container(
padding: EdgeInsets.symmetric(vertical: 20.0),
alignment: Alignment.center,
child: AlbumArt(tag: album.title, image: album.artwork, shadow: false, size: MediaQuery.of(context).size.width - 100,),
),
_makeDetailProgress(),
_makeDetailTrackInfo(album.title, album.artist),
_makeDetailControls(),
_makeVolumeControl(),
_makeExtraControls(),
Divider(height: 2.0,),
_makeDetailButtons(),
Divider(height: 2.0,),
_makeDetailLyrics(),
Divider(height: 2.0,),
_makeUpNext(),
SizedBox(height: 60.0,),
],
),
),
),
),
)
],
);
}
_makeDetailProgress(){
return Column(
children: <Widget>[
Slider(
value: 39.0,
activeColor: Colors.grey.shade700,
inactiveColor: Colors.grey.shade200,
min: 0.0,
max: 157.0,
onChanged: (double v){},
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 15.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text('0:39', style: Theme.of(context).textTheme.caption,),
Text('-1:58', style: Theme.of(context).textTheme.caption,),
],
),
)
],
);
}
_makeDetailTrackInfo(String title, String artist){
return Padding(
padding: EdgeInsets.all(20.0),
child: Column(
children: <Widget>[
Text(title,
style: Theme.of(context).textTheme.headline.copyWith(fontWeight: FontWeight.w600),),
Text('$artist - $title',
style: Theme.of(context).textTheme.headline.copyWith(color: Colors.red),
maxLines: 1,
),
],
),
);
}
_makeDetailControls(){
return Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
CupertinoButton(child: Icon(Icons.fast_rewind, size: 50.0,), pressedOpacity: 0.8, onPressed: (){},),
CupertinoButton(child: Icon(Icons.play_arrow, size: 75.0,), pressedOpacity: 0.8, onPressed: (){}),
CupertinoButton(child: Icon(Icons.fast_forward, size: 50.0,), pressedOpacity: 0.8, onPressed: (){}),
],
);
}
_makeVolumeControl() {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 10.0),
child: Row(
children: <Widget>[
Icon(Icons.volume_down, size: 18.0, color: Colors.grey,),
Expanded(
child: CupertinoSlider(
value: 65.0,
min: 0.0,
max: 100.0,
onChanged: (double v){},
activeColor: Colors.grey.shade700,
),
),
Icon(Icons.volume_up, size: 18.0, color: Colors.grey,),
],
),
);
}
_makeExtraControls() {
return Container(
padding: EdgeInsets.symmetric(vertical: 15.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
CupertinoButton(child: Icon(Icons.add, color: Colors.red,), pressedOpacity: 0.8, onPressed: (){}),
CupertinoButton(child: Icon(Icons.airplay, color: Colors.red,), pressedOpacity: 0.8, onPressed: (){}),
CupertinoButton(child: Icon(Icons.more_horiz, color: Colors.red,), pressedOpacity: 0.8, onPressed: (){}),
],
),
);
}
_makeDetailButtons() {
return Padding(
padding: EdgeInsets.symmetric(vertical: 15.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
SizedBox(width: 15.0,),
Expanded(
child: CupertinoButton(
padding: EdgeInsets.all(0.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(Icons.shuffle, color: Colors.red,),
Text(' Shuffle', style: TextStyle(color: Colors.red),)
],
),
onPressed: (){},
color: Colors.grey.shade100,
pressedOpacity: 0.4,
),
),
SizedBox(width: 15.0,),
Expanded(
child: CupertinoButton(
padding: EdgeInsets.all(0.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(Icons.repeat, color: Colors.white,),
Text(' Repeat', style: TextStyle(color: Colors.white,),)
],
),
onPressed: (){},
color: Colors.red,
pressedOpacity: 0.4,
),
),
SizedBox(width: 15.0,),
],
),
);
}
_makeDetailLyrics() {
return Container(
padding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 15.0),
child: Column(
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text('Lyrics', style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 26.0,
),),
CupertinoButton(
child: Text(showLyrics ? 'Hide' : 'Show',
style: TextStyle(
color: Colors.red,
fontSize: 18.0
),
),
onPressed: (){
setState(() {
showLyrics = !showLyrics;
print(showLyrics);
});
},
),
],
),
showLyrics ? Divider() : Container(),
showLyrics ? Container(
alignment: Alignment.topLeft,
child: Text('Tu eres la rueda, yo soy el camino\n'+
'pasas encima de mi dando vueltas\n'+
'tu rodaras porque ese es tu destino\n'+
'sin encontrar nadie que te detenga.\n\n'+
'Quise pararte pero ibas sin frenos\n'+
'y tus rodadas me hicieron pedazos\n'+
'porque no quieres los caminos buenos\n'+
'y agarras todo lo que hay en tus pasos.\n\n'+
'Yo que soñaba, con ser en tu vida\n'+
'el terminar de tus vueltas al mundo\n'+
'te vi pasar como nave perdida\n'+
'de aquà pa\'lla sin agarrar tu mundo.\n\n'+
'Ninguna rueda me habÃa lastimado\n'+
'y me pasaron de las más pesadas\n'+
'pero contigo quede destrozado\n'+
'porque no hiciste ninguna parada.',
style: TextStyle(fontSize: 18.0),
),
) : Container(),
],
),
);
}
_makeUpNext(){
return Container(
padding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 15.0),
color: Colors.grey.shade100,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text('Up Next', style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 26.0,
),),
Container(),
],
),
);
}
}
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import './album_list.dart';
class LibraryScreen extends StatelessWidget {
final Function onTap;
LibraryScreen({this.onTap});
@override
Widget build(BuildContext context) {
return new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Padding(
padding: EdgeInsets.only(left: 20.0),
child: Column(
children: <Widget>[
Divider(),
_makeListItem(context, 'Playlists'),
Divider(),
_makeListItem(context, 'Artists'),
Divider(),
_makeListItem(context, 'Albums'),
Divider(),
_makeListItem(context, 'Songs'),
Divider(),
_makeListItem(context, 'Downloaded Music'),
Divider(),
],
),
),
new Padding(
padding: EdgeInsets.only(top: 20.0, bottom: 10.0, left: 20.0),
child: Text(
'Recently Added',
style: Theme.of(context).textTheme.headline.copyWith(
fontWeight: FontWeight.w700
),
),
),
new Padding(
padding: const EdgeInsets.symmetric(horizontal: 20.0),
child: new ListView.builder(
shrinkWrap: true,
primary: false,
itemCount: albumsList.length,
itemBuilder: (context, index){
List<Album> albumRowData = albumsList[index];
return _makeAlbumRow(context, [
albumRowData.first,
albumRowData.last, //TODO: test to see if this exists
]);
},
),
),
SizedBox(height: 100.0,),
],
);
}
_makeAlbum(BuildContext context, Album album) {
double size = MediaQuery.of(context).size.width/2 - 40;
return GestureDetector(
onTap: () => onTap(album),
child: Card(
child: new Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
height: size,
width: size,
decoration: BoxDecoration(
image: DecorationImage(image: AssetImage(album.artwork), fit: BoxFit.cover),
),
),
new Padding(
padding: const EdgeInsets.symmetric(vertical: 4.0),
child: Text(album.title, style: TextStyle(fontSize: 16.0),),
),
Text(album.artist, style: TextStyle(color: Colors.grey),),
],
),
),
elevation: 0.0,
),
);
}
_makeListItem(BuildContext context, String s) {
return new CupertinoButton(
pressedOpacity: 0.6,
onPressed: (){},
padding: EdgeInsets.all(0.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Text(s,
style: Theme.of(context).textTheme.headline.copyWith(
color: Colors.red
),
),
new Padding(
padding: const EdgeInsets.all(5.0),
child: Icon(Icons.chevron_right, color: Colors.grey.shade300, size: 30.0,),
)
],
),
);
}
_makeAlbumRow(BuildContext context, List<Album> albums){
if(albums.length > 0) {
Album album1 = albums.first;
Album album2 = albums.length > 1 ? albums.last : null;
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
_makeAlbum(context, album1),
album2 != null ? _makeAlbum(context, album2) : Container(),
],
);
} else {
return Container();
}
}
}
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:fluids/utils/md_icons.dart'; //custom icons
import './library.dart';
import './album_art.dart';
import './detail.dart';
import './album_list.dart';
class AppleMusicMain extends StatefulWidget {
AppleMusicMain({Key key}) : super(key: key);
@override
_AppleMusicMainState createState() => new _AppleMusicMainState();
}
class _AppleMusicMainState extends State<AppleMusicMain> {
int selectedTab = 0;
String title = 'Library';
bool showTitle = false;
Album _selectedAlbum;
@override
initState() {
_selectedAlbum = albumsList[0][0];
super.initState();
}
@override
Widget build(BuildContext context) {
return Theme(
data: ThemeData(
primaryColor: Colors.white,
),
child: new Scaffold(
appBar: new AppBar(
backgroundColor: Colors.white,
elevation: 0.0,
title: AnimatedOpacity(
opacity: showTitle ? 1.0 : 0.0,
duration: Duration(milliseconds: showTitle ? 200 : 500),
child: Text('Library', style: TextStyle(color: Colors.black),),
),
centerTitle: true,
iconTheme: IconThemeData(
color: Colors.red,
),
actions: <Widget>[
CupertinoButton(
child: Text('Edit',
style: TextStyle(
color: Colors.red,
fontSize: 18.0
),
),
onPressed: (){},
)
],
),
body: new Stack(
children: <Widget>[
new Positioned.fill(
child: new NotificationListener(
child: new SingleChildScrollView(
child: new Container(
color: Colors.white,
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
_makeHeader('Library', hide: showTitle,),
LibraryScreen(onTap: (Album album){
setState(() {
_selectedAlbum = album;
});
},),
],
),
),
),
onNotification: (ScrollUpdateNotification notification){
setState(() {
if(notification.metrics.pixels > 52 && !showTitle){
showTitle = true;
} else if(notification.metrics.pixels < 52 && showTitle){
showTitle = false;
}
});
},
),
),
new Positioned(
bottom: 0.0,
left: 0.0,
right: 0.0,
child: _makeNowPlaying(context),
)
],
),
bottomNavigationBar: new BottomNavigationBar(
items: [
_makeNavButton(title: 'Library', icon: MDIcons.library_music),
_makeNavButton(title: 'For You', icon: MDIcons.heart),
_makeNavButton(title: 'Browse', icon: MDIcons.music_note),
_makeNavButton(title: 'Radio', icon: MDIcons.radio),
_makeNavButton(title: 'Search', icon: MDIcons.magnify),
],
type: BottomNavigationBarType.fixed,
currentIndex: selectedTab,
onTap: (int value){
setState(() {
selectedTab = value;
});
},
fixedColor: Colors.red,
),
),
);
}
_makeHeader(String title, {bool hide: false}) {
return new Padding(
padding: const EdgeInsets.only(left: 20.0),
child: new Text(
title,
style: Theme.of(context).textTheme.display2.copyWith(
color: hide ? Colors.transparent : Colors.black,
fontWeight: FontWeight.bold,
letterSpacing: 1.0
),
),
);
}
_makeNavButton({String title, IconData icon}) {
return new BottomNavigationBarItem(
icon: Icon(icon),
title: Text(title),
backgroundColor: Colors.white,
);
}
_makeNowPlaying(BuildContext context) {
return CupertinoButton(
onPressed: (){
Navigator.of(context).push(MaterialPageRoute(
fullscreenDialog: true,
builder: (BuildContext context){
return Detail(_selectedAlbum);
}
));
},
pressedOpacity: 0.9,
color: Colors.grey.shade200.withAlpha(280).withOpacity(0.9),
padding: EdgeInsets.all(0.0),
child: Container(
decoration: BoxDecoration(
border: Border(
top: BorderSide(color: Colors.grey.shade300, width: 1.0),
bottom: BorderSide(color: Colors.grey.shade300, width: 1.0),
),
),
padding: EdgeInsets.symmetric(vertical: 8.0, horizontal: 20.0),
child: Row(
children: <Widget>[
AlbumArt(tag: _selectedAlbum.title, size: 50.0, image: _selectedAlbum.artwork, shadow: true),
Expanded(
child: new Padding(
padding: const EdgeInsets.symmetric(horizontal: 20.0),
child: Text(
_selectedAlbum.title,
style: Theme.of(context).textTheme.subhead.copyWith(
fontWeight: FontWeight.normal
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
),
new Container(
width: 40.0,
child: IconButton(
icon: Icon(Icons.pause),
onPressed: (){},
iconSize: 35.0,
),
),
new Container(
width: 40.0,
child: IconButton(
icon: Icon(Icons.fast_forward),
onPressed: (){},
iconSize: 35.0,
),
),
],
),
),
);
}
}
|
Comments (0)
You can clone a snippet to your computer for local editing. Learn more.