Skip to content

Commit

Permalink
[*] improve ui
Browse files Browse the repository at this point in the history
  • Loading branch information
heng30 committed May 31, 2024
1 parent b7395ff commit 257582a
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 15 deletions.
10 changes: 1 addition & 9 deletions lib/models/backup_recover_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ class BackupREcoverController extends GetxController {
Get.defaultDialog(
title: "提 示".tr,
middleText: '${"恢复成功,请重启程序".tr}?',
barrierDismissible: false,
confirm: ElevatedButton(
onPressed: () async {
Get.closeAllSnackbars();
Expand All @@ -211,15 +212,6 @@ class BackupREcoverController extends GetxController {
),
),
),
cancel: ElevatedButton(
onPressed: () => Get.back(),
child: Obx(
() => Text(
"取消".tr,
style: TextStyle(color: CTheme.inversePrimary),
),
),
),
);
}
}
2 changes: 2 additions & 0 deletions lib/models/lyric_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class SongLyricController extends GetxController {

String? downloadDir;

bool isInitShowAdjustLyricSpeedOverlay = false;

SongLyricController() {
if (!kReleaseMode) {
fakeLyricList();
Expand Down
12 changes: 11 additions & 1 deletion lib/pages/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:flutter_slidable/flutter_slidable.dart';
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';

import '../theme/theme.dart';
import '../widgets/nodata.dart';
Expand All @@ -26,11 +27,19 @@ class _HomePageState extends State<HomePage> {
final playerTileController = Get.find<PlayerTileController>();
final songLyricController = Get.find<SongLyricController>();

final ItemScrollController _itemScrollController = ItemScrollController();

void go2song(int index) async {
songLyricController.updateController();
await Get.toNamed("/song", arguments: {"currentSongIndex": index});
playerTileController.playingSong = playlistController.playingSong();
playlistController.updateSelectedSong();

_itemScrollController.scrollTo(
index: playlistController.currentSongIndex!,
duration: CTheme.animationDuration,
curve: Curves.easeInOutCubic,
);
}

bool closeOnConfirmed() {
Expand Down Expand Up @@ -91,7 +100,8 @@ class _HomePageState extends State<HomePage> {
return Obx(
() => Container(
color: CTheme.background,
child: ListView.builder(
child: ScrollablePositionedList.builder(
itemScrollController: _itemScrollController,
itemCount: playlistController.playlist.length,
itemBuilder: (count, index) {
final song = playlistController.playlist[index];
Expand Down
9 changes: 4 additions & 5 deletions lib/pages/song.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class _SongPageState extends State<SongPage> {
final currentSongIndex = Get.arguments["currentSongIndex"];

final isShowAdjustLyricSpeedOverlay = false.obs;
bool isInitShowAdjustLyricSpeedOverlay = false;

@override
void initState() {
Expand Down Expand Up @@ -516,10 +515,10 @@ class _SongPageState extends State<SongPage> {
isShowAdjustLyricSpeedOverlay.value =
!isShowAdjustLyricSpeedOverlay.value;

// print(isShowAdjustLyricSpeedOverlay);

if (!isInitShowAdjustLyricSpeedOverlay) {
isInitShowAdjustLyricSpeedOverlay = true;
if (!songLyricController
.isInitShowAdjustLyricSpeedOverlay) {
songLyricController.isInitShowAdjustLyricSpeedOverlay =
true;
showAdjustLyricSpeedOverlay(
context,
playlistController
Expand Down
2 changes: 2 additions & 0 deletions lib/theme/theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ class CTheme {
static const double padding = 4.0;
static const double margin = 4.0;
static const double iconSize = 24.0;

static const Duration animationDuration = Durations.long4;
}

class CIcons {
Expand Down
8 changes: 8 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.27.7"
scrollable_positioned_list:
dependency: "direct main"
description:
name: scrollable_positioned_list
sha256: "1b54d5f1329a1e263269abc9e2543d90806131aa14fe7c6062a8054d57249287"
url: "https://pub.dev"
source: hosted
version: "0.3.8"
sky_engine:
dependency: transitive
description: flutter
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ dependencies:
percent_indicator: ^4.0.1
package_info_plus: ^8.0.0
permission_handler: ^11.3.1
scrollable_positioned_list: ^0.3.8

# this automatically add from the cmd: `flutter_rust_bridge_codegen integrate`
rust_lib_musicbox:
Expand Down

0 comments on commit 257582a

Please sign in to comment.