Skip to content

Commit

Permalink
chore(yt): change tabs header to icons
Browse files Browse the repository at this point in the history
cuz starting to get cluttered and hard to reach a page
  • Loading branch information
MSOB7YY committed Jul 8, 2024
1 parent f462bce commit 4ab32fd
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 12 deletions.
9 changes: 9 additions & 0 deletions lib/core/namida_converter_ext.dart
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,7 @@ extension InsertionSortingTypeTextIcon on InsertionSortingType {

extension YTHomePagesUils on YTHomePages {
String toText() => _NamidaConverters.inst.getTitle(this);
IconData toIcon() => _NamidaConverters.inst.getIcon(this);
}

extension PlaylistAddDuplicateActionUtils on PlaylistAddDuplicateAction {
Expand Down Expand Up @@ -1405,6 +1406,14 @@ class _NamidaConverters {
FABType.shuffle: Broken.shuffle,
FABType.play: Broken.play_cricle,
},
YTHomePages: {
YTHomePages.home: Broken.home_1,
YTHomePages.notifications: Broken.notification_bing,
YTHomePages.channels: Broken.profile_2user,
YTHomePages.playlists: Broken.music_library_2,
YTHomePages.userplaylists: Broken.music_dashboard,
YTHomePages.downloads: Broken.import,
},
};

_ffmpegToTitle = {
Expand Down
29 changes: 20 additions & 9 deletions lib/ui/widgets/custom_widgets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3301,7 +3301,8 @@ class NamidaAspectRatio extends StatelessWidget {

class NamidaTabView extends StatefulWidget {
final int initialIndex;
final List<String> tabs;
final List<String>? tabs;
final List<Widget>? tabWidgets;
final List<Widget> children;
final void Function(int index) onIndexChanged;
final bool isScrollable;
Expand All @@ -3310,7 +3311,8 @@ class NamidaTabView extends StatefulWidget {
super.key,
required this.children,
required this.initialIndex,
required this.tabs,
this.tabs,
this.tabWidgets,
required this.onIndexChanged,
this.isScrollable = false,
});
Expand Down Expand Up @@ -3353,13 +3355,22 @@ class _NamidaTabViewState extends State<NamidaTabView> with SingleTickerProvider
controller: controller,
isScrollable: widget.isScrollable,
tabs: widget.tabs
.map(
(e) => Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 10.0),
child: Text(e, maxLines: 1, overflow: TextOverflow.ellipsis),
),
)
.toList(),
?.map(
(e) => Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 10.0),
child: Text(e, maxLines: 1, overflow: TextOverflow.ellipsis),
),
)
.toList() ??
widget.tabWidgets ??
widget.children
.map(
(e) => Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 10.0),
child: Text(e.toString(), maxLines: 1, overflow: TextOverflow.ellipsis),
),
)
.toList(),
splashBorderRadius: BorderRadius.circular(12.0.multipliedRadius),
// indicatorPadding: const EdgeInsets.symmetric(horizontal: 32.0),
indicatorSize: TabBarIndicatorSize.label,
Expand Down
17 changes: 15 additions & 2 deletions lib/youtube/pages/youtube_home_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,22 @@ class YouTubeHomeView extends StatelessWidget with NamidaRouteWidget {
Widget build(BuildContext context) {
return BackgroundWrapper(
child: NamidaTabView(
isScrollable: true,
isScrollable: false,
initialIndex: settings.ytInitialHomePage.value.index,
tabs: YTHomePages.values.map((e) => e.toText()).toList(),
tabWidgets: YTHomePages.values
.map(
(e) => Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
child: Tooltip(
message: e.toText(),
child: Icon(
e.toIcon(),
size: 18.0,
),
),
),
)
.toList(),
onIndexChanged: (index) {
settings.save(ytInitialHomePage: YTHomePages.values[index]);
},
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: namida
description: A Beautiful and Feature-rich Music Player, With YouTube & Video Support Built in Flutter
publish_to: "none"
version: 3.0.9-beta+240708233
version: 3.1.0-beta+240708236

environment:
sdk: ">=3.4.0 <4.0.0"
Expand Down

0 comments on commit 4ab32fd

Please sign in to comment.