Skip to content

Commit e31fd0f

Browse files
committed
feat: add bottom navigation bar
1 parent 0ec7ab2 commit e31fd0f

File tree

2 files changed

+98
-13
lines changed

2 files changed

+98
-13
lines changed

lib/main.dart

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import 'package:hive_flutter/hive_flutter.dart';
2525
import 'models/conversion_history_entry.dart';
2626
import 'models/music_platform.dart';
2727
import 'models/track_metadata.dart';
28-
import 'pages/home_page.dart';
28+
import 'screens/main_screen.dart';
2929
import 'theme/app_theme.dart';
3030
import 'utils/web_share_handler.dart';
3131

@@ -53,8 +53,9 @@ class MusicSharityApp extends StatefulWidget {
5353
}
5454

5555
class _MusicSharityAppState extends State<MusicSharityApp> {
56-
static const _shareChannel = EventChannel('fr.byteroast.music_sharity/share');
57-
final _appLinks = AppLinks();
56+
static const EventChannel _shareChannel = EventChannel('fr.byteroast.music_sharity/share');
57+
58+
final AppLinks _appLinks = AppLinks();
5859

5960
StreamSubscription<Uri>? _deepLinkSubscription;
6061
StreamSubscription<Object?>? _nativeShareSubscription;
@@ -77,6 +78,16 @@ class _MusicSharityAppState extends State<MusicSharityApp> {
7778
}
7879
}
7980

81+
@override
82+
Widget build(BuildContext context) {
83+
return MaterialApp(
84+
title: 'Music Sharity',
85+
theme: AppTheme.darkTheme,
86+
debugShowCheckedModeBanner: false,
87+
home: MainScreen(initialLink: _sharedLink),
88+
);
89+
}
90+
8091
void _initWebSharing() {
8192
final sharedUrl = WebShareHandler.getSharedUrl();
8293

@@ -160,14 +171,4 @@ class _MusicSharityAppState extends State<MusicSharityApp> {
160171

161172
super.dispose();
162173
}
163-
164-
@override
165-
Widget build(BuildContext context) {
166-
return MaterialApp(
167-
title: 'Music Sharity',
168-
theme: AppTheme.darkTheme,
169-
debugShowCheckedModeBanner: false,
170-
home: HomePage(initialLink: _sharedLink, key: ValueKey(_sharedLink)),
171-
);
172-
}
173174
}

lib/screens/main_screen.dart

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*
2+
* Music Sharity - Share music across all platforms
3+
* Copyright (C) 2026 Sikelio (Byte Roast)
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
*/
18+
import 'package:flutter/material.dart';
19+
import '../pages/home_page.dart';
20+
import '../theme/app_theme.dart';
21+
22+
class MainScreen extends StatefulWidget {
23+
final String? initialLink;
24+
25+
const MainScreen({super.key, this.initialLink});
26+
27+
@override
28+
State<MainScreen> createState() => _MainScreenState();
29+
}
30+
31+
class _MainScreenState extends State<MainScreen> {
32+
int _selectedIndex = 0;
33+
34+
late List<Widget> _pages;
35+
36+
@override
37+
void initState() {
38+
super.initState();
39+
_pages = [
40+
HomePage(initialLink: widget.initialLink, key: ValueKey(widget.initialLink)),
41+
Text('History')
42+
];
43+
}
44+
45+
@override
46+
void didUpdateWidget(MainScreen oldWidget) {
47+
super.didUpdateWidget(oldWidget);
48+
49+
if (widget.initialLink != oldWidget.initialLink) {
50+
_pages[0] = HomePage(initialLink: widget.initialLink, key: ValueKey(widget.initialLink));
51+
}
52+
}
53+
54+
void _onItemTapped(int index) {
55+
setState(() {
56+
_selectedIndex = index;
57+
});
58+
}
59+
60+
@override
61+
Widget build(BuildContext context) {
62+
return Scaffold(
63+
body: IndexedStack(
64+
index: _selectedIndex,
65+
children: _pages,
66+
),
67+
bottomNavigationBar: BottomNavigationBar(
68+
currentIndex: _selectedIndex,
69+
onTap: _onItemTapped,
70+
fixedColor: AppTheme.electricBlue,
71+
items: const [
72+
BottomNavigationBarItem(
73+
icon: Icon(Icons.home_rounded),
74+
label: 'Home',
75+
),
76+
BottomNavigationBarItem(
77+
icon: Icon(Icons.history),
78+
label: 'History'
79+
),
80+
],
81+
),
82+
);
83+
}
84+
}

0 commit comments

Comments
 (0)