175 lines
5.7 KiB
Dart
175 lines
5.7 KiB
Dart
import 'package:hub/shared/enums/enum_throw_exception.dart';
|
|
|
|
import '/flutter_flow/flutter_flow_animations.dart';
|
|
import '/flutter_flow/flutter_flow_theme.dart';
|
|
import '/flutter_flow/flutter_flow_util.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_animate/flutter_animate.dart';
|
|
import 'package:google_fonts/google_fonts.dart';
|
|
import 'throw_exception_model.dart';
|
|
export 'throw_exception_model.dart';
|
|
|
|
class ThrowExceptionWidget extends StatefulWidget {
|
|
ThrowExceptionWidget(
|
|
{super.key, required this.msg, this.type = EnumThrowException.error});
|
|
|
|
final String? msg;
|
|
EnumThrowException type;
|
|
|
|
@override
|
|
State<ThrowExceptionWidget> createState() => _ThrowExceptionWidgetState();
|
|
}
|
|
|
|
class _ThrowExceptionWidgetState extends State<ThrowExceptionWidget>
|
|
with TickerProviderStateMixin {
|
|
late ThrowExceptionModel _model;
|
|
|
|
final animationsMap = <String, AnimationInfo>{};
|
|
|
|
@override
|
|
void setState(VoidCallback callback) {
|
|
super.setState(callback);
|
|
_model.onUpdate();
|
|
}
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_model = createModel(context, () => ThrowExceptionModel());
|
|
|
|
animationsMap.addAll({
|
|
'stackOnPageLoadAnimation': AnimationInfo(
|
|
trigger: AnimationTrigger.onPageLoad,
|
|
effectsBuilder: () => [
|
|
FadeEffect(
|
|
curve: Curves.easeInOut,
|
|
delay: 0.0.ms,
|
|
duration: 600.0.ms,
|
|
begin: 0.0,
|
|
end: 1.0,
|
|
),
|
|
],
|
|
),
|
|
});
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_model.maybeDispose();
|
|
|
|
super.dispose();
|
|
}
|
|
|
|
Color _getColorByType(BuildContext context) {
|
|
switch (widget.type) {
|
|
case EnumThrowException.error:
|
|
return FlutterFlowTheme.of(context).error;
|
|
case EnumThrowException.warning:
|
|
return FlutterFlowTheme.of(context).warning;
|
|
case EnumThrowException.success:
|
|
return FlutterFlowTheme.of(context).success;
|
|
}
|
|
}
|
|
|
|
IconData _getIconByType(BuildContext context) {
|
|
switch (widget.type) {
|
|
case EnumThrowException.error:
|
|
return Icons.cancel_outlined;
|
|
case EnumThrowException.warning:
|
|
return Icons.warning_amber_outlined;
|
|
case EnumThrowException.success:
|
|
return Icons.check_circle_outline;
|
|
}
|
|
}
|
|
|
|
String _getTitleByType(BuildContext context) {
|
|
switch (widget.type) {
|
|
case EnumThrowException.error:
|
|
return FFLocalizations.of(context)
|
|
.getVariableText(ptText: "Falha :(", enText: "Fail :(");
|
|
case EnumThrowException.warning:
|
|
return FFLocalizations.of(context)
|
|
.getVariableText(ptText: "Aviso :O", enText: "Warning :O");
|
|
case EnumThrowException.success:
|
|
return FFLocalizations.of(context)
|
|
.getVariableText(ptText: "Sucesso ;)", enText: "Success ;)");
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Column(
|
|
mainAxisSize: MainAxisSize.max,
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsetsDirectional.fromSTEB(10.0, 0.0, 10.0, 0.0),
|
|
child: InkWell(
|
|
splashColor: Colors.transparent,
|
|
focusColor: Colors.transparent,
|
|
hoverColor: Colors.transparent,
|
|
highlightColor: Colors.transparent,
|
|
onTap: () async {
|
|
Navigator.pop(context);
|
|
},
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.max,
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Stack(
|
|
children: [
|
|
Align(
|
|
alignment: const AlignmentDirectional(0.0, 0.0),
|
|
child: Icon(
|
|
_getIconByType(context),
|
|
color: _getColorByType(context),
|
|
size: 150.0,
|
|
),
|
|
),
|
|
],
|
|
).animateOnPageLoad(animationsMap['stackOnPageLoadAnimation']!),
|
|
Column(
|
|
mainAxisSize: MainAxisSize.max,
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
_getTitleByType(context),
|
|
style: FlutterFlowTheme.of(context).bodyMedium.override(
|
|
fontFamily:
|
|
FlutterFlowTheme.of(context).bodyMediumFamily,
|
|
fontSize: 20.0,
|
|
letterSpacing: 0.0,
|
|
fontWeight: FontWeight.bold,
|
|
useGoogleFonts: GoogleFonts.asMap().containsKey(
|
|
FlutterFlowTheme.of(context).bodyMediumFamily),
|
|
),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsetsDirectional.fromSTEB(
|
|
0.0, 10.0, 0.0, 0.0),
|
|
child: Text(
|
|
valueOrDefault<String>(
|
|
widget.msg,
|
|
'Message Not Found',
|
|
),
|
|
style: FlutterFlowTheme.of(context).bodyMedium.override(
|
|
fontFamily:
|
|
FlutterFlowTheme.of(context).bodyMediumFamily,
|
|
letterSpacing: 0.0,
|
|
useGoogleFonts: GoogleFonts.asMap().containsKey(
|
|
FlutterFlowTheme.of(context)
|
|
.bodyMediumFamily),
|
|
),
|
|
),
|
|
),
|
|
].addToStart(const SizedBox(height: 20.0)),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|