import 'package:flutter/material.dart';
import 'package:tasktracker/Settings/Settings.dart';
import 'package:tasktracker/Data.dart';
import 'package:tasktracker/theme_provider.dart';
import 'package:provider/provider.dart';
class AppearanceSettings extends StatefulWidget {
  const AppearanceSettings({Key? key}) : super(key: key);

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

class _AppearanceSettingsState extends State<AppearanceSettings> {

  @override
  Widget build(BuildContext context) {
    final themeProvider= Provider.of<ThemeProvider>(context);

    return Scaffold(
        appBar: AppBar(title: Text('Appearance Settings')),
        body: SafeArea(
          child: Container(
            child: Column(
              mainAxisSize: MainAxisSize.max,
              children: [
                SizedBox(height: 10,),
                Padding(
                  padding: const EdgeInsets.all(5.0),
                  child: Row(
                    mainAxisSize: MainAxisSize.max,
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Text("Dark Mode",style: TextStyle(fontSize: 18)),
                      Switch.adaptive(value: themeProvider.isDarkMode, onChanged: (value){
                        final provider = Provider.of<ThemeProvider>(context, listen: false);
                        provider.toggleTheme(value);
                        Settings.setTheme(value ? 0:1);
                      })
                    ],
                  ),
                ),
                Divider(),
              ],
            ),
          ),
        )
    );
  }
}