import 'package:flutter/material.dart';
import 'package:tasktracker/Settings/Settings.dart';
import 'package:tasktracker/Data.dart';

class BehaviourSettings extends StatefulWidget {
  const BehaviourSettings({Key? key}) : super(key: key);

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

class _BehaviourSettingsState extends State<BehaviourSettings> {

  bool untracked_unprod = true;

  @override void initState() {
    // TODO: implement initState
    super.initState();
    init();
  }

  void init() async{
    untracked_unprod=await Settings.getUntrackedUnproductive();
    setState(() {

    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(title: Text('Behaviour Settings')),
        body: SafeArea(
          child: Container(
            child:Column(
              children: [
                ListTile(
                  title:Text("Count untracked time as unproductive"),
                  subtitle: Text("Not tracking = Not productive"),
                  trailing: Switch.adaptive(value: untracked_unprod, onChanged: (val){
                    untracked_unprod=val;
                    setState(() {
                      Settings.setUntrackedUnproductive(val);
                    });
                    setState(() {

                    });
                  }),
                ),

              ],
            )
          ),
        )
    );
  }
}