mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00
chore: show loading indicator for alternative sourced track
This commit is contained in:
parent
8ff90bafd7
commit
b24dcd2951
@ -70,6 +70,7 @@ class SiblingTracksSheet extends HookConsumerWidget {
|
|||||||
final preferences = ref.watch(userPreferencesProvider);
|
final preferences = ref.watch(userPreferencesProvider);
|
||||||
final youtubeEngine = ref.watch(youtubeEngineProvider);
|
final youtubeEngine = ref.watch(youtubeEngineProvider);
|
||||||
|
|
||||||
|
final isLoading = useState(false);
|
||||||
final isSearching = useState(false);
|
final isSearching = useState(false);
|
||||||
final searchMode = useState(preferences.searchMode);
|
final searchMode = useState(preferences.searchMode);
|
||||||
final activeTrackSources = ref.watch(activeTrackSourcesProvider);
|
final activeTrackSources = ref.watch(activeTrackSourcesProvider);
|
||||||
@ -195,12 +196,14 @@ class SiblingTracksSheet extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
enabled: !isFetchingActiveTrack,
|
enabled: !isFetchingActiveTrack && !isLoading.value,
|
||||||
selected: !isFetchingActiveTrack &&
|
selected: !isFetchingActiveTrack &&
|
||||||
sourceInfo.id == activeTrackSource?.info.id,
|
sourceInfo.id == activeTrackSource?.info.id,
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
if (!isFetchingActiveTrack &&
|
if (!isFetchingActiveTrack &&
|
||||||
sourceInfo.id != activeTrackSource?.info.id) {
|
sourceInfo.id != activeTrackSource?.info.id) {
|
||||||
|
try {
|
||||||
|
isLoading.value = true;
|
||||||
await activeTrackNotifier?.swapWithSibling(sourceInfo);
|
await activeTrackNotifier?.swapWithSibling(sourceInfo);
|
||||||
await ref.read(audioPlayerProvider.notifier).swapActiveSource();
|
await ref.read(audioPlayerProvider.notifier).swapActiveSource();
|
||||||
|
|
||||||
@ -211,11 +214,22 @@ class SiblingTracksSheet extends HookConsumerWidget {
|
|||||||
closeDrawer(context);
|
closeDrawer(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
if (context.mounted) {
|
||||||
|
isLoading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
[activeTrackSource, activeTrackNotifier, siblings],
|
[
|
||||||
|
activeTrackSource,
|
||||||
|
activeTrackNotifier,
|
||||||
|
siblings,
|
||||||
|
isFetchingActiveTrack,
|
||||||
|
isLoading.value,
|
||||||
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
final scale = context.theme.scaling;
|
final scale = context.theme.scaling;
|
||||||
@ -293,6 +307,15 @@ class SiblingTracksSheet extends HookConsumerWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
AnimatedSwitcher(
|
||||||
|
duration: const Duration(milliseconds: 300),
|
||||||
|
child: isLoading.value
|
||||||
|
? const SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
child: LinearProgressIndicator(),
|
||||||
|
)
|
||||||
|
: const SizedBox.shrink(),
|
||||||
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: AnimatedSwitcher(
|
child: AnimatedSwitcher(
|
||||||
duration: const Duration(milliseconds: 300),
|
duration: const Duration(milliseconds: 300),
|
||||||
@ -307,7 +330,9 @@ class SiblingTracksSheet extends HookConsumerWidget {
|
|||||||
itemCount: siblings.length,
|
itemCount: siblings.length,
|
||||||
separatorBuilder: (context, index) => const Gap(8),
|
separatorBuilder: (context, index) => const Gap(8),
|
||||||
itemBuilder: (context, index) => itemBuilder(
|
itemBuilder: (context, index) => itemBuilder(
|
||||||
siblings[index], activeTrackSource!.source),
|
siblings[index],
|
||||||
|
activeTrackSource!.source,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
true => FutureBuilder(
|
true => FutureBuilder(
|
||||||
future: searchRequest,
|
future: searchRequest,
|
||||||
|
Loading…
Reference in New Issue
Block a user