Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Ambient
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Daniel Furaev
Ambient
Commits
9313f55c
Commit
9313f55c
authored
Jan 12, 2023
by
Erik Hinkelmanns
Browse files
Options
Downloads
Patches
Plain Diff
- added snackbar feedback on connect
parent
45f81063
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/homepage.dart
+19
-35
19 additions, 35 deletions
lib/homepage.dart
lib/widgets/musicPlayerState.dart
+4
-1
4 additions, 1 deletion
lib/widgets/musicPlayerState.dart
with
23 additions
and
36 deletions
lib/homepage.dart
+
19
−
35
View file @
9313f55c
...
...
@@ -26,7 +26,6 @@ class HomePage extends StatelessWidget {
return
StreamBuilder
<
ConnectionStatus
>(
stream:
SpotifySdk
.
subscribeConnectionStatus
(),
builder:
(
context
,
snapshot
)
{
//_connected = false
var
data
=
snapshot
.
data
;
if
(
data
!=
null
)
{
MusicPlayerState
.
of
(
context
)
.
connected
=
data
.
connected
;
...
...
@@ -39,36 +38,7 @@ class HomePage extends StatelessWidget {
);
}
Widget
utilityBar
(
BuildContext
context
)
{
return
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceEvenly
,
children:
<
Widget
>[
IconButton
(
icon:
const
Icon
(
Icons
.
queue_music
),
iconSize:
50
,
onPressed:
queue
,
),
IconButton
(
icon:
const
Icon
(
Icons
.
playlist_play
),
iconSize:
50
,
onPressed:
play
,
),
IconButton
(
icon:
const
Icon
(
Icons
.
info
),
iconSize:
50
,
color:
primaryColor
,
onPressed:
()
=
>
checkIfAppIsActive
(
context
),
),
MusicPlayerState
.
of
(
context
)
.
connected
?
IconButton
(
onPressed:
MusicPlayerState
.
of
(
context
)
.
disconnect
,
icon:
const
Icon
(
Icons
.
exit_to_app
),
)
:
Container
()
],
);
}
//Todo rename method
Widget
_sampleFlowWidget
(
BuildContext
context
)
{
return
Stack
(
children:
[
...
...
@@ -79,8 +49,12 @@ class HomePage extends StatelessWidget {
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
children:
<
Widget
>[
TextButton
(
onPressed:
MusicPlayerState
.
of
(
context
)
.
connectToSpotifyRemote
,
onPressed:
()
async
{
MusicPlayerState
.
of
(
context
)
.
connected
=
await
MusicPlayerState
.
of
(
context
)
.
connectToSpotifyRemote
();
buildSnackbar
(
context
);
},
child:
const
Icon
(
Icons
.
settings_remote
),
),
IconButton
(
...
...
@@ -131,7 +105,7 @@ class HomePage extends StatelessWidget {
var
playerState
=
snapshot
.
data
;
if
(
playerState
==
null
||
track
==
null
)
{
return
Center
(
return
const
Center
(
child:
Text
(
'Not connected'
),
);
}
...
...
@@ -146,7 +120,7 @@ class HomePage extends StatelessWidget {
${track.album.name}
'''
,
maxLines:
20
,
style:
TextStyle
(
style:
const
TextStyle
(
fontSize:
16.0
,
fontWeight:
FontWeight
.
bold
,
color:
Colors
.
black
)),
...
...
@@ -329,10 +303,20 @@ class HomePage extends StatelessWidget {
}
}
//todo usage?
void
setStatus
(
String
code
,
{
String
?
message
})
{
var
text
=
message
??
''
;
printErr
(
text
);
}
void
buildSnackbar
(
BuildContext
context
)
{
final
snackBar
=
SnackBar
(
content:
Text
(
MusicPlayerState
.
of
(
context
)
.
connected
?
'connect to spotify successful'
:
'connect to spotify failed'
));
ScaffoldMessenger
.
of
(
context
)
.
showSnackBar
(
snackBar
);
}
}
Color
darken
(
Color
color
,
[
double
amount
=
.
1
])
{
...
...
This diff is collapsed.
Click to expand it.
lib/widgets/musicPlayerState.dart
+
4
−
1
View file @
9313f55c
...
...
@@ -45,7 +45,8 @@ class MusicPlayerState extends InheritedWidget {
}
}
Future
<
void
>
connectToSpotifyRemote
()
async
{
Future
<
bool
>
connectToSpotifyRemote
()
async
{
bool
isConnected
=
false
;
try
{
setLoading
(
true
);
var
result
=
await
SpotifySdk
.
connectToSpotifyRemote
(
...
...
@@ -55,6 +56,7 @@ class MusicPlayerState extends InheritedWidget {
?
'connect to spotify successful'
:
'connect to spotify failed'
);
setLoading
(
false
);
isConnected
=
result
;
}
on
PlatformException
catch
(
e
)
{
setLoading
(
false
);
setStatus
(
e
.
code
,
message:
e
.
message
);
...
...
@@ -62,6 +64,7 @@ class MusicPlayerState extends InheritedWidget {
setLoading
(
false
);
setStatus
(
'not implemented'
);
}
return
isConnected
;
}
void
setStatus
(
String
code
,
{
String
?
message
})
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment