feat: Implement agent network management and refactor app navigation with a new AppShell component.

This commit is contained in:
pradeepkumar
2026-03-08 16:05:08 +05:30
parent b4d22df8ba
commit 0362d7cfe0
25 changed files with 1545 additions and 1423 deletions

View File

@@ -1201,56 +1201,57 @@ class _ChatScreenState extends ConsumerState<ChatScreen> {
// Text input pill with send icon inside
Expanded(
child: Container(
child: SizedBox(
height: 44,
margin: const EdgeInsets.only(left: 4),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(22),
border: Border.all(
child: TextField(
controller: _messageController,
focusNode: _messageFocusNode,
textInputAction: TextInputAction.send,
onSubmitted: (_) => _sendMessage(),
style: const TextStyle(
fontFamily: 'Fractul',
fontSize: 14,
fontWeight: FontWeight.w500,
color: AppColors.primaryDark,
width: 1.5,
),
),
clipBehavior: Clip.antiAlias,
child: Row(
children: [
Expanded(
child: TextField(
controller: _messageController,
focusNode: _messageFocusNode,
textInputAction: TextInputAction.send,
onSubmitted: (_) => _sendMessage(),
style: const TextStyle(
fontFamily: 'Fractul',
fontSize: 14,
fontWeight: FontWeight.w500,
color: AppColors.primaryDark,
),
decoration: const InputDecoration(
hintText: 'Write a Message',
hintStyle: TextStyle(
fontFamily: 'Fractul',
fontSize: 14,
fontWeight: FontWeight.w500,
color: AppColors.primaryDark,
),
contentPadding: EdgeInsets.symmetric(
horizontal: 18,
vertical: 10,
),
border: InputBorder.none,
enabledBorder: InputBorder.none,
focusedBorder: InputBorder.none,
),
decoration: InputDecoration(
hintText: 'Write a Message',
hintStyle: const TextStyle(
fontFamily: 'Fractul',
fontSize: 14,
fontWeight: FontWeight.w500,
color: AppColors.primaryDark,
),
contentPadding: const EdgeInsets.symmetric(
horizontal: 18,
vertical: 12,
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(22),
borderSide: const BorderSide(
color: AppColors.primaryDark,
width: 1.5,
),
),
// Send arrow inside the pill
GestureDetector(
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(22),
borderSide: const BorderSide(
color: AppColors.primaryDark,
width: 1.5,
),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(22),
borderSide: const BorderSide(
color: AppColors.primaryDark,
width: 1.5,
),
),
suffixIcon: GestureDetector(
onTap: _sendMessage,
behavior: HitTestBehavior.opaque,
child: Padding(
padding: const EdgeInsets.only(right: 14),
child: const Padding(
padding: EdgeInsets.only(right: 4),
child: Icon(
Icons.send,
size: 20,
@@ -1258,7 +1259,11 @@ class _ChatScreenState extends ConsumerState<ChatScreen> {
),
),
),
],
suffixIconConstraints: const BoxConstraints(
minWidth: 40,
minHeight: 20,
),
),
),
),
),

View File

@@ -62,107 +62,159 @@ class _ConversationsScreenState extends ConsumerState<ConversationsScreen> {
// -- Header with back arrow, search, icons --
Widget _buildHeader() {
return Container(
return Padding(
padding: const EdgeInsets.fromLTRB(16, 8, 16, 12),
child: Container(
height: 48,
decoration: BoxDecoration(
border: Border.all(
color: AppColors.primaryDark.withValues(alpha: 0.2),
width: 1,
),
borderRadius: BorderRadius.circular(15),
),
child: Row(
children: [
// Back arrow
GestureDetector(
onTap: () {
if (_isSearchActive) {
setState(() {
_isSearchActive = false;
_searchController.clear();
});
} else {
context.go('/home');
}
},
behavior: HitTestBehavior.opaque,
child: const Padding(
padding: EdgeInsets.symmetric(horizontal: 14),
child: Icon(
Icons.arrow_back_ios_new,
size: 16,
color: AppColors.primaryDark,
),
child: Row(
children: [
// Back arrow (outside the search box)
GestureDetector(
onTap: () {
if (_isSearchActive) {
setState(() {
_isSearchActive = false;
_searchController.clear();
});
} else {
context.go('/home');
}
},
behavior: HitTestBehavior.opaque,
child: const Padding(
padding: EdgeInsets.only(right: 10),
child: Icon(
Icons.arrow_back_ios_new,
size: 16,
color: AppColors.primaryDark,
),
),
// Search text or input
Expanded(
child: _isSearchActive
? TextField(
controller: _searchController,
autofocus: true,
style: const TextStyle(
fontFamily: 'Fractul',
fontSize: 15,
fontWeight: FontWeight.w600,
color: AppColors.primaryDark,
),
decoration: const InputDecoration(
hintText: 'Search Messages',
hintStyle: TextStyle(
fontFamily: 'Fractul',
fontSize: 15,
fontWeight: FontWeight.w600,
color: AppColors.hintText,
),
border: InputBorder.none,
contentPadding: EdgeInsets.zero,
isDense: true,
),
)
: GestureDetector(
onTap: () => setState(() => _isSearchActive = true),
child: const Text(
'Search Messages',
style: TextStyle(
),
// Search box with border
Expanded(
child: GestureDetector(
onTap: () {
if (!_isSearchActive) {
setState(() => _isSearchActive = true);
}
},
child: SizedBox(
height: 44,
child: _isSearchActive
? TextField(
controller: _searchController,
autofocus: true,
style: const TextStyle(
fontFamily: 'Fractul',
fontSize: 15,
fontWeight: FontWeight.w600,
color: AppColors.primaryDark,
),
decoration: InputDecoration(
hintText: 'Search Messages',
hintStyle: const TextStyle(
fontFamily: 'Fractul',
fontSize: 15,
fontWeight: FontWeight.w600,
color: AppColors.hintText,
),
contentPadding: const EdgeInsets.symmetric(
horizontal: 18,
vertical: 12,
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(22),
borderSide: BorderSide(
color: AppColors.primaryDark
.withValues(alpha: 0.25),
),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(22),
borderSide: BorderSide(
color: AppColors.primaryDark
.withValues(alpha: 0.25),
),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(22),
borderSide: BorderSide(
color: AppColors.primaryDark
.withValues(alpha: 0.4),
),
),
suffixIcon: _searchController.text.isNotEmpty
? IconButton(
icon: const Icon(Icons.close, size: 18),
color: AppColors.hintText,
onPressed: () {
_searchController.clear();
setState(() {});
},
)
: null,
),
)
: Container(
alignment: Alignment.centerLeft,
decoration: BoxDecoration(
border: Border.all(
color: AppColors.primaryDark
.withValues(alpha: 0.25),
),
borderRadius: BorderRadius.circular(22),
),
padding:
const EdgeInsets.symmetric(horizontal: 18),
child: const Text(
'Search Messages',
style: TextStyle(
fontFamily: 'Fractul',
fontSize: 15,
fontWeight: FontWeight.w600,
color: AppColors.primaryDark,
),
),
),
),
),
// Search icon
GestureDetector(
onTap: () => setState(() => _isSearchActive = true),
behavior: HitTestBehavior.opaque,
child: const Padding(
padding: EdgeInsets.symmetric(horizontal: 10),
child: Icon(
Icons.search,
size: 22,
color: AppColors.primaryDark,
),
),
),
// Three dots menu
GestureDetector(
onTap: () {},
behavior: HitTestBehavior.opaque,
child: const Padding(
padding: EdgeInsets.only(right: 14, left: 2),
child: Icon(
Icons.more_horiz,
size: 22,
color: AppColors.primaryDark,
),
),
const SizedBox(width: 10),
// Search icon (outside the search box)
GestureDetector(
onTap: () {
setState(() {
if (_isSearchActive) {
_isSearchActive = false;
_searchController.clear();
} else {
_isSearchActive = true;
}
});
},
behavior: HitTestBehavior.opaque,
child: Padding(
padding: const EdgeInsets.all(4),
child: Icon(
_isSearchActive ? Icons.close : Icons.search,
size: 22,
color: AppColors.primaryDark,
),
),
],
),
),
const SizedBox(width: 8),
// Three dots menu (outside the search box)
GestureDetector(
onTap: () {},
behavior: HitTestBehavior.opaque,
child: const Padding(
padding: EdgeInsets.all(4),
child: Icon(
Icons.more_horiz,
size: 22,
color: AppColors.primaryDark,
),
),
),
],
),
);
}

View File

@@ -1,117 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:go_router/go_router.dart';
import 'package:real_estate_mobile/core/constants/app_colors.dart';
import 'package:real_estate_mobile/features/auth/presentation/providers/auth_provider.dart';
import 'package:real_estate_mobile/features/home/presentation/widgets/home_header.dart';
class MessagingShell extends ConsumerWidget {
final Widget child;
const MessagingShell({super.key, required this.child});
@override
Widget build(BuildContext context, WidgetRef ref) {
return Scaffold(
backgroundColor: Colors.white,
body: Column(
children: [
SafeArea(
bottom: false,
child: const HomeHeader(),
),
Expanded(child: child),
],
),
bottomNavigationBar: _buildBottomNavBar(context, ref),
);
}
Widget _buildBottomNavBar(BuildContext context, WidgetRef ref) {
return Container(
decoration: const BoxDecoration(
color: Colors.white,
border: Border(
top: BorderSide(color: Color(0xFFE8E8E8), width: 1),
),
),
child: SafeArea(
top: false,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
_buildNavItem(
context: context,
svgPath: 'assets/icons/nav_home_icon.svg',
fallbackIcon: Icons.home,
isSelected: false,
onTap: () => context.go('/home'),
),
_buildNavItem(
context: context,
svgPath: 'assets/icons/nav_list_icon.svg',
fallbackIcon: Icons.list,
isSelected: false,
onTap: () => context.push('/agents/search'),
),
_buildNavItem(
context: context,
svgPath: 'assets/icons/nav_messages_icon.svg',
fallbackIcon: Icons.chat_bubble,
isSelected: true,
onTap: () => context.go('/messages'),
),
_buildNavItem(
context: context,
svgPath: 'assets/icons/nav_profile_icon.svg',
fallbackIcon: Icons.person_outline,
isSelected: false,
onTap: () {
final authState = ref.read(authProvider);
if (authState.status != AuthStatus.authenticated) {
context.push('/login');
return;
}
context.push('/profile');
},
),
],
),
),
),
);
}
Widget _buildNavItem({
required BuildContext context,
required String svgPath,
required IconData fallbackIcon,
required bool isSelected,
required VoidCallback onTap,
}) {
return GestureDetector(
onTap: onTap,
behavior: HitTestBehavior.opaque,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: SvgPicture.asset(
svgPath,
width: 24,
height: 24,
colorFilter: isSelected
? const ColorFilter.mode(AppColors.primaryDark, BlendMode.srcIn)
: const ColorFilter.mode(
AppColors.accentOrange, BlendMode.srcIn),
placeholderBuilder: (_) => Icon(
fallbackIcon,
size: 24,
color: isSelected ? AppColors.primaryDark : AppColors.accentOrange,
),
),
),
);
}
}