Fix: Tirado alguns códigos não utilizados
This commit is contained in:
parent
90ae49df06
commit
e8948cb69c
|
@ -1,19 +1,35 @@
|
||||||
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:hub/flutter_flow/flutter_flow_model.dart';
|
import 'package:hub/flutter_flow/flutter_flow_model.dart';
|
||||||
|
import 'package:hub/flutter_flow/flutter_flow_util.dart';
|
||||||
|
import 'package:hub/flutter_flow/uploaded_file.dart';
|
||||||
import 'package:hub/pages/pets_page/pets_page_widget.dart';
|
import 'package:hub/pages/pets_page/pets_page_widget.dart';
|
||||||
|
|
||||||
class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
||||||
late final TabController tabBarController;
|
late final TabController tabBarController;
|
||||||
int get tabBarCurrentIndex =>
|
Timer? _debounceTimer;
|
||||||
tabBarController != null ? tabBarController!.index : 0;
|
|
||||||
|
final unfocusNode = FocusNode();
|
||||||
|
bool isDataUploading = false;
|
||||||
|
FFUploadedFile uploadedLocalFile =
|
||||||
|
FFUploadedFile(bytes: Uint8List.fromList([]));
|
||||||
|
|
||||||
|
void debounce(Function() fn, Duration time) {
|
||||||
|
if (_debounceTimer != null) {
|
||||||
|
_debounceTimer!.cancel();
|
||||||
|
}
|
||||||
|
_debounceTimer = Timer(time, fn);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
tabBarController?.dispose();
|
tabBarController.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState(BuildContext context) {
|
void initState(BuildContext context) {
|
||||||
|
// Se liga! Esse é o controller do TabBar
|
||||||
tabBarController = TabController(
|
tabBarController = TabController(
|
||||||
vsync: Navigator.of(context),
|
vsync: Navigator.of(context),
|
||||||
length: 2,
|
length: 2,
|
||||||
|
|
|
@ -1,13 +1,17 @@
|
||||||
|
import 'package:easy_debounce/easy_debounce.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/scheduler.dart';
|
import 'package:flutter/scheduler.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
import 'package:hub/components/atomic_components/shared_components_atoms/tabview.dart';
|
import 'package:hub/components/atomic_components/shared_components_atoms/tabview.dart';
|
||||||
import 'package:hub/flutter_flow/flutter_flow_icon_button.dart';
|
import 'package:hub/flutter_flow/flutter_flow_icon_button.dart';
|
||||||
import 'package:hub/flutter_flow/flutter_flow_model.dart';
|
import 'package:hub/flutter_flow/flutter_flow_model.dart';
|
||||||
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
|
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
|
||||||
import 'package:hub/flutter_flow/flutter_flow_util.dart';
|
import 'package:hub/flutter_flow/flutter_flow_util.dart';
|
||||||
|
import 'package:hub/flutter_flow/flutter_flow_widgets.dart';
|
||||||
import 'package:hub/flutter_flow/internationalization.dart';
|
import 'package:hub/flutter_flow/internationalization.dart';
|
||||||
import 'package:hub/flutter_flow/nav/nav.dart';
|
import 'package:hub/flutter_flow/nav/nav.dart';
|
||||||
|
import 'package:hub/flutter_flow/upload_data.dart';
|
||||||
import 'package:hub/pages/pets_page/pets_page_model.dart';
|
import 'package:hub/pages/pets_page/pets_page_model.dart';
|
||||||
|
|
||||||
class PetsPageWidget extends StatefulWidget {
|
class PetsPageWidget extends StatefulWidget {
|
||||||
|
@ -37,12 +41,12 @@ class _PetsPageWidgetState extends State<PetsPageWidget>
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: appBarPetsPage(context),
|
appBar: appBarPets(context),
|
||||||
body: petsPageBody(context, _model, _model.tabBarController));
|
body: tabViewPets(context, _model, _model.tabBarController));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PreferredSizeWidget appBarPetsPage(BuildContext context) {
|
PreferredSizeWidget appBarPets(BuildContext context) {
|
||||||
return AppBar(
|
return AppBar(
|
||||||
backgroundColor: FlutterFlowTheme.of(context).primaryBackground,
|
backgroundColor: FlutterFlowTheme.of(context).primaryBackground,
|
||||||
automaticallyImplyLeading: false,
|
automaticallyImplyLeading: false,
|
||||||
|
@ -79,14 +83,288 @@ PreferredSizeWidget appBarPetsPage(BuildContext context) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget petsPageBody(BuildContext context, PetsPageModel _model, controller) {
|
Widget tabViewPets(BuildContext context, PetsPageModel _model, controller) {
|
||||||
return TabViewUtil(
|
return TabViewUtil(
|
||||||
context: context,
|
context: context,
|
||||||
model: _model,
|
model: _model,
|
||||||
labelTab1: 'Cadastrar',
|
labelTab1: 'Cadastrar',
|
||||||
labelTab2: 'Consultar',
|
labelTab2: 'Consultar',
|
||||||
controller: controller,
|
controller: controller,
|
||||||
widget1: Center(child: Text('Cadastrar')),
|
widget1: formAddPets(context),
|
||||||
widget2: Center(child: Text('Consultar')),
|
widget2: Center(child: Text('Consultar')),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget formAddPets(BuildContext context) {
|
||||||
|
return SingleChildScrollView(
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
children: [
|
||||||
|
Form(
|
||||||
|
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsetsDirectional.fromSTEB(
|
||||||
|
24.0, 0.0, 24.0, 0.0),
|
||||||
|
child: Builder(
|
||||||
|
builder: (context) {
|
||||||
|
if ((_model.uploadedLocalFile.bytes?.isNotEmpty ??
|
||||||
|
false)) {
|
||||||
|
return InkWell(
|
||||||
|
splashColor: Colors.transparent,
|
||||||
|
focusColor: Colors.transparent,
|
||||||
|
hoverColor: Colors.transparent,
|
||||||
|
highlightColor: Colors.transparent,
|
||||||
|
onTap: () async {
|
||||||
|
setState(() {
|
||||||
|
_model.isDataUploading = false;
|
||||||
|
_model.uploadedLocalFile = FFUploadedFile(
|
||||||
|
bytes: Uint8List.fromList([]));
|
||||||
|
});
|
||||||
|
},
|
||||||
|
child: ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(8.0),
|
||||||
|
child: Image.memory(
|
||||||
|
_model.uploadedLocalFile.bytes ??
|
||||||
|
Uint8List.fromList([]),
|
||||||
|
width: 300.0,
|
||||||
|
height: 200.0,
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return Stack(
|
||||||
|
children: [
|
||||||
|
Align(
|
||||||
|
alignment: const AlignmentDirectional(0.0, 0.0),
|
||||||
|
child: FFButtonWidget(
|
||||||
|
onPressed: () async {
|
||||||
|
final selectedMedia =
|
||||||
|
await selectMediaWithSourceBottomSheet(
|
||||||
|
context: context,
|
||||||
|
// maxWidth: 300.00,
|
||||||
|
// maxHeight: 300.00,
|
||||||
|
imageQuality: 100,
|
||||||
|
allowPhoto: true,
|
||||||
|
includeDimensions: true,
|
||||||
|
);
|
||||||
|
if (selectedMedia != null) {
|
||||||
|
// &&
|
||||||
|
// selectedMedia.every((m) =>
|
||||||
|
// validateFileFormat(
|
||||||
|
// m.storagePath, context))) {
|
||||||
|
setState(
|
||||||
|
() => _model.isDataUploading = true);
|
||||||
|
var selectedUploadedFiles =
|
||||||
|
<FFUploadedFile>[];
|
||||||
|
|
||||||
|
try {
|
||||||
|
showUploadMessage(
|
||||||
|
context,
|
||||||
|
'Uploading file...',
|
||||||
|
showLoading: true,
|
||||||
|
);
|
||||||
|
selectedUploadedFiles = selectedMedia
|
||||||
|
.map((m) => FFUploadedFile(
|
||||||
|
name: m.storagePath
|
||||||
|
.split('/')
|
||||||
|
.last,
|
||||||
|
bytes: m.bytes,
|
||||||
|
height: m.dimensions?.height,
|
||||||
|
width: m.dimensions?.width,
|
||||||
|
// blurHash: m.blurHash,
|
||||||
|
))
|
||||||
|
.toList();
|
||||||
|
} finally {
|
||||||
|
ScaffoldMessenger.of(context)
|
||||||
|
.hideCurrentSnackBar();
|
||||||
|
_model.isDataUploading = false;
|
||||||
|
}
|
||||||
|
if (selectedUploadedFiles.length ==
|
||||||
|
selectedMedia.length) {
|
||||||
|
setState(() {
|
||||||
|
_model.uploadedLocalFile =
|
||||||
|
selectedUploadedFiles.first;
|
||||||
|
});
|
||||||
|
showUploadMessage(context, 'Success!');
|
||||||
|
} else {
|
||||||
|
setState(() {});
|
||||||
|
showUploadMessage(
|
||||||
|
context, 'Failed to upload data');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
text: '',
|
||||||
|
icon: Icon(
|
||||||
|
Icons.photo_camera,
|
||||||
|
color: FlutterFlowTheme.of(context).accent1,
|
||||||
|
size: 30.0,
|
||||||
|
),
|
||||||
|
options: FFButtonOptions(
|
||||||
|
width: double.infinity,
|
||||||
|
height: 120.0,
|
||||||
|
padding:
|
||||||
|
const EdgeInsetsDirectional.fromSTEB(
|
||||||
|
0.0, 0.0, 0.0, 20.0),
|
||||||
|
iconPadding:
|
||||||
|
const EdgeInsetsDirectional.fromSTEB(
|
||||||
|
14.0, 0.0, 0.0, 20.0),
|
||||||
|
color: FlutterFlowTheme.of(context)
|
||||||
|
.primaryBackground,
|
||||||
|
textStyle: FlutterFlowTheme.of(context)
|
||||||
|
.titleSmall
|
||||||
|
.override(
|
||||||
|
fontFamily:
|
||||||
|
FlutterFlowTheme.of(context)
|
||||||
|
.titleSmallFamily,
|
||||||
|
color: FlutterFlowTheme.of(context)
|
||||||
|
.primaryText,
|
||||||
|
fontSize: 16.0,
|
||||||
|
letterSpacing: 0.0,
|
||||||
|
useGoogleFonts: GoogleFonts.asMap()
|
||||||
|
.containsKey(
|
||||||
|
FlutterFlowTheme.of(context)
|
||||||
|
.titleSmallFamily),
|
||||||
|
),
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color:
|
||||||
|
FlutterFlowTheme.of(context).accent1,
|
||||||
|
width: 0.2,
|
||||||
|
),
|
||||||
|
borderRadius: BorderRadius.circular(8.0),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Align(
|
||||||
|
alignment: const AlignmentDirectional(0.0, 0.0),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsetsDirectional.fromSTEB(
|
||||||
|
10.0, 65.0, 10.0, 0.0),
|
||||||
|
child: Text(
|
||||||
|
FFLocalizations.of(context).getText(
|
||||||
|
'p4ftwxcy' /* Clique para adicionar a foto p... */,
|
||||||
|
),
|
||||||
|
style: FlutterFlowTheme.of(context)
|
||||||
|
.bodyMedium
|
||||||
|
.override(
|
||||||
|
fontFamily:
|
||||||
|
FlutterFlowTheme.of(context)
|
||||||
|
.bodyMediumFamily,
|
||||||
|
color: FlutterFlowTheme.of(context)
|
||||||
|
.primaryText,
|
||||||
|
letterSpacing: 0.0,
|
||||||
|
useGoogleFonts: GoogleFonts.asMap()
|
||||||
|
.containsKey(
|
||||||
|
FlutterFlowTheme.of(context)
|
||||||
|
.bodyMediumFamily),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsetsDirectional.fromSTEB(
|
||||||
|
24.0, 0.0, 24.0, 0.0),
|
||||||
|
child: TextFormField(
|
||||||
|
// controller: _model.textController1,
|
||||||
|
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||||
|
// focusNode: _model.textFieldFocusNode1,
|
||||||
|
// onChanged: (_) => EasyDebounce.debounce(
|
||||||
|
// '_model.textFieldFocusNode1',
|
||||||
|
// const Duration(milliseconds: 500),
|
||||||
|
// () => setState(() {}),
|
||||||
|
// ),
|
||||||
|
autofocus: false,
|
||||||
|
textInputAction: TextInputAction.next,
|
||||||
|
obscureText: false,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
isDense: true,
|
||||||
|
labelText: FFLocalizations.of(context).getText(
|
||||||
|
'v7g73yik' /* Nome */,
|
||||||
|
),
|
||||||
|
labelStyle: FlutterFlowTheme.of(context)
|
||||||
|
.labelMedium
|
||||||
|
.override(
|
||||||
|
fontFamily: FlutterFlowTheme.of(context)
|
||||||
|
.labelMediumFamily,
|
||||||
|
color: FlutterFlowTheme.of(context).primaryText,
|
||||||
|
letterSpacing: 0.0,
|
||||||
|
useGoogleFonts: GoogleFonts.asMap().containsKey(
|
||||||
|
FlutterFlowTheme.of(context)
|
||||||
|
.labelMediumFamily),
|
||||||
|
),
|
||||||
|
hintStyle: FlutterFlowTheme.of(context)
|
||||||
|
.labelMedium
|
||||||
|
.override(
|
||||||
|
fontFamily: FlutterFlowTheme.of(context)
|
||||||
|
.labelMediumFamily,
|
||||||
|
color: FlutterFlowTheme.of(context).primaryText,
|
||||||
|
letterSpacing: 0.0,
|
||||||
|
useGoogleFonts: GoogleFonts.asMap().containsKey(
|
||||||
|
FlutterFlowTheme.of(context)
|
||||||
|
.labelMediumFamily),
|
||||||
|
),
|
||||||
|
enabledBorder: OutlineInputBorder(
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color: FlutterFlowTheme.of(context).customColor6,
|
||||||
|
width: 0.5,
|
||||||
|
),
|
||||||
|
borderRadius: BorderRadius.circular(10.0),
|
||||||
|
),
|
||||||
|
focusedBorder: OutlineInputBorder(
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color: FlutterFlowTheme.of(context).primary,
|
||||||
|
width: 0.5,
|
||||||
|
),
|
||||||
|
borderRadius: BorderRadius.circular(10.0),
|
||||||
|
),
|
||||||
|
errorBorder: OutlineInputBorder(
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color: FlutterFlowTheme.of(context).error,
|
||||||
|
width: 0.5,
|
||||||
|
),
|
||||||
|
borderRadius: BorderRadius.circular(10.0),
|
||||||
|
),
|
||||||
|
focusedErrorBorder: OutlineInputBorder(
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color: FlutterFlowTheme.of(context).error,
|
||||||
|
width: 0.5,
|
||||||
|
),
|
||||||
|
borderRadius: BorderRadius.circular(10.0),
|
||||||
|
),
|
||||||
|
suffixIcon: Icon(
|
||||||
|
Icons.person,
|
||||||
|
color: FlutterFlowTheme.of(context).accent1,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
style: FlutterFlowTheme.of(context).bodyMedium.override(
|
||||||
|
fontFamily:
|
||||||
|
FlutterFlowTheme.of(context).bodyMediumFamily,
|
||||||
|
color: FlutterFlowTheme.of(context).primaryText,
|
||||||
|
letterSpacing: 0.0,
|
||||||
|
useGoogleFonts: GoogleFonts.asMap().containsKey(
|
||||||
|
FlutterFlowTheme.of(context).bodyMediumFamily),
|
||||||
|
),
|
||||||
|
maxLines: null,
|
||||||
|
maxLength: 80,
|
||||||
|
keyboardType: TextInputType.name,
|
||||||
|
inputFormatters: [LengthLimitingTextInputFormatter(80)],
|
||||||
|
// validator:
|
||||||
|
// _model.textController1Validator.asValidator(context),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
])),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue