1
1
import 'package:flutter/material.dart' ;
2
+ import 'package:flutter_bloc/flutter_bloc.dart' ;
2
3
import 'package:spotify_with_flutter/common/helpers/is_dark_mode.dart' ;
3
4
import 'package:spotify_with_flutter/common/widgets/appbar/app_bar.dart' ;
4
5
import 'package:spotify_with_flutter/core/configs/theme/app_color.dart' ;
5
6
import 'package:spotify_with_flutter/core/constants/app_urls.dart' ;
6
7
import 'package:spotify_with_flutter/domain/entities/songs/songs.dart' ;
8
+ import 'package:spotify_with_flutter/presentation/song_player.dart/bloc/song_player_cubit.dart' ;
9
+ import 'package:spotify_with_flutter/presentation/song_player.dart/bloc/song_player_state.dart' ;
7
10
8
11
class SongPlayerPage extends StatelessWidget {
9
12
final SongEntity songEntity;
@@ -28,21 +31,27 @@ class SongPlayerPage extends StatelessWidget {
28
31
onPressed: () {},
29
32
icon: Icon (
30
33
Icons .more_vert_rounded,
31
- color: context.isDarkMode
32
- ? const Color (0xff959595 )
33
- : const Color (0xff555555 ),
34
+ color: context.isDarkMode ? const Color (0xff959595 ) : const Color (0xff555555 ),
34
35
),
35
36
),
36
37
),
37
- body: SingleChildScrollView (
38
- child: Padding (
39
- padding: const EdgeInsets .symmetric (horizontal: 16 , vertical: 20 ),
40
- child: Column (
41
- children: [
42
- _songCover (context),
43
- const SizedBox (height: 10 ),
44
- _songDetail (),
45
- ],
38
+ body: BlocProvider (
39
+ create: (_) => SongPlayerCubit ()
40
+ ..loadSong (
41
+ '${AppUrls .songFireStorage }${AppUrls .temp }${songEntity .idImg }.mp3?${AppUrls .mediaAlt }' ,
42
+ ),
43
+ child: SingleChildScrollView (
44
+ child: Padding (
45
+ padding: const EdgeInsets .symmetric (horizontal: 16 , vertical: 20 ),
46
+ child: Column (
47
+ children: [
48
+ _songCover (context),
49
+ const SizedBox (height: 10 ),
50
+ _songDetail (),
51
+ const SizedBox (height: 30 ),
52
+ _songPlayer (context),
53
+ ],
54
+ ),
46
55
),
47
56
),
48
57
),
@@ -57,7 +66,7 @@ class SongPlayerPage extends StatelessWidget {
57
66
image: DecorationImage (
58
67
fit: BoxFit .cover,
59
68
image: NetworkImage (
60
- '${AppUrls .fireStorage }${AppUrls .temp }${songEntity .idImg }.jpg?${AppUrls .mediaAlt }' ,
69
+ '${AppUrls .coverFireStorage }${AppUrls .temp }${songEntity .idImg }.jpg?${AppUrls .mediaAlt }' ,
61
70
),
62
71
),
63
72
),
@@ -101,4 +110,30 @@ class SongPlayerPage extends StatelessWidget {
101
110
],
102
111
);
103
112
}
113
+
114
+ Widget _songPlayer (BuildContext context) {
115
+ return BlocBuilder <SongPlayerCubit , SongPlayerState >(
116
+ builder: (BuildContext context, SongPlayerState state) {
117
+ if (state is SongPlayerLoading ) {
118
+ return const CircularProgressIndicator ();
119
+ }
120
+
121
+ if (state is SongPlayerLoaded ) {
122
+ return Column (
123
+ children: [
124
+ Slider (
125
+ value: context.read <SongPlayerCubit >().songPosition.inSeconds.toDouble (),
126
+ min: 0.0 ,
127
+ max: context.read <SongPlayerCubit >().songPosition.inSeconds.toDouble (),
128
+ onChanged: (value) {},
129
+ ),
130
+ const SizedBox (height: 20 ),
131
+ ],
132
+ );
133
+ }
134
+
135
+ return Container ();
136
+ },
137
+ );
138
+ }
104
139
}
0 commit comments