import 'package:flutter/material.dart';
import 'pttVoice.dart';
import 'realVoice.dart';
import 'realVoiceV2.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Gme Flutter',
      theme: ThemeData(primarySwatch: Colors.blueGrey),
      home: const MyHomePage(title: 'GME Flutter Demo'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);

  // This widget is the home page of your application. It is stateful, meaning
  // that it has a State object (defined below) that contains fields that affect
  // how it looks.

  // This class is the configuration for the state. It holds the values (in this
  // case the title) provided by the parent (in this case the App widget) and
  // used by the build method of the State. Fields in a Widget subclass are
  // always marked "final".

  final String title;
  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _selectedIndex = 0;
  void _onItemTapped(int index) {
    setState(() {
      _selectedIndex = index;
    });
  }

  List<Widget> pageList = [RealVoicePage(), PttVoicePage(), RealVoicePageV2()];
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text(widget.title)),
      body: IndexedStack(index: _selectedIndex, children: pageList),

      //Demo(_selectedIndex),
      bottomNavigationBar: BottomNavigationBar(
        currentIndex: _selectedIndex,
        items: [
          const BottomNavigationBarItem(
            backgroundColor: Colors.grey,
            icon: Icon(Icons.voice_chat),
            label: 'realVoice',
          ),
          const BottomNavigationBarItem(
            backgroundColor: Colors.grey,
            icon: Icon(Icons.integration_instructions),
            label: 'PTT',
          ),
          const BottomNavigationBarItem(
            icon: Icon(Icons.handyman),
            backgroundColor: Colors.grey,
            label: 'GmeV2',
          ),
        ],
        onTap: _onItemTapped,
      ),
      // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}
