studio error handlign + bug fixes
This commit is contained in:
parent
91d8469d19
commit
56f8b38693
|
|
@ -2,6 +2,7 @@ import 'dart:async';
|
|||
|
||||
import 'package:didvan/config/design_config.dart';
|
||||
import 'package:didvan/constants/app_icons.dart';
|
||||
import 'package:didvan/models/enums.dart';
|
||||
import 'package:didvan/models/requests/studio.dart';
|
||||
import 'package:didvan/models/view/action_sheet_data.dart';
|
||||
import 'package:didvan/routes/routes.dart';
|
||||
|
|
@ -18,6 +19,7 @@ import 'package:didvan/views/widgets/didvan/divider.dart';
|
|||
import 'package:didvan/views/widgets/didvan/icon_button.dart';
|
||||
import 'package:didvan/views/widgets/didvan/radial_button.dart';
|
||||
import 'package:didvan/views/widgets/item_title.dart';
|
||||
import 'package:didvan/views/widgets/state_handlers/empty_result.dart';
|
||||
import 'package:didvan/views/widgets/state_handlers/sliver_state_handler.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
|
@ -41,7 +43,8 @@ class _StudioState extends State<Studio> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CustomScrollView(
|
||||
return Consumer<StudioState>(
|
||||
builder: (context, state, child) => CustomScrollView(
|
||||
slivers: [
|
||||
SliverToBoxAdapter(
|
||||
child: Row(
|
||||
|
|
@ -54,10 +57,7 @@ class _StudioState extends State<Studio> {
|
|||
icon: DidvanIcons.bookmark_regular,
|
||||
onPressed: () => Navigator.of(context).pushNamed(
|
||||
Routes.filteredBookmarks,
|
||||
arguments: {
|
||||
'type': context.read<StudioState>().type,
|
||||
'onDeleted': (_) {}
|
||||
},
|
||||
arguments: {'type': state.type, 'onDeleted': (_) {}},
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
@ -67,6 +67,7 @@ class _StudioState extends State<Studio> {
|
|||
const SliverToBoxAdapter(
|
||||
child: StudioTabBar(),
|
||||
),
|
||||
if (state.appState != AppState.failed)
|
||||
SliverToBoxAdapter(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
|
|
@ -77,15 +78,15 @@ class _StudioState extends State<Studio> {
|
|||
),
|
||||
),
|
||||
),
|
||||
if (state.appState != AppState.failed)
|
||||
SliverToBoxAdapter(
|
||||
child: Consumer<StudioState>(
|
||||
builder: (context, state, child) => AnimatedVisibility(
|
||||
child: AnimatedVisibility(
|
||||
isVisible: !state.searching,
|
||||
duration: DesignConfig.lowAnimationDuration,
|
||||
child: const StudioSlider(),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (state.appState != AppState.failed && state.studios.isNotEmpty)
|
||||
const SliverPadding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16),
|
||||
sliver: SliverToBoxAdapter(
|
||||
|
|
@ -94,19 +95,18 @@ class _StudioState extends State<Studio> {
|
|||
),
|
||||
),
|
||||
),
|
||||
if (state.appState != AppState.failed && state.studios.isNotEmpty)
|
||||
SliverPadding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
sliver: SliverToBoxAdapter(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Consumer<StudioState>(
|
||||
builder: (context, state, child) => AnimatedVisibility(
|
||||
AnimatedVisibility(
|
||||
isVisible: !state.searching,
|
||||
duration: DesignConfig.lowAnimationDuration,
|
||||
child: ItemTitle(title: state.orderString),
|
||||
),
|
||||
),
|
||||
DidvanIconButton(
|
||||
gestureSize: 36,
|
||||
icon: DidvanIcons.sort_regular,
|
||||
|
|
@ -116,14 +116,18 @@ class _StudioState extends State<Studio> {
|
|||
),
|
||||
),
|
||||
),
|
||||
Consumer<StudioState>(
|
||||
builder: (context, state, child) => SliverStateHandler<StudioState>(
|
||||
SliverStateHandler<StudioState>(
|
||||
state: state,
|
||||
itemPadding: const EdgeInsets.only(
|
||||
bottom: 8,
|
||||
left: 16,
|
||||
right: 16,
|
||||
),
|
||||
emptyState: EmptyResult(
|
||||
onNewSearch: () => _focusNode.requestFocus(),
|
||||
),
|
||||
centerEmptyState: false,
|
||||
enableEmptyState: state.studios.isEmpty,
|
||||
placeholder: state.videosSelected
|
||||
? VideoOverview.placeHolder
|
||||
: PodcastOverview.placeholder,
|
||||
|
|
@ -154,8 +158,8 @@ class _StudioState extends State<Studio> {
|
|||
childCount: state.studios.length,
|
||||
onRetry: () => state.getStudios(page: 1),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -86,7 +86,13 @@ class _StudioDetailsState extends State<StudioDetails> {
|
|||
return Consumer<StudioDetailsState>(
|
||||
builder: (context, state, child) => StateHandler<StudioDetailsState>(
|
||||
state: state,
|
||||
onRetry: () => state.getStudioDetails(state.studio.id),
|
||||
onRetry: () {
|
||||
try {
|
||||
state.getStudioDetails(state.studio.id);
|
||||
} catch (e) {
|
||||
state.getStudioDetails(widget.pageData['id']);
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
|
|
|
|||
|
|
@ -125,6 +125,7 @@ class _SearchFieldState extends State<SearchField> {
|
|||
|
||||
@override
|
||||
void dispose() {
|
||||
widget.focusNode.removeListener(() {});
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,10 +118,21 @@ class _PlayerNavBar extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
alignment: Alignment.topCenter,
|
||||
child: !_enablePlayerController(state)
|
||||
? const SizedBox()
|
||||
: MediaService.currentPodcast == null
|
||||
? SizedBox(
|
||||
child: Builder(builder: (context) {
|
||||
if (!_enablePlayerController(state)) return const SizedBox();
|
||||
if (state.appState == AppState.failed) {
|
||||
Future.delayed(const Duration(seconds: 2), () {
|
||||
MediaService.resetAudioPlayer();
|
||||
});
|
||||
return DidvanText(
|
||||
'اتصال اینترنت برقرار نمیباشد',
|
||||
color: DesignConfig.isDark
|
||||
? Theme.of(context).colorScheme.title
|
||||
: Theme.of(context).colorScheme.secondCTA,
|
||||
);
|
||||
}
|
||||
if (MediaService.currentPodcast == null) {
|
||||
return SizedBox(
|
||||
height: 32,
|
||||
child: Center(
|
||||
child: SpinKitThreeBounce(
|
||||
|
|
@ -131,8 +142,9 @@ class _PlayerNavBar extends StatelessWidget {
|
|||
: Theme.of(context).colorScheme.secondCTA,
|
||||
),
|
||||
),
|
||||
)
|
||||
: SizedBox(
|
||||
);
|
||||
}
|
||||
return SizedBox(
|
||||
height: 56,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
|
|
@ -165,9 +177,7 @@ class _PlayerNavBar extends StatelessWidget {
|
|||
MediaService.currentPodcast!.title,
|
||||
color: DesignConfig.isDark
|
||||
? null
|
||||
: Theme.of(context)
|
||||
.colorScheme
|
||||
.secondCTA,
|
||||
: Theme.of(context).colorScheme.secondCTA,
|
||||
),
|
||||
AudioSlider(
|
||||
disableThumb: true,
|
||||
|
|
@ -177,8 +187,7 @@ class _PlayerNavBar extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
StreamBuilder<PlayerState>(
|
||||
stream:
|
||||
MediaService.audioPlayer.playerStateStream,
|
||||
stream: MediaService.audioPlayer.playerStateStream,
|
||||
builder: (context, snapshot) {
|
||||
final playerState = MediaService
|
||||
.audioPlayer.playerState.processingState;
|
||||
|
|
@ -196,12 +205,8 @@ class _PlayerNavBar extends StatelessWidget {
|
|||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
color: DesignConfig.isDark
|
||||
? Theme.of(context)
|
||||
.colorScheme
|
||||
.title
|
||||
: Theme.of(context)
|
||||
.colorScheme
|
||||
.secondCTA,
|
||||
? Theme.of(context).colorScheme.title
|
||||
: Theme.of(context).colorScheme.secondCTA,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
@ -210,8 +215,7 @@ class _PlayerNavBar extends StatelessWidget {
|
|||
},
|
||||
),
|
||||
if (state.appState != AppState.busy &&
|
||||
MediaService.audioPlayer.playerState
|
||||
.processingState !=
|
||||
MediaService.audioPlayer.playerState.processingState !=
|
||||
ProcessingState.loading)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
|
|
@ -235,8 +239,7 @@ class _PlayerNavBar extends StatelessWidget {
|
|||
);
|
||||
}
|
||||
MediaService.handleAudioPlayback(
|
||||
audioSource:
|
||||
MediaService.currentPodcast!.media,
|
||||
audioSource: MediaService.currentPodcast!.media,
|
||||
id: MediaService.currentPodcast!.id,
|
||||
isVoiceMessage: false,
|
||||
);
|
||||
|
|
@ -245,7 +248,8 @@ class _PlayerNavBar extends StatelessWidget {
|
|||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
|||
Loading…
Reference in New Issue