now with easytabs!

This commit is contained in:
2024-09-04 19:37:03 -04:00
parent c2c47de6b5
commit 0c5c20188b
2 changed files with 34 additions and 20 deletions

13
lib/EasyTab.dart Normal file
View File

@@ -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,
});
}

View File

@@ -1,32 +1,33 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:ything_radio/EasyTab.dart';
class HomePage extends StatelessWidget { class HomePage extends StatelessWidget {
const HomePage({super.key, required this.title}); const HomePage({super.key, required this.title});
final String title; final String title;
final List<EasyTab> 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 @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return DefaultTabController( return DefaultTabController(
length: 3, length: easytabs.length,
child: Scaffold( child: Scaffold(
bottomNavigationBar: BottomAppBar( bottomNavigationBar: BottomAppBar(
color: Theme.of(context).colorScheme.inversePrimary, color: Theme.of(context).colorScheme.inversePrimary,
child: const TabBar(tabs: [ child: TabBar(
Tab( tabs: easytabs
icon: Icon(Icons.play_arrow), .map((tab_item) =>
text: "Listen", Tab(text: tab_item.title, icon: Icon(tab_item.icon)))
.toList()),
), ),
Tab( body: TabBarView(
icon: Icon(Icons.web_asset), children: easytabs.map((tab_item) => tab_item.child).toList()),
text: "Website",
), ),
Tab( );
icon: Icon(Icons.language),
text: "Links",
)
]),
),
));
} }
} }