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 '/actions/actions.dart' as action_blocks;
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:provider/provider.dart';
import 'welcome_page_model.dart';
export 'welcome_page_model.dart';

class WelcomePageWidget extends StatefulWidget {
  const WelcomePageWidget({super.key});

  @override
  State<WelcomePageWidget> createState() => _WelcomePageWidgetState();
}

class _WelcomePageWidgetState extends State<WelcomePageWidget> {
  late WelcomePageModel _model;

  final scaffoldKey = GlobalKey<ScaffoldState>();

  @override
  void initState() {
    super.initState();
    _model = createModel(context, () => WelcomePageModel());

    // On page load action.
    SchedulerBinding.instance.addPostFrameCallback((_) async {
      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: wrapWithModel(
            model: _model.welcomeTemplateComponentModel,
            updateCallback: () => setState(() {}),
            updateOnChange: true,
            child: WelcomeTemplateComponentWidget(
              toggleSignUpPage: () async {
                await action_blocks.toggleSignUpPage(context);
              },
              toggleSignInPage: () async {
                await action_blocks.toggleSignInPage(context);
              },
            ),
          ),
        ),
      ),
    );
  }
}