update
This commit is contained in:
parent
47a2d34933
commit
4586256032
9 changed files with 246 additions and 154 deletions
|
|
@ -1,3 +1,5 @@
|
|||
import 'dart:developer';
|
||||
|
||||
import 'package:gap/gap.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:internet_connection_checker/internet_connection_checker.dart';
|
||||
|
|
@ -25,7 +27,7 @@ class _AddGenericsPageState extends State<AddGenericsPage> {
|
|||
final _refGenericNames = RefGenericNames();
|
||||
final _nameController = TextEditingController();
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
// bool _isVisible = false;
|
||||
|
||||
bool _isLoading = false;
|
||||
|
||||
late List _categoryList = [];
|
||||
|
|
@ -33,12 +35,11 @@ class _AddGenericsPageState extends State<AddGenericsPage> {
|
|||
late String _categoryUUID = '';
|
||||
|
||||
void _getList() async {
|
||||
// if (await InternetConnectionChecker.instance.hasConnection) {
|
||||
_categoryList = await _refCategories.getList();
|
||||
|
||||
if (_categoryList.isEmpty) {
|
||||
if (mounted) {
|
||||
showNotification(context, 'Error: Empty', false);
|
||||
showNotification(context, 'Error: No Categories Found', false);
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (mounted) {
|
||||
|
|
@ -46,23 +47,14 @@ class _AddGenericsPageState extends State<AddGenericsPage> {
|
|||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
setState(() => {});
|
||||
}
|
||||
// } else {
|
||||
// if (mounted) {
|
||||
// showNotification(context, 'Error: No Internet Connection', false);
|
||||
|
||||
// WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
// if (mounted) {
|
||||
// context.push('/main');
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
void autoRun() async {
|
||||
if (await InternetConnectionChecker.instance.hasConnection) {
|
||||
_categoryList = await _refCategories.getList();
|
||||
_getList();
|
||||
} else {
|
||||
if (mounted) {
|
||||
showNotification(context, 'Error: No Internet Connection', false);
|
||||
|
|
@ -114,7 +106,7 @@ class _AddGenericsPageState extends State<AddGenericsPage> {
|
|||
|
||||
@override
|
||||
void initState() {
|
||||
// autoRun();
|
||||
autoRun();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
|
|
@ -148,19 +140,39 @@ class _AddGenericsPageState extends State<AddGenericsPage> {
|
|||
children: [
|
||||
InputWidget(label: 'Name', controller: _nameController),
|
||||
const Gap(16),
|
||||
GestureDetector(
|
||||
onTap: _getList,
|
||||
child: DropDownWidget(
|
||||
label: 'Category',
|
||||
list: _categoryList,
|
||||
listTitle: 'category_name',
|
||||
onChanged: _updateCategory),
|
||||
),
|
||||
const Gap(32),
|
||||
if (_isLoading)
|
||||
Center(child: CircularProgressIndicator(color: Colors.white))
|
||||
if (_categoryList.isEmpty)
|
||||
Column(
|
||||
children: [
|
||||
const Gap(8),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
spacing: 16,
|
||||
children: [
|
||||
CircularProgressIndicator(color: Colors.white),
|
||||
TextWidget(
|
||||
text: 'Fetching Categories',
|
||||
size: 16,
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
else
|
||||
ButtonWidget(text: 'Add', onPressed: saveGeneric)
|
||||
Column(
|
||||
children: [
|
||||
DropDownWidget(
|
||||
label: 'Category',
|
||||
list: _categoryList,
|
||||
listTitle: 'category_name',
|
||||
onChanged: _updateCategory),
|
||||
const Gap(32),
|
||||
if (_isLoading)
|
||||
Center(child: CircularProgressIndicator(color: Colors.white))
|
||||
else
|
||||
ButtonWidget(text: 'Add', onPressed: saveGeneric)
|
||||
],
|
||||
),
|
||||
],
|
||||
)),
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue