Skip to content

Commit

Permalink
refactor: slide_up
Browse files Browse the repository at this point in the history
  • Loading branch information
Yesterday17 committed Sep 16, 2024
1 parent ee31f30 commit 426e401
Show file tree
Hide file tree
Showing 6 changed files with 581 additions and 41 deletions.
52 changes: 22 additions & 30 deletions lib/ui/layout/layout.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import 'package:annix/ui/page/playing/playing_mobile_blur.dart';
import 'package:annix/ui/route/delegate.dart';
import 'package:annix/ui/bottom_player/bottom_player.dart';
import 'package:annix/ui/route/page.dart';
import 'package:annix/ui/widgets/slide_up.dart';
import 'package:annix/utils/context_extension.dart';
import 'package:flutter/material.dart';
import 'package:flutter_adaptive_scaffold/flutter_adaptive_scaffold.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:sliding_up_panel2/sliding_up_panel2.dart';
import 'package:annix/i18n/strings.g.dart';
import 'package:flutter_hooks/flutter_hooks.dart';

Expand Down Expand Up @@ -97,45 +97,37 @@ class AnnixLayout extends HookConsumerWidget {
child: child!,
),
if (showMiniPlayer)
LayoutBuilder(
builder: (context, constraints) => MediaQuery(
data: MediaQuery.of(context).copyWith(
size: Size(constraints.maxWidth, constraints.maxHeight)),
child: SlidingUpPanel(
controller: router.panelController,
renderPanelSheet: false,
color: Colors.transparent,
borderRadius: BorderRadius.circular(8),
panelBuilder: () {
return panel;
},
collapsed: GestureDetector(
onTap: router.openPanel,
child: SlotLayout(
config: <Breakpoint, SlotLayoutConfig>{
Breakpoints.small: SlotLayout.from(
key: const Key('Bottom Player Small'),
builder: (context) => const MobileBottomPlayer(),
),
Breakpoints.mediumAndUp: SlotLayout.from(
key: const Key('Bottom Player Medium'),
builder: (context) => const DesktopBottomPlayer(),
),
},
SlidingUpPanel(
controller: router.panelController,
borderRadius: BorderRadius.circular(8),
panel: panel,
isDraggable: context.isMobileOrPortrait,
collapsed: GestureDetector(
onTap: router.openPanel,
child: SlotLayout(
config: <Breakpoint, SlotLayoutConfig>{
Breakpoints.small: SlotLayout.from(
key: const Key('Bottom Player Small'),
builder: (context) => const MobileBottomPlayer(),
),
),
minHeight: miniPlayerHeight,
maxHeight: panelMaxSize,
onPanelSlide: (pos) => positionState.value = pos,
Breakpoints.mediumAndUp: SlotLayout.from(
key: const Key('Bottom Player Medium'),
builder: (context) => const DesktopBottomPlayer(),
),
},
),
),
minHeight: miniPlayerHeight,
maxHeight: panelMaxSize,
onPanelSlide: (pos) => positionState.value = pos,
)
],
);
},
child: child,
);
final root = AdaptiveLayout(
internalAnimations: false,
primaryNavigation: SlotLayout(config: <Breakpoint, SlotLayoutConfig>{
Breakpoints.mediumAndUp: SlotLayout.from(
key: const Key('Primary Navigation Medium'),
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/route/delegate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import 'package:annix/services/metadata/metadata_model.dart';
import 'package:annix/ui/page/home/home.dart';
import 'package:annix/ui/page/search.dart';
import 'package:annix/ui/route/page.dart';
import 'package:annix/ui/widgets/slide_up.dart';
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:sliding_up_panel2/sliding_up_panel2.dart';

class AnnixRouterDelegate extends RouterDelegate<List<RouteSettings>>
with ChangeNotifier, PopNavigatorRouterDelegateMixin<List<RouteSettings>> {
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/widgets/lyric.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import 'package:annix/providers.dart';
import 'package:annix/services/metadata/metadata_model.dart';
import 'package:annix/services/playback/playback.dart';
import 'package:annix/ui/widgets/slide_up.dart';
import 'package:annix/utils/context_extension.dart';
import 'package:flutter/material.dart';
import 'package:flutter_lyric/lyrics_reader.dart';
import 'package:annix/i18n/strings.g.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:sliding_up_panel2/sliding_up_panel2.dart';

extension on LyricAlign {
TextAlign get textAlign {
Expand Down
Loading

0 comments on commit 426e401

Please sign in to comment.