Untitled
import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/material.dart'; import 'package:connectivity_plus/connectivity_plus.dart'; import 'package:lottie/lottie.dart'; import 'package:untitled1/Radio/just_music_page.dart'; import 'package:untitled1/data/1.dart'; import 'package:untitled1/utilites/constants.dart'; import 'package:untitled1/widgets/custom_text.dart'; import 'package:shared_preferences/shared_preferences.dart'; import '../my_drawer.dart'; import 'package:provider/provider.dart'; import 'package:untitled1/Radio/no_internet.dart'; import '../provider/check_internet_provider.dart'; import '../utilites/constants.dart'; import '../utilites/sharedPref.dart'; import '../widgets/custom_text.dart'; import 'package:get/get.dart'; import 'package:just_audio/just_audio.dart'; class LiveScreen extends StatefulWidget { const LiveScreen({Key? key}) : super(key: key); @override _LiveScreenState createState() => _LiveScreenState(); } class _LiveScreenState extends State<LiveScreen> { GlobalKey<ScaffoldState>? mainDrawerKey = GlobalKey<ScaffoldState>(); final _firestore = FirebaseFirestore.instance; final AudioPlayer _audioPlayer = AudioPlayer(); late bool isDarkMode = false; @override void initState() { Provider.of<CheckInternetProvider>(context, listen: false) .startMonitoring(); super.initState(); } @override Widget build(BuildContext context) { return Provider.of<CheckInternetProvider>(context).isOnline ? Scaffold( drawer: MyDrawer(), key: mainDrawerKey, appBar: AppBar( elevation: 0, backgroundColor: Colors.orange, leading: IconButton( onPressed: () { mainDrawerKey!.currentState!.openDrawer(); }, icon: const Icon( Icons.menu_sharp, color: whiteColor, )), title: CustomText( title: "URL", fontSize: 20, fontWeight: FontWeight.w600, color: whiteColor, ), actions: [ IconButton( onPressed: () { Get.changeTheme(Get.isDarkMode ? ThemeData.light() : ThemeData.dark()); setState(() { isDarkMode = !isDarkMode; SharedPref() .write(key: "isNightModeOn1", value: isDarkMode); }); }, icon: Icon( isDarkMode ? Icons.light_mode : Icons.dark_mode, color: whiteColor, )), IconButton( onPressed: () { showDialog( context: context, builder: (BuildContext context) { return AlertDialog( title: Text('Favorite List'), content: setupAlertDialoadContainer(), ); }); }, icon: Icon( Icons.star, color: whiteColor, )), ]), body: Padding( padding: const EdgeInsets.only(top: 0.0), child: Column( children: [ StreamBuilder<QuerySnapshot>( stream: _firestore .collection('songDocs') .snapshots(), // TODO add the field here builder: (context, snapshot) { if (snapshot.connectionState == ConnectionState.waiting) { return Center( child: Lottie.asset('assets/lottie/music_loading.json'), ); } else if (snapshot.hasData) { List<Widget> musicTiles = []; final links = snapshot.data!.docs; for (var link in links) { String stringInfo = link.get('info'); List<String> megaInfo = stringInfo.split("*"); print("++++++MEGA INFO LINK++++++++++++$megaInfo"); String _audioLink = megaInfo[0]; // Index 0 String _thumbnailLink = megaInfo[1]; String _headingName = megaInfo[2]; String _location = megaInfo[3]; String _uniqueID = megaInfo[4]; musicTiles.add( InkWell( onTap: () { if (_headingName == "Sikhnet") { // Helper.toScreen(context, HukamnamaScreen()); } else if (_headingName == "Sikhnet") { // Helper.toScreen(context, HukamnamaScreen()); } else { Navigator.push( context, MaterialPageRoute( builder: (context) => JustMusicPlay( audioLink: _audioLink, thumbnailLink: _thumbnailLink, headingName: _headingName, heroTag: _uniqueID, audioPlayer: _audioPlayer, albumName: _location, ), ), ); } }, child: Container( padding: const EdgeInsets.symmetric(vertical: 15), child: Row( children: [ // Padding( // padding: // const EdgeInsets.only(left: 15.0), // child: CircleAvatar( // backgroundImage: CachedNetworkImage( // imageUrl: // "http://via.placeholder.com/350x150", // placeholder: (context, url) => // CircularProgressIndicator(), // errorWidget: (context, url, error) => // Icon(Icons.error), // ), // radius: 35, // ), // ), const SizedBox( width: 20, ), Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( _headingName, style: const TextStyle( fontWeight: FontWeight.bold, fontSize: 22.0, ), ), Text( _location, style: const TextStyle(fontSize: 16.0), ), ], ), // Column() ], ), ), ), ); } return Expanded( child: Padding( padding: const EdgeInsets.only(top: 10.0), child: ListView( children: musicTiles, ), ), ); } else { return Container( alignment: Alignment.center, child: Text("Try Again After Some time"), ); } }, ) ], ), ), ) : const NoInternetScreen(); } void loadCounter() async { SharedPreferences prefs = await SharedPreferences.getInstance(); isNightModeOn = await SharedPref().read(key: "isVibrationOn") ?? true; print(isNightModeOn); } Widget setupAlertDialoadContainer() { return Container( height: 300.0, // Change as per your requirement width: 300.0, // Change as per your requirement child: ListView.builder( shrinkWrap: true, itemCount: 5, itemBuilder: (BuildContext context, int index) { return ListTile( title: Text('Gujarat, India'), ); }, ), ); } }
Leave a Comment