import 'package:flutter/material.dart';

class MainScreen extends StatefulWidget {
  const MainScreen({super.key});

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

class _MainScreenState extends State<MainScreen> with SingleTickerProviderStateMixin {
  Widget _currentBody = const HomeBody();

  void _changeBody(Widget newBody) {
    setState(() {
      _currentBody = newBody;
    });
  }
  late TabController _tabController;

  @override
  void initState() {
    super.initState();
    _tabController = TabController(length: 2, vsync: this);
  }

  @override
  void dispose() {
    _tabController.dispose();
    super.dispose();
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
          leading:SizedBox( 
          height: 50,
          width: 63,
          child: IconButton(
          icon: Image.asset('assets/images/logo.png'),
          onPressed: () {
            // Open drawer or perform action
          },
        ),),
        title: Row(
          children: [
const SizedBox(
                  height: 10, //height of button
                  width: 20, //width of button
                  child: Icon(Icons.keyboard_arrow_down),
                ),
                const SizedBox(
                  //width of button
                  width: 10,
                ),
                SizedBox(
                  width: 100.0,
                  child: TextField(
                    controller: TextEditingController(text: "Ingolstadt"),
                    decoration: const InputDecoration(
                      border: UnderlineInputBorder(),
                    ),
                  ),
                ),
          ],
        ),
        actions: [
          IconButton(
            icon: const Icon(Icons.search),
            onPressed: () {
              // Perform search action
            },
          ),
           const SizedBox(
                  height: 40,
                  child: VerticalDivider(
                    thickness: 1,
                    width: 20,
                    color: Colors.black,
                  ),),
          SizedBox(
                  height: 50, //height of button
                  //width of button
                  child: IconButton(
                    icon: Image.asset('assets/images/Login.png'),
                    onPressed: () {},
                  ),
                ),
        ],
        bottom: PreferredSize(
          preferredSize: const Size.fromHeight(1.0),
          child: Container(
            color: Colors.black,
            height: 1.0,
          ),
        ),
        flexibleSpace: Container(
          
        ),
      ),
      body: _currentBody,
      bottomNavigationBar: BottomAppBar(
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceAround,
          children: <Widget>[
            IconButton(
              icon: const Icon(Icons.home),
              onPressed: () => _changeBody(const HomeBody()),
            ),
            IconButton(
              icon: const Icon(Icons.settings),
              onPressed: () => _changeBody(const SettingsBody()),
            ),
            // Add more buttons as needed
          ],
        ),
      ),
    );
  }
}

class HomeBody extends StatelessWidget {
  const HomeBody({super.key});

  @override
  Widget build(BuildContext context) {
    return const Center(child: Text('Home Screen'));
  }
}

class SettingsBody extends StatelessWidget {
  const SettingsBody({super.key});

  @override
  Widget build(BuildContext context) {
    return const Center(child: Text('Settings Screen'));
  }
}