Skip to content

Commit

Permalink
Improve: Generalize the player bottom sheet widget
Browse files Browse the repository at this point in the history
  • Loading branch information
gokadzev committed Nov 29, 2023
1 parent 9a2a2ac commit eac3b9e
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 40 deletions.
43 changes: 3 additions & 40 deletions lib/screens/now_playing_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:musify/main.dart';
import 'package:musify/models/position_data.dart';
import 'package:musify/services/settings_manager.dart';
import 'package:musify/style/app_themes.dart';
import 'package:musify/utilities/flutter_bottom_sheet.dart';
import 'package:musify/utilities/flutter_toast.dart';
import 'package:musify/utilities/formatter.dart';
import 'package:musify/utilities/mediaitem.dart';
Expand Down Expand Up @@ -392,7 +393,7 @@ class _NowPlayingPageState extends State<NowPlayingPage> {
children: [
TextButton(
onPressed: () {
_showBottomSheet(
showCustomBottomSheet(
context,
ListView.builder(
shrinkWrap: true,
Expand Down Expand Up @@ -428,7 +429,7 @@ class _NowPlayingPageState extends State<NowPlayingPage> {
mediaItem.artist.toString(),
mediaItem.title.toString(),
);
_showBottomSheet(
showCustomBottomSheet(
context,
ValueListenableBuilder<String?>(
valueListenable: lyrics,
Expand Down Expand Up @@ -471,44 +472,6 @@ class _NowPlayingPageState extends State<NowPlayingPage> {
);
}

void _showBottomSheet(BuildContext context, Widget content) {
showBottomSheet(
context: context,
builder: (context) => Container(
decoration: const BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(18),
topRight: Radius.circular(18),
),
),
width: MediaQuery.of(context).size.width - 15,
height: MediaQuery.of(context).size.height / 2.14,
child: Column(
children: <Widget>[
Padding(
padding: EdgeInsets.only(
top: MediaQuery.of(context).size.height * 0.012,
),
child: IconButton(
icon: Icon(
FluentIcons.arrow_between_down_24_filled,
color: colorScheme.primary,
size: 20,
),
onPressed: () => Navigator.pop(context),
),
),
Expanded(
child: SingleChildScrollView(
child: content,
),
),
],
),
),
);
}

void _showAddToPlaylistDialog(BuildContext context, dynamic song) {
showDialog(
context: context,
Expand Down
41 changes: 41 additions & 0 deletions lib/utilities/flutter_bottom_sheet.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import 'package:fluentui_system_icons/fluentui_system_icons.dart';
import 'package:flutter/material.dart';
import 'package:musify/style/app_themes.dart';

void showCustomBottomSheet(BuildContext context, Widget content) {
showBottomSheet(
context: context,
builder: (context) => Container(
decoration: const BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(18),
topRight: Radius.circular(18),
),
),
width: MediaQuery.of(context).size.width - 15,
height: MediaQuery.of(context).size.height / 2.14,
child: Column(
children: <Widget>[
Padding(
padding: EdgeInsets.only(
top: MediaQuery.of(context).size.height * 0.012,
),
child: IconButton(
icon: Icon(
FluentIcons.arrow_between_down_24_filled,
color: colorScheme.primary,
size: 20,
),
onPressed: () => Navigator.pop(context),
),
),
Expanded(
child: SingleChildScrollView(
child: content,
),
),
],
),
),
);
}

0 comments on commit eac3b9e

Please sign in to comment.