Skip to content

Commit

Permalink
chore: do the unfocus keyboard in miniplayer states switching
Browse files Browse the repository at this point in the history
  • Loading branch information
MSOB7YY committed Dec 31, 2024
1 parent 062378b commit 725dc5b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
7 changes: 0 additions & 7 deletions lib/controller/video_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import 'package:namida/controller/ffmpeg_controller.dart';
import 'package:namida/controller/indexer_controller.dart';
import 'package:namida/controller/navigator_controller.dart';
import 'package:namida/controller/player_controller.dart';
import 'package:namida/controller/scroll_search_controller.dart';
import 'package:namida/controller/settings_controller.dart';
import 'package:namida/controller/thumbnail_manager.dart';
import 'package:namida/core/constants.dart';
Expand Down Expand Up @@ -132,23 +131,17 @@ class VideoController {

final videoZoomAdditionalScale = 0.0.obs;

bool _didUnfocusKeyboard = false;
void updateShouldShowControls(double animationValue) {
final ytmini = videoControlsKey.currentState;
if (ytmini == null) return;
final isExpanded = animationValue >= 0.95;
if (isExpanded) {
// YoutubeMiniplayerUiController.inst.startDimTimer(); // bad experience honestly
if (!_didUnfocusKeyboard) {
ScrollSearchController.inst.unfocusKeyboard();
_didUnfocusKeyboard = true;
}
ytmini.isEndCardsVisible.value = true;
} else {
// YoutubeMiniplayerUiController.inst.cancelDimTimer();
ytmini.setControlsVisibily(false);
ytmini.isEndCardsVisible.value = false;
_didUnfocusKeyboard = false;
}
}

Expand Down
12 changes: 12 additions & 0 deletions lib/packages/mp.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:async';

import 'package:flutter/material.dart';

import 'package:namida/controller/scroll_search_controller.dart';
import 'package:namida/controller/wakelock_controller.dart';
import 'package:namida/core/extensions.dart';
import 'package:namida/core/utils.dart';
Expand Down Expand Up @@ -53,6 +54,8 @@ class NamidaYTMiniplayer extends StatefulWidget {
class NamidaYTMiniplayerState extends State<NamidaYTMiniplayer> with SingleTickerProviderStateMixin {
late final AnimationController controller;

bool _didUnfocusKeyboard = false;

@override
void initState() {
super.initState();
Expand Down Expand Up @@ -157,6 +160,15 @@ class NamidaYTMiniplayerState extends State<NamidaYTMiniplayer> with SingleTicke
_updateHeight(toExpanded ? maxHeight : widget.minHeight, duration: dur ?? widget.duration);
_wasExpanded = toExpanded;
WakelockController.inst.updateMiniplayerStatus(toExpanded);

if (toExpanded) {
if (!_didUnfocusKeyboard) {
ScrollSearchController.inst.unfocusKeyboard();
_didUnfocusKeyboard = true;
}
} else {
_didUnfocusKeyboard = false;
}
}

void onVerticalDragUpdate(double dy) {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: namida
description: A Beautiful and Feature-rich Music Player, With YouTube & Video Support Built in Flutter
publish_to: "none"
version: 4.8.5-beta+241229235
version: 4.8.51-beta+241231170

environment:
sdk: ">=3.4.0 <4.0.0"
Expand Down

0 comments on commit 725dc5b

Please sign in to comment.