From df9337c235a36bcff2181658afd8695deb48514f Mon Sep 17 00:00:00 2001 From: mg143pavankumar Date: Thu, 27 May 2021 22:32:01 +0530 Subject: [PATCH] Finished project --- assets/radio.json | 20 +++--------------- lib/pages/home_screen.dart | 43 ++++++++++++++++++++++++++++++++++---- pubspec.lock | 2 +- pubspec.yaml | 1 + 4 files changed, 44 insertions(+), 22 deletions(-) diff --git a/assets/radio.json b/assets/radio.json index a391d59..ed7639d 100644 --- a/assets/radio.json +++ b/assets/radio.json @@ -72,20 +72,6 @@ }, { "id": 6, - "name": "94", - "tagline": "Today's Hits", - "color": "0xff27383e", - "desc": "", - "url": "http://playerservices.streamtheworld.com/api/livestream-redirect/977_HITS.mp3", - "icon": "https://static.radio.net/images/broadcasts/8d/76/3600/1/c175.png", - "image": "https://i.ytimg.com/vi/BUnPVjqb0YY/maxresdefault.jpg", - "lang": "English", - "category": "rock", - "disliked": false, - "order": 6 - }, - { - "id": 7, "name": "93", "tagline": "Love Songs", "color": "0xffa06a37", @@ -96,10 +82,10 @@ "lang": "Hindi", "category": "pop", "disliked": false, - "order": 7 + "order": 6 }, { - "id": 8, + "id": 7, "name": "107", "tagline": "Rocking Retro Hits", "color": "0xff090909", @@ -110,7 +96,7 @@ "lang": "Hindi", "category": "classic", "disliked": false, - "order": 8 + "order": 7 } ] diff --git a/lib/pages/home_screen.dart b/lib/pages/home_screen.dart index 4d20bbe..82b092b 100644 --- a/lib/pages/home_screen.dart +++ b/lib/pages/home_screen.dart @@ -39,6 +39,7 @@ class _HomeScreenState extends State { fetchRadios() async { final radioJson = await rootBundle.loadString("assets/radio.json"); radios = MyRadioList.fromJson(radioJson).radios; + setState(() {}); } _playMusic(String url) { @@ -50,7 +51,32 @@ class _HomeScreenState extends State { @override Widget build(BuildContext context) { return Scaffold( - drawer: Drawer(), + drawer: Drawer( + child: Container( + color: _selectedColor ?? AIColors.primaryColor2, + child: radios != null + ? [ + 100.heightBox, + "All Channel".text.xl.white.semiBold.make().px16(), + 20.heightBox, + ListView( + padding: Vx.m0, + shrinkWrap: true, + children: radios + .map( + (e) => ListTile( + leading: CircleAvatar( + backgroundImage: NetworkImage(e.icon), + ), + title: "${e.name} FM".text.white.make(), + subtitle: e.tagline.text.white.make(), + ), + ) + .toList()), + ].vStack() + : const Offstage(), + ), + ), body: Stack( children: [ VxAnimatedBox() @@ -59,12 +85,15 @@ class _HomeScreenState extends State { LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, - colors: [AIColors.primaryColor1, AIColors.primaryColor2], + colors: [ + AIColors.primaryColor2, + _selectedColor ?? AIColors.primaryColor1, + ], ), ) .make(), AppBar( - title: "AI Radio".text.xl4.bold.white.make().shimmer( + title: "MG Radio".text.xl4.bold.white.make().shimmer( primaryColor: Vx.purple300, secondaryColor: Colors.white, ), @@ -75,6 +104,11 @@ class _HomeScreenState extends State { radios != null ? VxSwiper.builder( itemCount: radios.length, + onPageChanged: (index) { + final colorHex = radios[index].color; + _selectedColor = Color(int.tryParse(colorHex)); + setState(() {}); + }, aspectRatio: 1.0, enlargeCenterPage: true, itemBuilder: (context, index) { @@ -137,7 +171,7 @@ class _HomeScreenState extends State { ).centered() : CircularProgressIndicator( backgroundColor: Colors.white, - ), + ).centered(), Align( alignment: Alignment.bottomCenter, child: [ @@ -151,6 +185,7 @@ class _HomeScreenState extends State { ? CupertinoIcons.stop_circle : CupertinoIcons.play_circle, color: Colors.white, + size: 40, ).onInkTap(() { if (_isPlaying) { _audioPlayer.stop(); diff --git a/pubspec.lock b/pubspec.lock index 49cb5cc..480b23f 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -122,7 +122,7 @@ packages: source: hosted version: "2.1.0" http: - dependency: transitive + dependency: "direct main" description: name: http url: "https://pub.dartlang.org" diff --git a/pubspec.yaml b/pubspec.yaml index f62269c..9408cb2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -26,6 +26,7 @@ dependencies: audioplayers: ^0.19.0 cupertino_icons: ^1.0.3 google_fonts: ^2.1.0 + http: ^0.13.3 velocity_x: ^3.1.1 dev_dependencies: