Keep original bottom nav, navigate search/notifications inside shell with Threads-style top bar
This commit is contained in:
parent
8623596903
commit
858d57b5b2
|
|
@ -21,6 +21,7 @@ import '../screens/discover/discover_screen.dart';
|
||||||
import '../screens/secure_chat/secure_chat_full_screen.dart';
|
import '../screens/secure_chat/secure_chat_full_screen.dart';
|
||||||
import '../screens/secure_chat/secure_chat_loader_screen.dart';
|
import '../screens/secure_chat/secure_chat_loader_screen.dart';
|
||||||
import '../screens/post/threaded_conversation_screen.dart';
|
import '../screens/post/threaded_conversation_screen.dart';
|
||||||
|
import '../screens/notifications/notifications_screen.dart';
|
||||||
|
|
||||||
/// App routing config (GoRouter).
|
/// App routing config (GoRouter).
|
||||||
class AppRoutes {
|
class AppRoutes {
|
||||||
|
|
@ -93,6 +94,16 @@ class AppRoutes {
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: homeAlias,
|
path: homeAlias,
|
||||||
builder: (_, __) => const FeedPersonalScreen(),
|
builder: (_, __) => const FeedPersonalScreen(),
|
||||||
|
routes: [
|
||||||
|
GoRoute(
|
||||||
|
path: 'notifications',
|
||||||
|
builder: (_, __) => const NotificationsScreen(),
|
||||||
|
),
|
||||||
|
GoRoute(
|
||||||
|
path: 'discover',
|
||||||
|
builder: (_, __) => const DiscoverScreen(),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -256,13 +256,7 @@ class _HomeShellState extends ConsumerState<HomeShell> with WidgetsBindingObserv
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: Icon(Icons.search, color: AppTheme.navyBlue),
|
icon: Icon(Icons.search, color: AppTheme.navyBlue),
|
||||||
tooltip: 'Discover',
|
tooltip: 'Discover',
|
||||||
onPressed: () {
|
onPressed: () => context.go('/home/discover'),
|
||||||
Navigator.of(context).push(
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (_) => const DiscoverScreen(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: Consumer(
|
icon: Consumer(
|
||||||
|
|
@ -299,13 +293,7 @@ class _HomeShellState extends ConsumerState<HomeShell> with WidgetsBindingObserv
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
tooltip: 'Notifications',
|
tooltip: 'Notifications',
|
||||||
onPressed: () {
|
onPressed: () => context.go('/home/notifications'),
|
||||||
Navigator.of(context).push(
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (_) => const NotificationsScreen(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
const SizedBox(width: 4),
|
const SizedBox(width: 4),
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -6,13 +6,9 @@ import 'package:timeago/timeago.dart' as timeago;
|
||||||
import '../../models/notification.dart';
|
import '../../models/notification.dart';
|
||||||
import '../../providers/api_provider.dart';
|
import '../../providers/api_provider.dart';
|
||||||
import '../../theme/app_theme.dart';
|
import '../../theme/app_theme.dart';
|
||||||
import '../../widgets/app_scaffold.dart';
|
|
||||||
import '../../widgets/media/signed_media_image.dart';
|
import '../../widgets/media/signed_media_image.dart';
|
||||||
import '../profile/viewable_profile_screen.dart';
|
import '../profile/viewable_profile_screen.dart';
|
||||||
import '../post/post_detail_screen.dart';
|
import '../post/post_detail_screen.dart';
|
||||||
import '../search/search_screen.dart';
|
|
||||||
import '../discover/discover_screen.dart';
|
|
||||||
import '../secure_chat/secure_chat_full_screen.dart';
|
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import '../../services/notification_service.dart';
|
import '../../services/notification_service.dart';
|
||||||
|
|
||||||
|
|
@ -352,35 +348,33 @@ class _NotificationsScreenState extends ConsumerState<NotificationsScreen> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _navigateHome() {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
}
|
|
||||||
|
|
||||||
void _navigateSearch() {
|
|
||||||
Navigator.of(context).pushReplacement(
|
|
||||||
MaterialPageRoute(builder: (_) => const DiscoverScreen()),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _navigateChat() {
|
|
||||||
Navigator.of(context).pushReplacement(
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (_) => const SecureChatFullScreen(),
|
|
||||||
fullscreenDialog: true,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final canArchiveAll = _activeTabIndex == 0 && _notifications.isNotEmpty;
|
final canArchiveAll = _activeTabIndex == 0 && _notifications.isNotEmpty;
|
||||||
|
|
||||||
return DefaultTabController(
|
return DefaultTabController(
|
||||||
length: 2,
|
length: 2,
|
||||||
child: AppScaffold(
|
child: Scaffold(
|
||||||
title: 'Activity',
|
backgroundColor: AppTheme.scaffoldBg,
|
||||||
leading: const SizedBox.shrink(),
|
body: SafeArea(
|
||||||
actions: [
|
child: Column(
|
||||||
|
children: [
|
||||||
|
// Threads-style top bar
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 4, right: 8, top: 4),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
IconButton(
|
||||||
|
icon: Icon(Icons.arrow_back, color: AppTheme.navyBlue),
|
||||||
|
onPressed: () => context.go('/home'),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'Activity',
|
||||||
|
style: AppTheme.textTheme.headlineSmall?.copyWith(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Spacer(),
|
||||||
if (canArchiveAll)
|
if (canArchiveAll)
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: _archiveAllNotifications,
|
onPressed: _archiveAllNotifications,
|
||||||
|
|
@ -393,7 +387,10 @@ class _NotificationsScreenState extends ConsumerState<NotificationsScreen> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
bottom: TabBar(
|
),
|
||||||
|
),
|
||||||
|
// Filter tabs
|
||||||
|
TabBar(
|
||||||
onTap: (index) {
|
onTap: (index) {
|
||||||
if (index != _activeTabIndex) {
|
if (index != _activeTabIndex) {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
|
@ -410,8 +407,9 @@ class _NotificationsScreenState extends ConsumerState<NotificationsScreen> {
|
||||||
Tab(text: 'Archived'),
|
Tab(text: 'Archived'),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
bottomNavigationBar: _buildBottomNav(),
|
// Content
|
||||||
body: _error != null
|
Expanded(
|
||||||
|
child: _error != null
|
||||||
? _ErrorState(
|
? _ErrorState(
|
||||||
message: _error!,
|
message: _error!,
|
||||||
onRetry: () => _loadNotifications(refresh: true),
|
onRetry: () => _loadNotifications(refresh: true),
|
||||||
|
|
@ -486,88 +484,12 @@ class _NotificationsScreenState extends ConsumerState<NotificationsScreen> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildBottomNav() {
|
|
||||||
return Container(
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: AppTheme.scaffoldBg,
|
|
||||||
border: Border(
|
|
||||||
top: BorderSide(
|
|
||||||
color: AppTheme.egyptianBlue.withOpacity(0.1),
|
|
||||||
width: 0.5,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: SafeArea(
|
|
||||||
top: false,
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
||||||
children: [
|
|
||||||
_buildNavItem(
|
|
||||||
icon: Icons.home_outlined,
|
|
||||||
label: 'Home',
|
|
||||||
onTap: _navigateHome,
|
|
||||||
),
|
|
||||||
_buildNavItem(
|
|
||||||
icon: Icons.search,
|
|
||||||
label: 'Discover',
|
|
||||||
onTap: _navigateSearch,
|
|
||||||
),
|
|
||||||
_buildNavItem(
|
|
||||||
icon: Icons.notifications,
|
|
||||||
label: 'Activity',
|
|
||||||
isActive: true,
|
|
||||||
onTap: () {},
|
|
||||||
),
|
|
||||||
_buildNavItem(
|
|
||||||
icon: Icons.chat_bubble_outline,
|
|
||||||
label: 'Chat',
|
|
||||||
onTap: _navigateChat,
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildNavItem({
|
|
||||||
required IconData icon,
|
|
||||||
required String label,
|
|
||||||
required VoidCallback onTap,
|
|
||||||
bool isActive = false,
|
|
||||||
}) {
|
|
||||||
return InkWell(
|
|
||||||
onTap: onTap,
|
|
||||||
borderRadius: BorderRadius.circular(12),
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Icon(
|
|
||||||
icon,
|
|
||||||
color: isActive ? AppTheme.navyBlue : Colors.grey,
|
|
||||||
size: 26,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 2),
|
|
||||||
Text(
|
|
||||||
label,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 10,
|
|
||||||
color: isActive ? AppTheme.navyBlue : Colors.grey,
|
|
||||||
fontWeight: isActive ? FontWeight.w600 : FontWeight.normal,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Individual notification item widget
|
/// Individual notification item widget
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue