Lyrics page Sidebar crash in mobile/tablet device bugfix

This commit is contained in:
Kingkor Roy Tirtho 2022-07-11 13:55:07 +06:00
parent 2a221d9cfb
commit c898716b06

View File

@ -10,6 +10,7 @@ import 'package:spotube/hooks/useBreakpoints.dart';
import 'package:spotube/models/sideBarTiles.dart'; import 'package:spotube/models/sideBarTiles.dart';
import 'package:spotube/provider/Auth.dart'; import 'package:spotube/provider/Auth.dart';
import 'package:spotube/provider/SpotifyRequests.dart'; import 'package:spotube/provider/SpotifyRequests.dart';
import 'package:spotube/utils/platform.dart';
class Sidebar extends HookConsumerWidget { class Sidebar extends HookConsumerWidget {
final int selectedIndex; final int selectedIndex;
@ -59,105 +60,110 @@ class Sidebar extends HookConsumerWidget {
return null; return null;
}); });
return Material( return SafeArea(
color: Theme.of(context).navigationRailTheme.backgroundColor, child: Material(
child: Column( color: Theme.of(context).navigationRailTheme.backgroundColor,
crossAxisAlignment: CrossAxisAlignment.start, child: Column(
children: [ crossAxisAlignment: CrossAxisAlignment.start,
if (selectedIndex == 3) children: [
SizedBox( if (selectedIndex == 3 && kIsDesktop)
height: appWindow.titleBarHeight, SizedBox(
width: titleBarDragMaxWidth.toDouble(), height: appWindow.titleBarHeight,
child: MoveWindow(), width: titleBarDragMaxWidth.toDouble(),
child: MoveWindow(),
),
Padding(
padding: const EdgeInsets.only(left: 15),
child: (extended.value)
? Row(
children: [
_buildSmallLogo(),
const SizedBox(
width: 10,
),
Text("Spotube",
style: Theme.of(context).textTheme.headline4),
],
)
: _buildSmallLogo(),
), ),
extended.value Expanded(
? Padding( child: NavigationRail(
padding: const EdgeInsets.only(left: 15), destinations: sidebarTileList
child: Row(children: [ .map(
_buildSmallLogo(), (e) => NavigationRailDestination(
const SizedBox( icon: Icon(e.icon),
width: 10, label: Text(
), e.title,
Text("Spotube", style: const TextStyle(
style: Theme.of(context).textTheme.headline4), fontWeight: FontWeight.bold,
]), fontSize: 16,
) ),
: _buildSmallLogo(),
Expanded(
child: NavigationRail(
destinations: sidebarTileList
.map(
(e) => NavigationRailDestination(
icon: Icon(e.icon),
label: Text(
e.title,
style: const TextStyle(
fontWeight: FontWeight.bold,
fontSize: 16,
), ),
), ),
), )
) .toList(),
.toList(), selectedIndex: selectedIndex,
selectedIndex: selectedIndex, onDestinationSelected: onSelectedIndexChanged,
onDestinationSelected: onSelectedIndexChanged, extended: extended.value,
extended: extended.value, ),
), ),
), SizedBox(
SizedBox( width: titleBarDragMaxWidth.toDouble(),
width: titleBarDragMaxWidth.toDouble(), child: Builder(
child: Builder( builder: (context) {
builder: (context) { final data = meSnapshot.asData?.value;
final data = meSnapshot.asData?.value;
final avatarImg = imageToUrlString(data?.images, final avatarImg = imageToUrlString(data?.images,
index: (data?.images?.length ?? 1) - 1); index: (data?.images?.length ?? 1) - 1);
if (extended.value) { if (extended.value) {
return Padding( return Padding(
padding: const EdgeInsets.all(16), padding: const EdgeInsets.all(16),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
if (auth.isLoggedIn && data == null) if (auth.isLoggedIn && data == null)
const Center( const Center(
child: CircularProgressIndicator(), child: CircularProgressIndicator(),
) )
else if (data != null) else if (data != null)
Row( Row(
children: [ children: [
CircleAvatar( CircleAvatar(
backgroundImage: backgroundImage:
CachedNetworkImageProvider(avatarImg), CachedNetworkImageProvider(avatarImg),
),
const SizedBox(width: 10),
Text(
data.displayName ?? "Guest",
style: const TextStyle(
fontWeight: FontWeight.bold,
), ),
), const SizedBox(width: 10),
], Text(
), data.displayName ?? "Guest",
IconButton( style: const TextStyle(
icon: const Icon(Icons.settings_outlined), fontWeight: FontWeight.bold,
onPressed: () => goToSettings(context)), ),
], ),
)); ],
} else { ),
return Padding( IconButton(
padding: const EdgeInsets.all(8.0), icon: const Icon(Icons.settings_outlined),
child: InkWell( onPressed: () => goToSettings(context)),
onTap: () => goToSettings(context), ],
child: CircleAvatar( ));
backgroundImage: CachedNetworkImageProvider(avatarImg), } else {
return Padding(
padding: const EdgeInsets.all(8.0),
child: InkWell(
onTap: () => goToSettings(context),
child: CircleAvatar(
backgroundImage:
CachedNetworkImageProvider(avatarImg),
),
), ),
), );
); }
} },
}, ),
), )
) ],
], ),
), ),
); );
} }