A new interim state screen

This commit is contained in:
Ankit Mahato
2023-03-10 14:19:39 +05:30
parent 416572bdee
commit 644c792caa
4 changed files with 43 additions and 4 deletions

BIN
assets/sending.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 181 KiB

View File

@ -25,12 +25,16 @@ class _ResponsePaneState extends ConsumerState<ResponsePane> {
@override
Widget build(BuildContext context) {
final activeId = ref.watch(activeIdStateProvider);
final sentRequestId = ref.watch(sentRequestIdStateProvider);
final collection = ref.read(collectionStateNotifierProvider);
final idIdx = collection.indexWhere((m) => m.id == activeId);
final status = ref.watch(collectionStateNotifierProvider
.select((value) => (value[idIdx].responseStatus,
value[idIdx].message,
value[idIdx].responseModel)));
if(sentRequestId != null && sentRequestId == activeId){
return const SendingWidget();
}
if (status.$0 == null) {
return const NotSentWidget();
}
@ -59,6 +63,7 @@ class NotSentWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
final color = Theme.of(context).colorScheme.secondary;
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
@ -66,14 +71,41 @@ class NotSentWidget extends StatelessWidget {
Icon(
Icons.north_east_rounded,
size: 40,
color: colorErrorMsg,
color: color,
),
Text(
'Not Sent',
style: Theme.of(context)
.textTheme
.titleMedium
?.copyWith(color: colorErrorMsg),
?.copyWith(color: color),
),
],
),
);
}
}
class SendingWidget extends StatelessWidget {
const SendingWidget({super.key});
@override
Widget build(BuildContext context) {
final color = Theme.of(context).colorScheme.secondary;
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ColorFiltered(
colorFilter: ColorFilter.mode(
//Color.fromARGB(123, 71, 84, 179),
color.withOpacity(0.7),
BlendMode.dstIn,
),
child: const Image(
image: sendingIndicator,
width: 300,
),
),
],
),
@ -88,6 +120,7 @@ class ErrorMessage extends StatelessWidget {
@override
Widget build(BuildContext context) {
final color = Theme.of(context).colorScheme.secondary;
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
@ -95,14 +128,14 @@ class ErrorMessage extends StatelessWidget {
Icon(
Icons.warning_rounded,
size: 40,
color: colorErrorMsg,
color: color,
),
Text(
message ?? 'And error occurred.',
style: Theme.of(context)
.textTheme
.titleMedium
?.copyWith(color: colorErrorMsg),
?.copyWith(color: color),
),
],
),

View File

@ -1,3 +1,5 @@
import 'package:flutter/material.dart';
enum HTTPVerb { get, head, post, put, patch, delete }
enum ContentType { json, text }
@ -6,6 +8,8 @@ const DEFAULT_METHOD = HTTPVerb.get;
const DEFAULT_BODY_CONTENT_TYPE = ContentType.json;
const JSON_MIMETYPE = 'application/json';
const sendingIndicator = AssetImage("assets/sending.gif");
const RESPONSE_CODE_REASONS = {
// 100s
100: 'Continue',

View File

@ -26,3 +26,5 @@ dev_dependencies:
flutter:
uses-material-design: true
assets:
- assets/sending.gif