Skip to content
Snippets Groups Projects
Commit 4005fe0f authored by Erik Hinkelmanns's avatar Erik Hinkelmanns
Browse files

- added music bar for all pages

parent 9313f55c
No related branches found
No related tags found
No related merge requests found
......@@ -4,7 +4,6 @@ import 'package:ambient/widgets/MusicPlayerState.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:spotify_sdk/models/connection_status.dart';
import 'package:spotify_sdk/models/image_uri.dart';
import 'package:spotify_sdk/models/player_context.dart';
......@@ -71,20 +70,6 @@ class HomePage extends StatelessWidget {
: const Center(
child: Text('Not connected'),
),
const Divider(),
/*const Text(
'Player Context',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
_connected
? _buildPlayerContextWidget()
: const Center(
child: Text('Not connected'),
),
_connected ? utilityBar(context) : Text("noUtilBar"),*/
],
),
MusicPlayerState.of(context).loading
......@@ -103,7 +88,6 @@ class HomePage extends StatelessWidget {
var track = snapshot.data?.track;
MusicPlayerState.of(context).currentTrackImageUri = track?.imageUri;
var playerState = snapshot.data;
if (playerState == null || track == null) {
return const Center(
child: Text('Not connected'),
......@@ -303,7 +287,6 @@ class HomePage extends StatelessWidget {
}
}
//todo usage?
void setStatus(String code, {String? message}) {
var text = message ?? '';
printErr(text);
......
......@@ -5,6 +5,9 @@ import 'package:ambient/searchpage.dart';
import 'package:ambient/widgets/navbars.dart';
import 'package:flutter/material.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:spotify_sdk/models/player_state.dart';
import 'package:spotify_sdk/spotify_sdk.dart';
import 'homepage.dart';
import 'moodpage.dart';
......@@ -72,7 +75,57 @@ class _HUDState extends State<HUD> {
StateSearcgPage(),
],
),
bottomNavigationBar: BottomNavigationBar(
bottomNavigationBar: Column(
mainAxisSize: MainAxisSize.min,
children: [
_currentIndex != 0
? StreamBuilder<PlayerState>(
stream: SpotifySdk.subscribePlayerState(),
builder:
(BuildContext context, AsyncSnapshot<PlayerState> snapshot) {
var track = snapshot.data?.track;
MusicPlayerState.of(context).currentTrackImageUri =
track?.imageUri;
var playerState = snapshot.data;
if (playerState == null || track == null) {
return const Center(
child: Text('Not connected'),
);
}
return Row(
children: [
Container(
height: 80,
color: Colors.grey,
child: Row(
children: [
Container(
alignment: Alignment.centerRight,
width: 100,
color: Colors.blue,
),
playerState.isPaused
? const IconButton(
icon: Icon(Icons.play_arrow_outlined),
iconSize: 50,
onPressed: SpotifySdk.resume,
)
: const IconButton(
icon: Icon(Icons.pause_outlined),
iconSize: 50,
color: primaryColor,
onPressed: SpotifySdk.pause,
),
],
),
),
],
);
})
: const Center(
child: Text('Moin'),
),
BottomNavigationBar(
currentIndex: _currentIndex,
backgroundColor: ligten(primaryContainer),
selectedItemColor: primaryColor,
......@@ -83,14 +136,18 @@ class _HUDState extends State<HUD> {
label: "Play",
),
BottomNavigationBarItem(icon: Icon(Icons.mood), label: "Moods"),
BottomNavigationBarItem(icon: Icon(Icons.search), label: "Suchen"),
BottomNavigationBarItem(
icon: Icon(Icons.search), label: "Suchen"),
],
onTap: (newIndex) {
_pageController.animateToPage(newIndex,
duration: const Duration(milliseconds: 500), curve: Curves.ease);
duration: const Duration(milliseconds: 500),
curve: Curves.ease);
_title = _titleList[newIndex];
},
),
],
),
);
}
}
......@@ -5,7 +5,6 @@ import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:spotify_sdk/models/image_uri.dart';
import 'package:logger/logger.dart';
import 'package:spotify_sdk/spotify_sdk.dart';
class MusicPlayerState extends InheritedWidget {
......@@ -30,6 +29,7 @@ class MusicPlayerState extends InheritedWidget {
rebuildStream.sink.add(Null);
}
Future<void> disconnect() async {
try {
setLoading(true);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment