138 lines
4.6 KiB
Dart
138 lines
4.6 KiB
Dart
import 'package:firebase_messaging/firebase_messaging.dart';
|
|
|
|
import '/components/templates_components/sign_in_template_component/sign_in_template_component_widget.dart';
|
|
import '/components/templates_components/sign_up_template_component/sign_up_template_component_widget.dart';
|
|
import '/components/templates_components/welcome_template_component/welcome_template_component_widget.dart';
|
|
import '/flutter_flow/flutter_flow_theme.dart';
|
|
import '/flutter_flow/flutter_flow_util.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/scheduler.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'on_boarding_page_model.dart';
|
|
export 'on_boarding_page_model.dart';
|
|
|
|
class OnBoardingPageWidget extends StatefulWidget {
|
|
const OnBoardingPageWidget({super.key});
|
|
|
|
@override
|
|
State<OnBoardingPageWidget> createState() => _OnBoardingPageWidgetState();
|
|
}
|
|
|
|
class _OnBoardingPageWidgetState extends State<OnBoardingPageWidget> {
|
|
late OnBoardingPageModel _model;
|
|
|
|
final scaffoldKey = GlobalKey<ScaffoldState>();
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_model = createModel(context, () => OnBoardingPageModel());
|
|
|
|
// On page load action.
|
|
SchedulerBinding.instance.addPostFrameCallback((_) async {
|
|
if (!mounted)
|
|
return; // Adiciona esta linha para verificar se o widget ainda está montado
|
|
|
|
if (FFAppState().isLogged == true) {
|
|
context.goNamed(
|
|
'homePage',
|
|
extra: <String, dynamic>{
|
|
kTransitionInfoKey: const TransitionInfo(
|
|
hasTransition: true,
|
|
transitionType: PageTransitionType.fade,
|
|
duration: Duration(
|
|
milliseconds: 300), // Altere a duração para algo não nulo
|
|
),
|
|
},
|
|
);
|
|
} else {
|
|
if (isAndroid == true) {
|
|
FFAppState().device = 'Android';
|
|
setState(() {});
|
|
} else if (isiOS == true) {
|
|
FFAppState().device = 'iOS';
|
|
setState(() {});
|
|
} else {
|
|
FFAppState().device = 'Web';
|
|
setState(() {});
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_model.dispose();
|
|
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
context.watch<FFAppState>();
|
|
|
|
return GestureDetector(
|
|
onTap: () => _model.unfocusNode.canRequestFocus
|
|
? FocusScope.of(context).requestFocus(_model.unfocusNode)
|
|
: FocusScope.of(context).unfocus(),
|
|
child: Scaffold(
|
|
key: scaffoldKey,
|
|
backgroundColor: FlutterFlowTheme.of(context).primaryBackground,
|
|
body: SafeArea(
|
|
top: true,
|
|
child: Stack(
|
|
children: [
|
|
if (_model.toggleIdx == 'SignIn')
|
|
wrapWithModel(
|
|
model: _model.signInTemplateComponentModel,
|
|
updateCallback: () => setState(() {}),
|
|
updateOnChange: true,
|
|
child: SignInTemplateComponentWidget(
|
|
toggleOnBoardingPageAction: (toggleValueSignInParam) async {
|
|
await _model.toggleOnBoardingActionPage(
|
|
context,
|
|
toggleValue: toggleValueSignInParam,
|
|
);
|
|
setState(() {});
|
|
},
|
|
),
|
|
),
|
|
if (_model.toggleIdx == 'SignUp')
|
|
wrapWithModel(
|
|
model: _model.signUpTemplateComponentModel,
|
|
updateCallback: () => setState(() {}),
|
|
updateOnChange: true,
|
|
child: SignUpTemplateComponentWidget(
|
|
toggleOnBoardingPageAction: (toggleValueSignUpParam) async {
|
|
await _model.toggleOnBoardingActionPage(
|
|
context,
|
|
toggleValue: toggleValueSignUpParam,
|
|
);
|
|
setState(() {});
|
|
},
|
|
),
|
|
),
|
|
if (_model.toggleIdx == 'welcome')
|
|
wrapWithModel(
|
|
model: _model.welcomeTemplateComponentModel,
|
|
updateCallback: () => setState(() {}),
|
|
updateOnChange: true,
|
|
child: WelcomeTemplateComponentWidget(
|
|
toggleOnboardingPageAction:
|
|
(toggleValueWelcomeParam) async {
|
|
await _model.toggleOnBoardingActionPage(
|
|
context,
|
|
toggleValue: toggleValueWelcomeParam,
|
|
);
|
|
setState(() {});
|
|
},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|