
import 'package:flutter/material.dart';
import 'package:responsive_builder/responsive_builder.dart';

import '../constants.dart';
import '../generated/l10n.dart';
import '../store/actions.dart';
import '../store/store.dart';
import '../widgets/desktop/desktop_me.dart';
import '../widgets/general/bottom_nav.dart';
import '../widgets/general/breadcrumbs.dart';
import '../widgets/general/double_back_to_close_app_wrapper.dart';
import '../widgets/general/navigationbar.dart';
import '../widgets/mobile/MobileBottomNav.dart';
import '../widgets/mobile/mobile_me.dart';

class Me extends StatefulWidget {
  final Key? key;

  const Me({this.key}) : super(key: key);

  @override
  State<StatefulWidget> createState() {
    return MeState();
  }
}

class MeState extends State<Me> {

  final _scaffoldKey = GlobalKey<ScaffoldState>();

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    store.dispatch(UpdateContext(context));

    return ResponsiveBuilder(
      builder: (context, sizingInformation) =>
          Scaffold(
            key: _scaffoldKey,
            appBar: sizingInformation.isMobile? null : MiniNavigationBar(
              title: S.of(context).me,
              back: true,
              breadCrumbs: [
                BreadCrumb(S.of(context).me, null),
              ],
              breadCrumbHeight: sizingInformation.deviceScreenType == DeviceScreenType.mobile ? null : Constants.BREADCRUMB_HEIGHT,
            ),
            drawer: null,
            body: DoubleBackToCloseAppWrapper(
              child: ScreenTypeLayout(
                mobile: MobileMe(),
                tablet: DesktopMe(),
                desktop: DesktopMe(),
              ),
            ),
            bottomNavigationBar: ScreenTypeLayout(
              mobile: MobileBottomNav(currentIndex: 3,),
              tablet: BottomNav(),
              desktop: BottomNav(),
            ),
          ),
    );
  }
}