import 'package:diplomaticquarterapp/config/config.dart';
import 'package:diplomaticquarterapp/pages/settings/general_setting.dart';
import 'package:diplomaticquarterapp/pages/settings/profile_setting.dart';
import 'package:diplomaticquarterapp/theme/colors.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/widgets/others/arrow_back.dart';
import 'package:flutter/material.dart';

class Settings extends StatefulWidget {
  final int type;

  Settings({this.type = 0});

  @override
  _Settings createState() => _Settings();
}

class _Settings extends State<Settings> with TickerProviderStateMixin {
  TabController _tabController;

  @override
  void initState() {
    _tabController = new TabController(length: 2, vsync: this, initialIndex: widget.type);

    if (widget.type == 1) {
      _tabController.animateTo(1);
    }

    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    AppGlobal.context = context;
    return AppScaffold(
      isShowAppBar: false,
      isShowDecPage: false,
      showNewAppBarTitle: true,
      showNewAppBar: true,
      appBarTitle: TranslationBase.of(context).settings,
      backgroundColor: Color(0xFFF7F7F7),
      body: Column(
        children: [
          TabBar(
            // isScrollable: true,

            indicatorWeight: 3.0,
            //indicatorSize: TabBarIndicatorSize.label,
            // indicatorSize: TabBarIndicatorSize.tab,

            indicatorColor: CustomColors.accentColor,
            labelColor: Colors.black,
            unselectedLabelColor: CustomColors.grey,
            // labelColor: Theme.of(context).primaryColor,
            tabs: [
              Tab(text: TranslationBase.of(context).general),
              Tab(
                text: TranslationBase.of(context).profile,
              )
            ],
            controller: _tabController,
          ),
          Expanded(
            child: TabBarView(
                physics: NeverScrollableScrollPhysics(),
                children: [
                  GeneralSettings(),
                  ProfileSettings(),
                ],
                controller: _tabController),
          ),
        ],
      ),
    );
  }
}
