diff --git a/lib/EasyTab.dart b/lib/EasyTab.dart new file mode 100644 index 0000000..3d7ed05 --- /dev/null +++ b/lib/EasyTab.dart @@ -0,0 +1,13 @@ +import 'package:flutter/material.dart'; + +class EasyTab { + final String title; + final IconData icon; + final Widget child; + + const EasyTab({ + required this.title, + required this.icon, + required this.child, + }); +} diff --git a/lib/HomePage.dart b/lib/HomePage.dart index 0d06d27..e69aa1d 100644 --- a/lib/HomePage.dart +++ b/lib/HomePage.dart @@ -1,32 +1,33 @@ import 'package:flutter/material.dart'; +import 'package:ything_radio/EasyTab.dart'; class HomePage extends StatelessWidget { const HomePage({super.key, required this.title}); final String title; + final List easytabs = const [ + EasyTab(title: "Listen", icon: Icons.play_arrow, child: Placeholder()), + EasyTab(title: "About", icon: Icons.help, child: Placeholder()), + EasyTab(title: "Links", icon: Icons.language, child: Placeholder()), + ]; + @override Widget build(BuildContext context) { return DefaultTabController( - length: 3, - child: Scaffold( - bottomNavigationBar: BottomAppBar( - color: Theme.of(context).colorScheme.inversePrimary, - child: const TabBar(tabs: [ - Tab( - icon: Icon(Icons.play_arrow), - text: "Listen", - ), - Tab( - icon: Icon(Icons.web_asset), - text: "Website", - ), - Tab( - icon: Icon(Icons.language), - text: "Links", - ) - ]), - ), - )); + length: easytabs.length, + child: Scaffold( + bottomNavigationBar: BottomAppBar( + color: Theme.of(context).colorScheme.inversePrimary, + child: TabBar( + tabs: easytabs + .map((tab_item) => + Tab(text: tab_item.title, icon: Icon(tab_item.icon))) + .toList()), + ), + body: TabBarView( + children: easytabs.map((tab_item) => tab_item.child).toList()), + ), + ); } }