Skip to content

Commit

Permalink
chore: tweaks/fixes
Browse files Browse the repository at this point in the history
+ comment copy will parse html first
+ yt description duration tap will seek
+ smol tagger fallback issue
+ show buffering in miniplayer when not using yt-styled miniplayer
+ theme color dialog refreshing
+ perf: app will not be painted when miniplayer expanded
+ fix queue item rebuild issue on reorder
+ drawer tweaks & others
  • Loading branch information
MSOB7YY committed Mar 3, 2024
1 parent 13c374c commit 1433488
Show file tree
Hide file tree
Showing 10 changed files with 217 additions and 139 deletions.
2 changes: 1 addition & 1 deletion lib/controller/ffmpeg_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class NamidaFFMPEG {
try {
final mainTags = (map['streams'] as List?)?.firstWhereEff((e) {
final t = e['tags'];
return t is List && t.isNotEmpty;
return t is Map && t.isNotEmpty;
});
tags = mainTags?['tags'];
} catch (_) {}
Expand Down
3 changes: 2 additions & 1 deletion lib/main_page_wrapper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ class _MainPageWrapperState extends State<MainPageWrapper> {
Widget build(BuildContext context) {
return NamidaInnerDrawer(
key: NamidaNavigator.inst.innerDrawerKey,
borderRadius: 38.0.multipliedRadius,
borderRadius: 42.0.multipliedRadius,
drawerChild: const NamidaDrawer(),
maxPercentage: 0.465.withMaximum(324.0 / context.width),
child: const MainScreenStack(),
);
}
Expand Down
76 changes: 43 additions & 33 deletions lib/packages/miniplayer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -150,23 +150,27 @@ class NamidaMiniPlayerTrack extends StatelessWidget {
queueItemExtent: Dimensions.inst.trackTileItemExtent,
itemBuilder: (context, i, currentIndex) {
final track = Player.inst.currentQueue[i];
return TrackTile(
key: Key("tt_$key"),
index: i,
trackOrTwd: track,
displayRightDragHandler: true,
draggableThumbnail: true,
queueSource: QueueSource.playerQueue,
cardColorOpacity: 0.5,
fadeOpacity: i < currentIndex ? 0.3 : 0.0,
onPlaying: () {
// -- to improve performance, skipping process of checking new queues, etc..
if (i == currentIndex) {
Player.inst.togglePlayPause();
} else {
Player.inst.skipToQueueItem(i);
}
},
final key = Key("${i}_${track.track.path}");
return (
TrackTile(
key: key,
index: i,
trackOrTwd: track,
displayRightDragHandler: true,
draggableThumbnail: true,
queueSource: QueueSource.playerQueue,
cardColorOpacity: 0.5,
fadeOpacity: i < currentIndex ? 0.3 : 0.0,
onPlaying: () {
// -- to improve performance, skipping process of checking new queues, etc..
if (i == currentIndex) {
Player.inst.togglePlayPause();
} else {
Player.inst.skipToQueueItem(i);
}
},
),
key,
);
},
getDurationMS: (currentItem) => currentItem.track.duration * 1000,
Expand Down Expand Up @@ -317,6 +321,7 @@ class NamidaMiniPlayerTrack extends StatelessWidget {
cp: bcp,
),
textBuilder: _textBuilder,
canShowBuffering: false,
),
);
}
Expand Down Expand Up @@ -378,22 +383,26 @@ class NamidaMiniPlayerYoutubeID extends StatelessWidget {
queueItemExtent: Dimensions.youtubeCardItemExtent,
itemBuilder: (context, i, currentIndex) {
final video = Player.inst.currentQueueYoutube[i];
return YTHistoryVideoCard(
key: Key("${i}_${video.id}"),
videos: Player.inst.currentQueueYoutube,
index: i,
day: null,
playlistID: null,
playlistName: '',
openMenuOnLongPress: false,
displayTimeAgo: false,
thumbnailHeight: context.width * 0.3 * 9 / 16,
fromPlayerQueue: true,
draggingEnabled: true,
draggableThumbnail: true,
showMoreIcon: true,
cardColorOpacity: 0.8,
fadeOpacity: i < currentIndex ? 0.3 : 0.0,
final key = Key("${i}_${video.id}");
return (
YTHistoryVideoCard(
key: key,
videos: Player.inst.currentQueueYoutube,
index: i,
day: null,
playlistID: null,
playlistName: '',
openMenuOnLongPress: false,
displayTimeAgo: false,
thumbnailHeight: context.width * 0.3 * 9 / 16,
fromPlayerQueue: true,
draggingEnabled: true,
draggableThumbnail: true,
showMoreIcon: true,
cardColorOpacity: 0.8,
fadeOpacity: i < currentIndex ? 0.3 : 0.0,
),
key,
);
},
getDurationMS: null,
Expand Down Expand Up @@ -549,6 +558,7 @@ class NamidaMiniPlayerYoutubeID extends StatelessWidget {
cp: bcp,
),
textBuilder: (item) => _textBuilder(context, item),
canShowBuffering: true,
),
);
}
Expand Down
76 changes: 49 additions & 27 deletions lib/packages/miniplayer_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import 'package:namida/core/icon_fonts/broken_icons.dart';
import 'package:namida/core/namida_converter_ext.dart';
import 'package:namida/core/translations/language.dart';
import 'package:namida/packages/focused_menu.dart';
import 'package:namida/packages/three_arched_circle.dart';
import 'package:namida/packages/miniplayer_raw.dart';
import 'package:namida/ui/widgets/animated_widgets.dart';
import 'package:namida/ui/widgets/custom_widgets.dart';
Expand Down Expand Up @@ -78,7 +79,7 @@ class MiniplayerTextData {
class NamidaMiniPlayerBase<E> extends StatefulWidget {
final List<E> queue;
final double queueItemExtent;
final Widget Function(BuildContext context, int index, int currentIndex) itemBuilder;
final (Widget, Key) Function(BuildContext context, int index, int currentIndex) itemBuilder;
final int Function(E currentItem)? getDurationMS;
final String Function(int number) itemsKeyword;
final void Function(E currentItem) onAddItemsTap;
Expand All @@ -90,6 +91,7 @@ class NamidaMiniPlayerBase<E> extends StatefulWidget {
final Widget Function(E item, double cp) imageBuilder;
final Widget Function(E item, double bcp) currentImageBuilder;
final MiniplayerTextData Function(E item) textBuilder;
final bool canShowBuffering;

const NamidaMiniPlayerBase({
super.key,
Expand All @@ -107,6 +109,7 @@ class NamidaMiniPlayerBase<E> extends StatefulWidget {
required this.imageBuilder,
required this.currentImageBuilder,
required this.textBuilder,
required this.canShowBuffering,
});

@override
Expand Down Expand Up @@ -194,8 +197,9 @@ class _NamidaMiniPlayerBaseState<E> extends State<NamidaMiniPlayerBase<E>> {
onReorder: (oldIndex, newIndex) => Player.inst.reorderTrack(oldIndex, newIndex),
padding: padding,
itemBuilder: (context, i) {
final childWK = widget.itemBuilder(context, i, currentIndex);
return FadeDismissible(
key: Key("Diss_$i"),
key: Key("Diss_${i}_${childWK.$2}"),
onDismissed: (direction) {
Player.inst.removeFromQueue(i);
MiniPlayerController.inst.invokeDoneReordering();
Expand All @@ -208,7 +212,7 @@ class _NamidaMiniPlayerBaseState<E> extends State<NamidaMiniPlayerBase<E>> {
MiniPlayerController.inst.invokeDoneReordering();
}
},
child: widget.itemBuilder(context, i, currentIndex),
child: childWK.$1,
);
},
);
Expand Down Expand Up @@ -280,6 +284,8 @@ class _NamidaMiniPlayerBaseState<E> extends State<NamidaMiniPlayerBase<E>> {
final panelFinal = panelH - (panelExtra * (1 - qcp));

final currentImage = widget.currentImageBuilder(currentItem, bcp);
final iconBoxSize = (velpy(a: 60.0, b: 80.0, c: rcp) - 8) + 8 * rcp - 8 * icp;
final iconSize = (velpy(a: 60.0 * 0.5, b: 80.0 * 0.5, c: rp) - 8) + 8 * cp * rcp;
return Stack(
children: [
/// MiniPlayer Body
Expand Down Expand Up @@ -570,8 +576,8 @@ class _NamidaMiniPlayerBaseState<E> extends State<NamidaMiniPlayerBase<E>> {
SizedBox(width: 7 * rcp),
SizedBox(
key: const Key("playpause"),
height: (velpy(a: 60.0, b: 80.0, c: rcp) - 8) + 8 * rcp - 8 * icp,
width: (velpy(a: 60.0, b: 80.0, c: rcp) - 8) + 8 * rcp - 8 * icp,
height: iconBoxSize,
width: iconBoxSize,
child: Center(
child: Obx(
() {
Expand Down Expand Up @@ -609,30 +615,46 @@ class _NamidaMiniPlayerBaseState<E> extends State<NamidaMiniPlayerBase<E>> {
),
],
),
child: IconButton(
highlightColor: Colors.transparent,
onPressed: () => Player.inst.togglePlayPause(),
icon: Padding(
padding: EdgeInsets.all(6.0 * cp * rcp),
child: Obx(
() => AnimatedSwitcher(
duration: const Duration(milliseconds: 200),
child: Player.inst.isPlaying
? Icon(
Broken.pause,
size: (velpy(a: 60.0 * 0.5, b: 80.0 * 0.5, c: rp) - 8) + 8 * cp * rcp,
key: const Key("pauseicon"),
color: Colors.white.withAlpha(180),
)
: Icon(
Broken.play,
size: (velpy(a: 60.0 * 0.5, b: 80.0 * 0.5, c: rp) - 8) + 8 * cp * rcp,
key: const Key("playicon"),
color: Colors.white.withAlpha(180),
),
child: Stack(
alignment: Alignment.center,
children: [
IconButton(
highlightColor: Colors.transparent,
onPressed: () => Player.inst.togglePlayPause(),
icon: Padding(
padding: EdgeInsets.all(6.0 * cp * rcp),
child: Obx(
() => AnimatedSwitcher(
duration: const Duration(milliseconds: 200),
child: Player.inst.isPlaying
? Icon(
Broken.pause,
size: iconSize,
key: const Key("pauseicon"),
color: Colors.white.withAlpha(180),
)
: Icon(
Broken.play,
size: iconSize,
key: const Key("playicon"),
color: Colors.white.withAlpha(180),
),
),
),
),
),
),
if (widget.canShowBuffering)
IgnorePointer(
child: Obx(
() => Player.inst.isBuffering || Player.inst.isLoading
? ThreeArchedCircle(
color: Colors.white.withAlpha(120),
size: iconSize * 1.4,
)
: const SizedBox(),
),
),
],
),
),
),
Expand Down
21 changes: 13 additions & 8 deletions lib/ui/pages/main_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,14 @@ class MainPage extends StatelessWidget {
preferredSize: const Size(0, 56.0),
child: Obx(
() {
final isReallyHidden = animation.value > 1; // queue
return isReallyHidden || !settings.enableMiniplayerParallaxEffect.value
return !settings.enableMiniplayerParallaxEffect.value
? appbar(1.0)
: AnimatedBuilder(
animation: animation,
builder: (context, child) => appbar((1 - animation.value * 0.3)),
builder: (context, child) {
if (animation.value > 1) return const SizedBox(); // expanded/queue
return appbar((1 - animation.value * 0.3));
},
);
},
),
Expand All @@ -93,16 +95,18 @@ class MainPage extends StatelessWidget {
alignment: Alignment.bottomCenter,
children: [
Obx(() {
final isReallyHidden = animation.value > 1; // queue
return isReallyHidden || !settings.enableMiniplayerParallaxEffect.value
return !settings.enableMiniplayerParallaxEffect.value
? main
: AnimatedBuilder(
animation: animation,
child: main,
builder: (context, child) {
return Transform.scale(
scale: 1 - (animation.value * 0.05),
child: child,
return Visibility.maintain(
visible: animation.value < 1, // not expanded/queue
child: Transform.scale(
scale: 1 - (animation.value * 0.05),
child: child,
),
);
},
);
Expand Down Expand Up @@ -215,6 +219,7 @@ class MainPage extends StatelessWidget {
),
),
builder: (context, child) {
if (animation.value > 1) return const SizedBox(); // expanded/queue
return Transform.translate(
offset: Offset(0, (kBottomNavigationBarHeight * animation.value).withMinimum(0)),
child: child,
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/widgets/custom_widgets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1531,8 +1531,8 @@ class NamidaPartyContainer extends StatelessWidget {
final finalScale = WaveformController.inst.getCurrentAnimatingScale(Player.inst.nowPlayingPosition);
return AnimatedSizedBox(
duration: const Duration(milliseconds: 400),
height: height,
width: width,
height: height ?? context.height,
width: width ?? context.width,
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
Expand Down
Loading

0 comments on commit 1433488

Please sign in to comment.