import 'package:diplomaticquarterapp/config/config.dart';
import 'package:diplomaticquarterapp/pages/settings/profile_setting.dart';
import 'package:diplomaticquarterapp/pages/settings/general_setting.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.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 Scaffold(
      appBar: AppBar(
        actions: [
          IconButton(
            icon: Icon(Icons.info, color: Colors.white),
            onPressed: () {
              //openInfoPage()
            },
          )
        ],
        bottom: TabBar(
          // isScrollable: true,

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

          indicatorColor: Theme.of(context).primaryColor,
          // labelColor: Theme.of(context).primaryColor,
          tabs: [
            Tab(text: TranslationBase.of(context).general),
            Tab(
              text: TranslationBase.of(context).profile,
            )
          ],
          controller: _tabController,
        ),
        title: Text(TranslationBase.of(context).settings,
            style: TextStyle(color: Colors.white)),
        leading: Builder(
          builder: (BuildContext context) {
            return ArrowBack();
          },
        ),
      ),
      body: TabBarView(
          physics: NeverScrollableScrollPhysics(),
          children: [GeneralSettings(), ProfileSettings()],
          controller: _tabController),
    );
  }
}
