fix clear data and edit mode problems
This commit is contained in:
parent
a50acbd0d8
commit
d1d4ee0144
|
@ -38,7 +38,9 @@ class _MediaUploadButtonUtilState extends State<MediaUploadButtonUtil> {
|
||||||
padding: const EdgeInsetsDirectional.fromSTEB(24.0, 0.0, 24.0, 0.0),
|
padding: const EdgeInsetsDirectional.fromSTEB(24.0, 0.0, 24.0, 0.0),
|
||||||
child: Builder(
|
child: Builder(
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
if ((widget.uploadedFiles != null)) {
|
if (widget.uploadedFiles != null &&
|
||||||
|
widget.uploadedFiles!.bytes!.isNotEmpty) {
|
||||||
|
{
|
||||||
return InkWell(
|
return InkWell(
|
||||||
splashColor: Colors.transparent,
|
splashColor: Colors.transparent,
|
||||||
focusColor: Colors.transparent,
|
focusColor: Colors.transparent,
|
||||||
|
@ -62,6 +64,7 @@ class _MediaUploadButtonUtilState extends State<MediaUploadButtonUtil> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return Stack(
|
return Stack(
|
||||||
children: [
|
children: [
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import 'dart:developer';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
|
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
|
||||||
|
@ -8,11 +10,13 @@ class TabViewUtil extends StatelessWidget {
|
||||||
String labelTab1;
|
String labelTab1;
|
||||||
String labelTab2;
|
String labelTab2;
|
||||||
final TabController controller;
|
final TabController controller;
|
||||||
|
final Function(bool) onEditingChanged;
|
||||||
Widget widget1;
|
Widget widget1;
|
||||||
Widget widget2;
|
Widget widget2;
|
||||||
|
|
||||||
TabViewUtil({
|
TabViewUtil({
|
||||||
super.key,
|
super.key,
|
||||||
|
required this.onEditingChanged,
|
||||||
required this.context,
|
required this.context,
|
||||||
required this.model,
|
required this.model,
|
||||||
required this.labelTab1,
|
required this.labelTab1,
|
||||||
|
@ -53,6 +57,8 @@ class TabViewUtil extends StatelessWidget {
|
||||||
],
|
],
|
||||||
controller: controller,
|
controller: controller,
|
||||||
onTap: (i) async {
|
onTap: (i) async {
|
||||||
|
if (i == 1) onEditingChanged(false);
|
||||||
|
log('TabBar onTap: $i');
|
||||||
[() async {}, () async {}][i]();
|
[() async {}, () async {}][i]();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
|
@ -33,6 +33,7 @@ import 'package:hub/pages/pets_page/pets_history_screen.dart';
|
||||||
import 'package:hub/pages/pets_page/pets_page_model.dart';
|
import 'package:hub/pages/pets_page/pets_page_model.dart';
|
||||||
import 'package:hub/shared/utils/dialog_util.dart';
|
import 'package:hub/shared/utils/dialog_util.dart';
|
||||||
import 'package:hub/shared/utils/validator_util.dart';
|
import 'package:hub/shared/utils/validator_util.dart';
|
||||||
|
import 'package:material_symbols_icons/symbols.dart';
|
||||||
import 'package:sqflite/sqflite.dart';
|
import 'package:sqflite/sqflite.dart';
|
||||||
import '/custom_code/actions/index.dart' as actions;
|
import '/custom_code/actions/index.dart' as actions;
|
||||||
|
|
||||||
|
@ -128,6 +129,21 @@ class _PetsPageWidgetState extends State<PetsPageWidget>
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _handleEditingChanged(bool editing) {
|
||||||
|
setState(() {
|
||||||
|
isEditing = editing;
|
||||||
|
_model.uploadedLocalFile = null;
|
||||||
|
_model.textControllerName.text = '';
|
||||||
|
_model.textControllerSpecies.text = '';
|
||||||
|
_model.textControllerRace.text = '';
|
||||||
|
_model.textControllerColor.text = '';
|
||||||
|
_model.textControllerData.text = '';
|
||||||
|
_model.textControllerObservation.text = '';
|
||||||
|
_model.dropDownValueController1 = FormFieldController<String>('');
|
||||||
|
_model.dropDownValueController2 = FormFieldController<String>('');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
log('Chamou o build');
|
log('Chamou o build');
|
||||||
|
@ -146,7 +162,10 @@ class _PetsPageWidgetState extends State<PetsPageWidget>
|
||||||
return TabViewUtil(
|
return TabViewUtil(
|
||||||
context: context,
|
context: context,
|
||||||
model: _model,
|
model: _model,
|
||||||
labelTab1: FFLocalizations.of(context)
|
labelTab1: isEditing
|
||||||
|
? FFLocalizations.of(context)
|
||||||
|
.getVariableText(ptText: 'Editar', enText: 'Edit')
|
||||||
|
: FFLocalizations.of(context)
|
||||||
.getVariableText(ptText: 'Cadastrar', enText: 'Register'),
|
.getVariableText(ptText: 'Cadastrar', enText: 'Register'),
|
||||||
labelTab2: FFLocalizations.of(context)
|
labelTab2: FFLocalizations.of(context)
|
||||||
.getVariableText(ptText: 'Consultar', enText: 'History'),
|
.getVariableText(ptText: 'Consultar', enText: 'History'),
|
||||||
|
@ -154,6 +173,7 @@ class _PetsPageWidgetState extends State<PetsPageWidget>
|
||||||
widget1:
|
widget1:
|
||||||
isEditing ? _buildEditForm(context) : _buildRegisterForm(context),
|
isEditing ? _buildEditForm(context) : _buildRegisterForm(context),
|
||||||
widget2: PetsHistoryScreen(),
|
widget2: PetsHistoryScreen(),
|
||||||
|
onEditingChanged: _handleEditingChanged,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,6 +213,7 @@ class _PetsPageWidgetState extends State<PetsPageWidget>
|
||||||
child: MediaUploadButtonUtil(
|
child: MediaUploadButtonUtil(
|
||||||
onUploadComplete: _handleUploadComplete,
|
onUploadComplete: _handleUploadComplete,
|
||||||
isUploading: _model.isDataUploading,
|
isUploading: _model.isDataUploading,
|
||||||
|
uploadedFiles: _model.uploadedLocalFile,
|
||||||
labelText: FFLocalizations.of(context).getVariableText(
|
labelText: FFLocalizations.of(context).getVariableText(
|
||||||
ptText: 'Clique para adicionar a foto de seu Pet',
|
ptText: 'Clique para adicionar a foto de seu Pet',
|
||||||
enText: 'Click to add your Pet\'s photo'),
|
enText: 'Click to add your Pet\'s photo'),
|
||||||
|
@ -222,7 +243,7 @@ class _PetsPageWidgetState extends State<PetsPageWidget>
|
||||||
ptText: 'Espécie', enText: 'Species'),
|
ptText: 'Espécie', enText: 'Species'),
|
||||||
hintText: FFLocalizations.of(context).getVariableText(
|
hintText: FFLocalizations.of(context).getVariableText(
|
||||||
ptText: 'Espécie', enText: 'Species'),
|
ptText: 'Espécie', enText: 'Species'),
|
||||||
suffixIcon: Icons.pest_control,
|
suffixIcon: Symbols.raven_sharp,
|
||||||
haveMaxLength: true,
|
haveMaxLength: true,
|
||||||
maxLength: 80,
|
maxLength: 80,
|
||||||
),
|
),
|
||||||
|
@ -238,7 +259,7 @@ class _PetsPageWidgetState extends State<PetsPageWidget>
|
||||||
.getVariableText(ptText: 'Raça', enText: 'Race'),
|
.getVariableText(ptText: 'Raça', enText: 'Race'),
|
||||||
hintText: FFLocalizations.of(context)
|
hintText: FFLocalizations.of(context)
|
||||||
.getVariableText(ptText: 'Raça', enText: 'Race'),
|
.getVariableText(ptText: 'Raça', enText: 'Race'),
|
||||||
suffixIcon: Icons.pets,
|
suffixIcon: Icons.pets_outlined,
|
||||||
haveMaxLength: true,
|
haveMaxLength: true,
|
||||||
maxLength: 80,
|
maxLength: 80,
|
||||||
),
|
),
|
||||||
|
@ -254,7 +275,7 @@ class _PetsPageWidgetState extends State<PetsPageWidget>
|
||||||
.getVariableText(ptText: 'Cor', enText: 'Color'),
|
.getVariableText(ptText: 'Cor', enText: 'Color'),
|
||||||
hintText: FFLocalizations.of(context)
|
hintText: FFLocalizations.of(context)
|
||||||
.getVariableText(ptText: 'Cor', enText: 'Color'),
|
.getVariableText(ptText: 'Cor', enText: 'Color'),
|
||||||
suffixIcon: Icons.invert_colors,
|
suffixIcon: Icons.invert_colors_on_outlined,
|
||||||
haveMaxLength: true,
|
haveMaxLength: true,
|
||||||
maxLength: 80,
|
maxLength: 80,
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in New Issue