[imp]: Switch out search from navbar
This commit is contained in:
+27
-43
@@ -33,9 +33,8 @@ class _FloridAppState extends State<FloridApp> {
|
||||
|
||||
late final List<Widget> _screens = [
|
||||
const LibraryScreen(),
|
||||
SearchScreen(tabIndexListenable: _tabNotifier, tabIndex: 1),
|
||||
const UpdatesScreen(),
|
||||
const UserScreen(),
|
||||
UpdatesScreen(),
|
||||
UserScreen(),
|
||||
];
|
||||
|
||||
@override
|
||||
@@ -266,12 +265,6 @@ class _FloridAppState extends State<FloridApp> {
|
||||
selectedIcon: homeSelectedIcon,
|
||||
label: Text(localizations.home),
|
||||
),
|
||||
if (!isFlorid)
|
||||
NavigationRailDestination(
|
||||
icon: searchIcon,
|
||||
selectedIcon: searchSelectedIcon,
|
||||
label: Text(localizations.search),
|
||||
),
|
||||
NavigationRailDestination(
|
||||
icon: deviceIcon,
|
||||
selectedIcon: deviceSelectedIcon,
|
||||
@@ -284,18 +277,20 @@ class _FloridAppState extends State<FloridApp> {
|
||||
),
|
||||
];
|
||||
|
||||
final floridNavIndex = _currentIndex == 2
|
||||
final floridNavIndex = _currentIndex == 1
|
||||
? 1
|
||||
: _currentIndex == 3
|
||||
: _currentIndex == 2
|
||||
? 2
|
||||
: 0;
|
||||
|
||||
final searchFab = FloatingActionButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_currentIndex = 1;
|
||||
});
|
||||
_tabNotifier.value = 1;
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const SearchScreen(),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: const Icon(Symbols.search),
|
||||
);
|
||||
@@ -306,21 +301,12 @@ class _FloridAppState extends State<FloridApp> {
|
||||
children: [
|
||||
if (isWide)
|
||||
NavigationRail(
|
||||
selectedIndex: isFlorid
|
||||
? floridNavIndex
|
||||
: _currentIndex,
|
||||
selectedIndex: _currentIndex,
|
||||
onDestinationSelected: (index) {
|
||||
final targetIndex = isFlorid
|
||||
? (index == 0
|
||||
? 0
|
||||
: index == 1
|
||||
? 2
|
||||
: 3)
|
||||
: index;
|
||||
setState(() {
|
||||
_currentIndex = targetIndex;
|
||||
_currentIndex = index;
|
||||
});
|
||||
_tabNotifier.value = targetIndex;
|
||||
_tabNotifier.value = index;
|
||||
},
|
||||
destinations: navRailDestinations,
|
||||
trailingAtBottom: true,
|
||||
@@ -393,15 +379,10 @@ class _FloridAppState extends State<FloridApp> {
|
||||
child: FNavBar(
|
||||
currentIndex: floridNavIndex,
|
||||
onChanged: (index) {
|
||||
final targetIndex = index == 0
|
||||
? 0
|
||||
: index == 1
|
||||
? 2
|
||||
: 3;
|
||||
setState(() {
|
||||
_currentIndex = targetIndex;
|
||||
_currentIndex = index;
|
||||
});
|
||||
_tabNotifier.value = targetIndex;
|
||||
_tabNotifier.value = index;
|
||||
},
|
||||
items: floridNavItems,
|
||||
fab: searchFab,
|
||||
@@ -420,6 +401,18 @@ class _FloridAppState extends State<FloridApp> {
|
||||
),
|
||||
),
|
||||
),
|
||||
if (!isFlorid && !isWide)
|
||||
Positioned(
|
||||
right: 16,
|
||||
bottom: 16,
|
||||
child: SafeArea(child: searchFab),
|
||||
),
|
||||
if (!isFlorid && isWide)
|
||||
Positioned(
|
||||
right: 24,
|
||||
bottom: 24,
|
||||
child: SafeArea(child: searchFab),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
@@ -449,15 +442,6 @@ class _FloridAppState extends State<FloridApp> {
|
||||
),
|
||||
label: localizations.home,
|
||||
),
|
||||
NavigationDestination(
|
||||
icon: const Icon(Symbols.search),
|
||||
selectedIcon: const Icon(
|
||||
Symbols.search,
|
||||
fill: 1,
|
||||
weight: 600,
|
||||
),
|
||||
label: localizations.search,
|
||||
),
|
||||
NavigationDestination(
|
||||
icon: updatableAppsCount > 0
|
||||
? Badge.count(
|
||||
|
||||
@@ -2,7 +2,6 @@ import 'package:florid/l10n/app_localizations.dart';
|
||||
import 'package:florid/providers/settings_provider.dart';
|
||||
import 'package:florid/utils/menu_actions.dart';
|
||||
import 'package:florid/utils/responsive.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:material_symbols_icons/symbols.dart';
|
||||
@@ -14,13 +13,7 @@ import '../widgets/app_list_item.dart';
|
||||
import 'app_details_screen.dart';
|
||||
|
||||
class SearchScreen extends StatefulWidget {
|
||||
const SearchScreen({super.key, this.tabIndexListenable, this.tabIndex = 1});
|
||||
|
||||
/// Notifies the screen when the search tab becomes active.
|
||||
final ValueListenable<int>? tabIndexListenable;
|
||||
|
||||
/// The index of the search tab in the parent navigation.
|
||||
final int tabIndex;
|
||||
const SearchScreen({super.key});
|
||||
|
||||
@override
|
||||
State<SearchScreen> createState() => _SearchScreenState();
|
||||
@@ -30,8 +23,10 @@ class _SearchScreenState extends State<SearchScreen> {
|
||||
final TextEditingController _searchController = TextEditingController();
|
||||
final FocusNode _searchFocus = FocusNode();
|
||||
|
||||
void _requestFocus() {
|
||||
// Defer to ensure the widget tree is ready, then show keyboard.
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
// Auto-focus search field when screen opens
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (!mounted) return;
|
||||
_searchFocus.requestFocus();
|
||||
@@ -39,25 +34,8 @@ class _SearchScreenState extends State<SearchScreen> {
|
||||
});
|
||||
}
|
||||
|
||||
void _handleTabChange() {
|
||||
if (!mounted) return;
|
||||
final current = widget.tabIndexListenable?.value;
|
||||
if (current == widget.tabIndex) {
|
||||
_requestFocus();
|
||||
} else {
|
||||
_searchFocus.unfocus();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
widget.tabIndexListenable?.addListener(_handleTabChange);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
widget.tabIndexListenable?.removeListener(_handleTabChange);
|
||||
_searchController.dispose();
|
||||
_searchFocus.dispose();
|
||||
super.dispose();
|
||||
|
||||
@@ -28,7 +28,7 @@ class _UpdatesScreenState extends State<UpdatesScreen>
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_tabController = TabController(length: 3, vsync: this);
|
||||
_tabController = TabController(length: 2, vsync: this);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_loadData();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user