2022-04-28 21:24:26 +02:00
|
|
|
// ignore_for_file: prefer_const_literals_to_create_immutables, avoid_print
|
|
|
|
|
2022-04-30 01:48:17 +02:00
|
|
|
import 'dart:convert';
|
2022-05-05 01:23:16 +02:00
|
|
|
import 'package:fipy/models/track.dart';
|
|
|
|
import 'package:fipy/providers/home.dart';
|
|
|
|
import 'package:fipy/providers/player.dart';
|
2022-04-28 21:24:26 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2022-05-05 22:31:16 +02:00
|
|
|
import 'package:flutter/services.dart';
|
2022-04-28 21:24:26 +02:00
|
|
|
import 'package:miniplayer/miniplayer.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'package:youtube_explode_dart/youtube_explode_dart.dart';
|
2022-05-06 12:53:01 +02:00
|
|
|
// import 'dart:math';
|
|
|
|
// import 'package:flutter/rendering.dart';
|
2022-04-28 21:24:26 +02:00
|
|
|
|
|
|
|
class HomeScreen extends StatefulWidget {
|
|
|
|
const HomeScreen({Key? key, required this.title}) : super(key: key);
|
|
|
|
final String title;
|
|
|
|
@override
|
|
|
|
State<HomeScreen> createState() => _HomeScreenState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _HomeScreenState extends State<HomeScreen> {
|
2022-04-30 01:48:17 +02:00
|
|
|
String radio = 'fip_groove';
|
|
|
|
|
2022-04-28 21:24:26 +02:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2022-04-30 01:48:17 +02:00
|
|
|
HomeProvider hp = Provider.of<HomeProvider>(context, listen: false);
|
2022-04-28 21:24:26 +02:00
|
|
|
final MiniplayerController controller = MiniplayerController();
|
|
|
|
|
2022-05-05 22:31:16 +02:00
|
|
|
return RawKeyboardListener(
|
|
|
|
autofocus: true,
|
|
|
|
focusNode: FocusNode(),
|
|
|
|
onKey: (RawKeyEvent event) {
|
|
|
|
if (event.runtimeType == RawKeyDownEvent &&
|
|
|
|
event.data.logicalKey.keyId == 32) //Enter Key ID from keyboard
|
|
|
|
{
|
2022-05-06 17:15:41 +02:00
|
|
|
hp.player.state.name == 'playing'
|
|
|
|
? hp.player.pause()
|
|
|
|
: hp.player.resume();
|
2022-05-05 22:31:16 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
child: Stack(
|
|
|
|
children: <Widget>[
|
|
|
|
Scaffold(
|
|
|
|
body: RawScrollbar(
|
|
|
|
thumbColor: Colors.grey[600],
|
|
|
|
radius: const Radius.circular(20),
|
|
|
|
thickness: 12,
|
|
|
|
// thumbVisibility: true,
|
|
|
|
mainAxisMargin: 70,
|
|
|
|
child: SingleChildScrollView(
|
2022-05-06 12:53:01 +02:00
|
|
|
// controller: AdjustableScrollController(40),
|
2022-05-05 22:31:16 +02:00
|
|
|
child: Column(
|
|
|
|
children: <Widget>[
|
|
|
|
Container(
|
|
|
|
color: Colors.grey[900],
|
|
|
|
height: 50,
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
DropdownButton(
|
|
|
|
dropdownColor: Colors.grey[900],
|
|
|
|
value: radio,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 15, color: Colors.grey[300]),
|
|
|
|
underline: const SizedBox(),
|
|
|
|
iconSize: 22,
|
|
|
|
onChanged: (String? newRadio) {
|
|
|
|
setState(() {
|
|
|
|
radio = newRadio!;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
items: hp.radioList),
|
|
|
|
const SizedBox(width: 50),
|
|
|
|
DropdownButton(
|
|
|
|
dropdownColor: Colors.grey[900],
|
|
|
|
value: hp.userPageNbr.toString(),
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 15, color: Colors.grey[300]),
|
|
|
|
underline: const SizedBox(),
|
|
|
|
iconSize: 22,
|
|
|
|
onChanged: (String? newPageNumber) {
|
|
|
|
setState(() {
|
|
|
|
hp.userPageNbr =
|
|
|
|
int.parse(newPageNumber!);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
items: hp.pageList),
|
|
|
|
]),
|
|
|
|
),
|
|
|
|
FutureBuilder<List<Track>>(
|
|
|
|
future: hp.getTracks(radio),
|
|
|
|
builder: (
|
|
|
|
BuildContext context,
|
|
|
|
AsyncSnapshot<List<Track>> snapshot,
|
|
|
|
) {
|
|
|
|
print(snapshot.connectionState);
|
|
|
|
if (snapshot.connectionState ==
|
|
|
|
ConnectionState.waiting) {
|
2022-04-30 01:48:17 +02:00
|
|
|
return Stack(children: [
|
|
|
|
Container(
|
|
|
|
height: 10000,
|
|
|
|
width: 10000,
|
|
|
|
color: const Color(0xFF121212)),
|
|
|
|
Center(
|
|
|
|
child: Column(children: [
|
|
|
|
const SizedBox(height: 20),
|
2022-05-05 22:31:16 +02:00
|
|
|
SizedBox(
|
|
|
|
height: 30,
|
|
|
|
width: 30,
|
|
|
|
child: CircularProgressIndicator(
|
|
|
|
color: Colors.amber[100],
|
|
|
|
),
|
2022-04-30 01:48:17 +02:00
|
|
|
),
|
|
|
|
]),
|
|
|
|
),
|
|
|
|
]);
|
2022-05-05 22:31:16 +02:00
|
|
|
} else if (snapshot.connectionState ==
|
|
|
|
ConnectionState.done) {
|
|
|
|
if (snapshot.hasError) {
|
|
|
|
return Stack(children: [
|
|
|
|
Container(
|
|
|
|
height: 10000,
|
|
|
|
width: 10000,
|
|
|
|
color: const Color(0xFF121212)),
|
|
|
|
Center(
|
|
|
|
child: Column(children: [
|
|
|
|
const SizedBox(height: 20),
|
|
|
|
Text(
|
2023-04-15 22:10:29 +02:00
|
|
|
'Error: ${snapshot.error}',
|
2022-05-05 22:31:16 +02:00
|
|
|
style: TextStyle(color: Colors.grey[500]),
|
|
|
|
),
|
|
|
|
]),
|
2022-04-30 01:48:17 +02:00
|
|
|
),
|
2022-05-05 22:31:16 +02:00
|
|
|
]);
|
|
|
|
} else if (snapshot.hasData) {
|
|
|
|
return Table(
|
|
|
|
columnWidths: {
|
|
|
|
0: const FlexColumnWidth(4),
|
|
|
|
1: const FlexColumnWidth(2),
|
|
|
|
2: const FlexColumnWidth(1),
|
|
|
|
},
|
|
|
|
defaultVerticalAlignment:
|
|
|
|
TableCellVerticalAlignment.middle,
|
|
|
|
children: snapshot.data!
|
|
|
|
.map(
|
|
|
|
(item) => _buildTableRow(item, context))
|
|
|
|
.toList()
|
|
|
|
..insert(
|
|
|
|
0,
|
|
|
|
_buildTableRow(
|
|
|
|
Track(
|
|
|
|
number: -1,
|
|
|
|
title: 'TITRE',
|
|
|
|
artiste: 'ARTISTE',
|
|
|
|
album: 'ALBUM',
|
|
|
|
id: 'URL'),
|
|
|
|
context),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
return const Text('Empty data');
|
|
|
|
}
|
2022-04-30 01:48:17 +02:00
|
|
|
} else {
|
2022-05-05 22:31:16 +02:00
|
|
|
return Text('State: ${snapshot.connectionState}');
|
2022-04-30 01:48:17 +02:00
|
|
|
}
|
2022-05-05 22:31:16 +02:00
|
|
|
},
|
2022-04-28 21:24:26 +02:00
|
|
|
),
|
2022-05-05 22:31:16 +02:00
|
|
|
const SizedBox(height: 70)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
)),
|
|
|
|
),
|
|
|
|
Consumer<PlayerProvider>(builder: (context, playerProvider, _) {
|
|
|
|
TextEditingController trackTitle = TextEditingController();
|
|
|
|
TextEditingController trackArtiste = TextEditingController();
|
|
|
|
trackTitle.text = hp.currentTrack?.title ?? '';
|
|
|
|
trackArtiste.text = hp.currentTrack?.artiste ?? '';
|
|
|
|
return Miniplayer(
|
|
|
|
controller: controller,
|
|
|
|
backgroundColor: Colors.grey[900]!,
|
|
|
|
minHeight: 70,
|
|
|
|
maxHeight: 70,
|
|
|
|
builder: (height, percentage) {
|
|
|
|
return Row(
|
|
|
|
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
hp.currentTrack?.imageUrl != '' &&
|
|
|
|
hp.currentTrack?.imageUrl != null
|
|
|
|
? Image.network(
|
|
|
|
hp.currentTrack!.imageUrl!,
|
|
|
|
width: 70,
|
|
|
|
)
|
|
|
|
: const SizedBox(width: 70),
|
|
|
|
Expanded(
|
|
|
|
child: Column(children: [
|
|
|
|
SizedBox(
|
|
|
|
height: 20,
|
|
|
|
child: TextField(
|
|
|
|
enabled: false,
|
|
|
|
maxLines: 1,
|
|
|
|
controller: trackTitle,
|
|
|
|
decoration: const InputDecoration(
|
|
|
|
border: InputBorder.none,
|
|
|
|
focusedBorder: InputBorder.none,
|
|
|
|
enabledBorder: InputBorder.none,
|
|
|
|
disabledBorder: InputBorder.none,
|
|
|
|
contentPadding: EdgeInsets.only(left: 15),
|
|
|
|
),
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 14,
|
|
|
|
color: Colors.grey[300],
|
|
|
|
),
|
2022-04-28 21:24:26 +02:00
|
|
|
),
|
2022-05-05 22:31:16 +02:00
|
|
|
),
|
|
|
|
SizedBox(
|
|
|
|
height: 20,
|
|
|
|
child: TextField(
|
|
|
|
enabled: false,
|
|
|
|
maxLines: 1,
|
|
|
|
controller: trackArtiste,
|
|
|
|
decoration: const InputDecoration(
|
|
|
|
border: InputBorder.none,
|
|
|
|
focusedBorder: InputBorder.none,
|
|
|
|
enabledBorder: InputBorder.none,
|
|
|
|
disabledBorder: InputBorder.none,
|
|
|
|
contentPadding: EdgeInsets.only(left: 15),
|
|
|
|
),
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12,
|
|
|
|
color: Colors.grey[500],
|
|
|
|
),
|
2022-04-28 21:24:26 +02:00
|
|
|
),
|
|
|
|
),
|
2022-04-29 12:18:26 +02:00
|
|
|
]),
|
2022-05-05 22:31:16 +02:00
|
|
|
),
|
|
|
|
Column(children: [
|
|
|
|
const Spacer(),
|
|
|
|
Row(children: [
|
|
|
|
const SizedBox(width: 70),
|
|
|
|
Column(children: [
|
|
|
|
IconButton(
|
|
|
|
padding: const EdgeInsets.all(0),
|
|
|
|
icon: Icon(Icons.skip_previous,
|
|
|
|
color: Colors.grey[500], size: 32),
|
|
|
|
onPressed: () {
|
|
|
|
if (hp.currentTrack != null &&
|
|
|
|
hp.currentTrack!.number > 1) {
|
|
|
|
hp.currentTrack = hp.trackList.firstWhere(
|
|
|
|
(element) =>
|
|
|
|
element.number ==
|
|
|
|
hp.currentTrack!.number - 1);
|
|
|
|
hp.playTrack(context, hp.currentTrack!);
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
]),
|
|
|
|
const SizedBox(width: 1),
|
|
|
|
ElevatedButton(
|
|
|
|
onPressed: () {
|
2022-05-06 17:15:41 +02:00
|
|
|
hp.player.state.name == 'playing'
|
|
|
|
? hp.player.pause()
|
|
|
|
: hp.player.resume();
|
|
|
|
|
2022-05-05 22:31:16 +02:00
|
|
|
// playerProvider.reload();
|
|
|
|
},
|
2023-04-15 22:10:29 +02:00
|
|
|
style: ElevatedButton.styleFrom(
|
|
|
|
foregroundColor: Colors.grey[900],
|
|
|
|
backgroundColor: Colors.grey[300],
|
|
|
|
shape: const CircleBorder(),
|
|
|
|
padding: const EdgeInsets.all(12),
|
|
|
|
),
|
2022-05-05 22:31:16 +02:00
|
|
|
child: Icon(
|
2022-05-06 17:15:41 +02:00
|
|
|
hp.player.state.name == 'playing'
|
2022-05-05 22:31:16 +02:00
|
|
|
? Icons.pause
|
|
|
|
: Icons.play_arrow,
|
|
|
|
color: Colors.grey[900],
|
|
|
|
size: 30),
|
2022-04-29 12:18:26 +02:00
|
|
|
),
|
2022-05-05 22:31:16 +02:00
|
|
|
Column(children: [
|
|
|
|
IconButton(
|
|
|
|
padding: const EdgeInsets.all(0),
|
|
|
|
icon: Icon(Icons.skip_next,
|
|
|
|
color: Colors.grey[500], size: 32),
|
|
|
|
onPressed: () {
|
|
|
|
if (hp.currentTrack != null &&
|
|
|
|
hp.currentTrack!.number <
|
|
|
|
hp.trackList.last.number) {
|
|
|
|
hp.currentTrack = hp.trackList.firstWhere(
|
|
|
|
(element) =>
|
|
|
|
element.number ==
|
|
|
|
hp.currentTrack!.number + 1);
|
|
|
|
hp.playTrack(context, hp.currentTrack!);
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
// const SizedBox(height: 7),
|
|
|
|
]),
|
2022-04-29 12:18:26 +02:00
|
|
|
]),
|
2022-05-05 22:31:16 +02:00
|
|
|
const Spacer(),
|
|
|
|
Row(children: [
|
|
|
|
const SizedBox(width: 70),
|
|
|
|
Text(
|
2022-05-06 17:15:41 +02:00
|
|
|
timeFormat(hp.currentTrack?.position ??
|
2022-05-05 22:31:16 +02:00
|
|
|
const Duration(seconds: 0)),
|
|
|
|
style:
|
|
|
|
TextStyle(color: Colors.grey[500], fontSize: 12),
|
2022-04-29 12:18:26 +02:00
|
|
|
),
|
2022-05-05 22:31:16 +02:00
|
|
|
const SizedBox(width: 3),
|
|
|
|
SliderTheme(
|
|
|
|
data: const SliderThemeData(
|
|
|
|
thumbShape:
|
|
|
|
RoundSliderThumbShape(enabledThumbRadius: 2),
|
|
|
|
overlayShape:
|
|
|
|
RoundSliderThumbShape(enabledThumbRadius: 5),
|
|
|
|
trackHeight: 2,
|
|
|
|
),
|
|
|
|
child: SizedBox(
|
|
|
|
width: 300,
|
|
|
|
child: Slider(
|
2022-05-06 17:15:41 +02:00
|
|
|
value: double.parse(hp
|
|
|
|
.currentTrack?.position?.inSeconds
|
|
|
|
.toString() ??
|
|
|
|
'0'),
|
|
|
|
max: double.parse(hp
|
|
|
|
.currentTrack?.duration?.inSeconds
|
|
|
|
.toString() ??
|
|
|
|
'2000'),
|
2022-05-05 22:31:16 +02:00
|
|
|
onChanged: (double value) {
|
2022-05-06 17:15:41 +02:00
|
|
|
if (hp.currentTrack?.position != null) {
|
|
|
|
hp.player.seek(
|
|
|
|
Duration(seconds: value.toInt()),
|
|
|
|
);
|
2022-05-05 22:31:16 +02:00
|
|
|
playerProvider.reload();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
activeColor: Colors.grey[400],
|
|
|
|
inactiveColor: Colors.grey[700],
|
|
|
|
),
|
2022-04-29 12:18:26 +02:00
|
|
|
),
|
|
|
|
),
|
2022-05-05 22:31:16 +02:00
|
|
|
const SizedBox(width: 3),
|
|
|
|
Text(
|
2022-05-06 17:15:41 +02:00
|
|
|
timeFormat(hp.currentTrack?.duration ??
|
2022-05-05 22:31:16 +02:00
|
|
|
const Duration(seconds: 0)),
|
|
|
|
style:
|
|
|
|
TextStyle(color: Colors.grey[500], fontSize: 12),
|
|
|
|
),
|
|
|
|
]),
|
|
|
|
const Spacer(),
|
2022-04-29 12:18:26 +02:00
|
|
|
]),
|
|
|
|
const Spacer(),
|
2022-05-05 22:31:16 +02:00
|
|
|
SliderTheme(
|
|
|
|
data: const SliderThemeData(
|
|
|
|
thumbShape:
|
|
|
|
RoundSliderThumbShape(enabledThumbRadius: 7),
|
|
|
|
overlayShape:
|
|
|
|
RoundSliderThumbShape(enabledThumbRadius: 8),
|
|
|
|
trackHeight: 2.5,
|
|
|
|
),
|
|
|
|
child: SizedBox(
|
|
|
|
width: 130,
|
|
|
|
child: Slider(
|
2022-05-06 17:15:41 +02:00
|
|
|
value: hp.currentVolume,
|
2022-05-05 22:31:16 +02:00
|
|
|
max: 1,
|
2022-05-06 17:15:41 +02:00
|
|
|
onChanged: (double value) async {
|
|
|
|
hp.currentVolume = value;
|
|
|
|
await hp.player.setVolume(value);
|
|
|
|
playerProvider.reload();
|
2022-05-05 22:31:16 +02:00
|
|
|
},
|
|
|
|
activeColor: Colors.grey[400],
|
|
|
|
inactiveColor: Colors.grey[700],
|
|
|
|
),
|
2022-04-28 21:24:26 +02:00
|
|
|
),
|
|
|
|
),
|
2022-05-05 22:31:16 +02:00
|
|
|
const SizedBox(width: 20)
|
|
|
|
],
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
})
|
|
|
|
],
|
|
|
|
),
|
2022-04-28 21:24:26 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget trackLine(Track track) {
|
|
|
|
return SizedBox(
|
|
|
|
height: 30,
|
|
|
|
child: Row(
|
2023-04-15 22:10:29 +02:00
|
|
|
children: [Text('${track.title} - ${track.artiste}')],
|
2022-04-28 21:24:26 +02:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
TableRow _buildTableRow(Track track, BuildContext context) {
|
2022-04-29 12:18:26 +02:00
|
|
|
DownloadProvider downloadProvider =
|
|
|
|
Provider.of<DownloadProvider>(context, listen: false);
|
2022-04-30 01:48:17 +02:00
|
|
|
HomeProvider hp = Provider.of<HomeProvider>(context, listen: false);
|
|
|
|
int isDownloading = -1;
|
2022-04-29 12:18:26 +02:00
|
|
|
|
2022-04-28 21:24:26 +02:00
|
|
|
final textStyle = TextStyle(
|
|
|
|
fontWeight: track.number == -1 ? FontWeight.w200 : FontWeight.normal,
|
|
|
|
color: Colors.grey[500],
|
|
|
|
fontSize: track.number == -1 ? 15 : 14);
|
|
|
|
const rowPadding = EdgeInsets.all(10);
|
|
|
|
final yt = YoutubeExplode();
|
|
|
|
|
|
|
|
return TableRow(
|
|
|
|
decoration: const BoxDecoration(
|
|
|
|
color: Color(0xFF121212),
|
|
|
|
),
|
|
|
|
children: [
|
|
|
|
TableCell(
|
|
|
|
child: Padding(
|
|
|
|
padding: rowPadding,
|
|
|
|
child: InkWell(
|
|
|
|
onTap: () async {
|
|
|
|
if (track.number != -1) {
|
2022-05-14 16:54:41 +02:00
|
|
|
// FutureBuilder<void>(
|
|
|
|
// future: hp.playTrack(context, track),
|
|
|
|
// builder: (
|
|
|
|
// BuildContext context,
|
|
|
|
// AsyncSnapshot<void> snapshot,
|
|
|
|
// ) {
|
|
|
|
// return const SizedBox();
|
|
|
|
// },
|
|
|
|
// );
|
2022-04-30 01:48:17 +02:00
|
|
|
hp.playTrack(context, track);
|
2022-04-28 21:24:26 +02:00
|
|
|
}
|
|
|
|
},
|
2022-04-30 01:48:17 +02:00
|
|
|
child: Row(children: [
|
|
|
|
track.number != -1
|
|
|
|
? track.image == ''
|
|
|
|
? const SizedBox(width: 40)
|
|
|
|
: Image.memory(base64Decode(track.image!), height: 40)
|
|
|
|
: const SizedBox(),
|
|
|
|
const SizedBox(width: 10),
|
|
|
|
Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Consumer<PlayerProvider>(
|
|
|
|
builder: (context, playerProvider, _) {
|
|
|
|
return Text(track.title,
|
|
|
|
style: TextStyle(
|
|
|
|
fontWeight: FontWeight.normal,
|
2022-05-02 12:41:13 +02:00
|
|
|
color:
|
|
|
|
hp.currentTrack?.title == track.title &&
|
|
|
|
hp.currentTrack?.artiste ==
|
|
|
|
track.artiste
|
|
|
|
? Colors.green
|
|
|
|
: Colors.grey[350],
|
2022-04-30 01:48:17 +02:00
|
|
|
fontSize: 14));
|
|
|
|
}),
|
|
|
|
const SizedBox(height: 2),
|
|
|
|
if (track.number != -1)
|
|
|
|
Text(track.artiste,
|
|
|
|
style: TextStyle(
|
|
|
|
fontWeight: FontWeight.normal,
|
|
|
|
color: Colors.grey[500],
|
|
|
|
fontSize: 13))
|
|
|
|
]),
|
|
|
|
]),
|
2022-04-28 21:24:26 +02:00
|
|
|
)),
|
|
|
|
),
|
|
|
|
TableCell(
|
|
|
|
child: Padding(
|
|
|
|
padding: rowPadding,
|
|
|
|
child: Text(track.album ?? '', style: textStyle),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
TableCell(
|
|
|
|
child: Padding(
|
|
|
|
padding: rowPadding,
|
|
|
|
child: InkWell(
|
2022-04-29 12:18:26 +02:00
|
|
|
onTap: () async {
|
|
|
|
isDownloading = track.number;
|
|
|
|
downloadProvider.reload();
|
|
|
|
if (track.id == null) {
|
|
|
|
final secondMatch =
|
|
|
|
track.artiste == '' ? track.album : track.artiste;
|
|
|
|
final resultUrl = await yt.search
|
2023-04-15 22:10:29 +02:00
|
|
|
.search('${track.title} ${secondMatch!}');
|
2022-04-29 12:18:26 +02:00
|
|
|
track.id = resultUrl.first.id.value;
|
2022-04-28 21:24:26 +02:00
|
|
|
}
|
2022-04-29 12:18:26 +02:00
|
|
|
if (track.id != null) {
|
2022-04-30 01:48:17 +02:00
|
|
|
hp.downloadMusic(context, track);
|
2022-04-29 12:18:26 +02:00
|
|
|
}
|
|
|
|
isDownloading = -1;
|
2022-04-29 17:38:23 +02:00
|
|
|
yt.close();
|
2022-04-29 12:18:26 +02:00
|
|
|
downloadProvider.reload();
|
|
|
|
},
|
|
|
|
child: track.number == -1
|
|
|
|
? Text('TÉLÉCHARGER', style: textStyle)
|
2022-04-30 19:29:24 +02:00
|
|
|
: Consumer<DownloadProvider>(builder: (context, _, __) {
|
2022-04-29 12:18:26 +02:00
|
|
|
return Row(children: [
|
|
|
|
const SizedBox(width: 37),
|
|
|
|
isDownloading == track.number
|
|
|
|
? SizedBox(
|
|
|
|
height: 20,
|
|
|
|
width: 20,
|
|
|
|
child: CircularProgressIndicator(
|
|
|
|
strokeWidth: 2,
|
|
|
|
color: Colors.grey[500],
|
|
|
|
),
|
|
|
|
)
|
|
|
|
: Icon(Icons.download, color: Colors.grey[500]),
|
|
|
|
]);
|
|
|
|
}))),
|
2022-04-28 21:24:26 +02:00
|
|
|
),
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2022-04-29 12:18:26 +02:00
|
|
|
String timeFormat(Duration d) {
|
|
|
|
String dd = d.toString().split('.').first;
|
|
|
|
String minutes = dd.toString().split(':')[1];
|
|
|
|
String seconds = dd.toString().split(':')[2];
|
|
|
|
return '$minutes:$seconds';
|
|
|
|
}
|
2022-05-06 12:53:01 +02:00
|
|
|
|
|
|
|
// class AdjustableScrollController extends ScrollController {
|
|
|
|
// AdjustableScrollController([int extraScrollSpeed = 40]) {
|
|
|
|
// // super.initialScrollOffset = 50;
|
|
|
|
// super.addListener(() {
|
|
|
|
// ScrollDirection scrollDirection = super.position.userScrollDirection;
|
|
|
|
// if (scrollDirection != ScrollDirection.idle) {
|
|
|
|
// double scrollEnd = super.offset +
|
|
|
|
// (scrollDirection == ScrollDirection.reverse
|
|
|
|
// ? extraScrollSpeed
|
|
|
|
// : -extraScrollSpeed);
|
|
|
|
// scrollEnd = min(super.position.maxScrollExtent,
|
|
|
|
// max(super.position.minScrollExtent, scrollEnd));
|
|
|
|
// WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
// if (super.hasClients) jumpTo(scrollEnd);
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
// }
|