Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions mobile/android/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
ndkVersion = flutter.ndkVersion

compileOptions {
sourceCompatibility = JavaVersion.VERSION_25
targetCompatibility = JavaVersion.VERSION_25
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

defaultConfig {
Expand Down Expand Up @@ -39,7 +39,7 @@ android {

kotlin {
compilerOptions {
jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_25
jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17
}
}

Expand Down
83 changes: 47 additions & 36 deletions mobile/lib/pages/chat_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,46 +61,57 @@ class _ChatPageState extends State<ChatPage> {
name: widget.displayName,
status: _getPresenceStatusText(chatState),
),
body: chatState.activeChat.isEmpty
? const Center(
child: Text(
"No messages yet",
style: TextStyle(color: Colors.grey, fontSize: 14),
),
)
: ListView.builder(
controller: _scrollController,
padding: const EdgeInsets.only(
top: 120,
bottom: 100,
left: 16,
right: 16,
),
itemCount: chatState.activeChat.length,
itemBuilder: (context, index) {
final msg = chatState.activeChat[index];
body: Stack(
children: [
chatState.activeChat.isEmpty
? const Center(
child: Text(
"No messages yet",
style: TextStyle(color: Colors.grey, fontSize: 14),
),
)
: ListView.builder(
controller: _scrollController,
padding: const EdgeInsets.only(
top: 120,
bottom: 120,
left: 16,
right: 16,
),
itemCount: chatState.activeChat.length,
itemBuilder: (context, index) {
final msg = chatState.activeChat[index];

final String cleanSenderId = msg.senderId.trim().toLowerCase();
final String cleanPeerId = widget.chatUserId
.trim()
.toLowerCase();
final String cleanSenderId = msg.senderId
.trim()
.toLowerCase();
final String cleanPeerId = widget.chatUserId
.trim()
.toLowerCase();

final bool isMe =
cleanSenderId == 'me' ||
(cleanSenderId.isNotEmpty && cleanSenderId != cleanPeerId);
final bool isMe =
cleanSenderId == 'me' ||
(cleanSenderId.isNotEmpty &&
cleanSenderId != cleanPeerId);

return ChatBubble(
message: msg.content,
isMe: isMe,
timestamp: msg.createdAt,
isRead: msg.isRead,
);
},
return ChatBubble(
message: msg.content,
isMe: isMe,
timestamp: msg.createdAt,
isRead: msg.isRead,
);
},
),
Align(
alignment: AlignmentGeometry.bottomCenter,
child: ChatInputArea(
onSendMessage: _sendMessage,
onTypingChanged: (isTyping) => context
.read<ChatController>()
.sendTypingNotification(isTyping),
),
bottomNavigationBar: ChatInputArea(
onSendMessage: _sendMessage,
onTypingChanged: (isTyping) =>
context.read<ChatController>().sendTypingNotification(isTyping),
),
],
),
);
}
Expand Down
9 changes: 7 additions & 2 deletions mobile/lib/pages/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,12 @@ class _HomePageState extends State<HomePage> {
);
}

final Set<String> _selectedChatIds = {};

bool get _isSelectionMode => _selectedChatIds.isNotEmpty;

Widget buildHomeTab(ChatController chatState) {

return RefreshIndicator(
color: const Color(0xFF1890FF),
onRefresh: () => chatState.loadInbox(),
Expand Down Expand Up @@ -317,7 +322,8 @@ class _HomePageState extends State<HomePage> {
itemCount: chatState.inbox.length,
itemBuilder: (context, index) {
final thread = chatState.inbox[index];
return CustomChatCard(conversation: thread);
final bool isSelected = _selectedChatIds.contains(thread.chatUserId);
return CustomChatCard(conversation: thread, isSelected: isSelected);
},
),
SliverList(
Expand All @@ -327,7 +333,6 @@ class _HomePageState extends State<HomePage> {
),
);
}

@override
Widget build(BuildContext context) {
final chatState = context.watch<ChatController>();
Expand Down
114 changes: 86 additions & 28 deletions mobile/lib/widgets/chat_screen_modular_widgets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,14 @@ class _ChatInputAreaState extends State<ChatInputArea> {
super.dispose();
}

final int _charLimit = 5000; // limit
bool _isOverLimit = false;

void _handleOnChange(String text) {
setState(() {
_isOverLimit = text.length > _charLimit;
});

final hasText = text.trim().isNotEmpty;

if (hasText && !_isTyping) {
Expand Down Expand Up @@ -197,6 +204,7 @@ class _ChatInputAreaState extends State<ChatInputArea> {
}

void _submit() {
_isOverLimit = false;
final text = _controller.text.trim();
if (text.isNotEmpty) {
_typingTimer?.cancel();
Expand All @@ -214,37 +222,87 @@ class _ChatInputAreaState extends State<ChatInputArea> {
@override
Widget build(BuildContext context) {
return SafeArea(
child: Padding(
padding: const EdgeInsets.all(12.0),
child: Row(
children: [
Expanded(
child: TextField(
controller: _controller,
onChanged: _handleOnChange,
style: const TextStyle(color: Colors.black87, fontSize: 15),
decoration: InputDecoration(
hintText: "Write a message...",
hintStyle: const TextStyle(color: Colors.black38),
fillColor: const Color(0xFFF5F5F5),
filled: true,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(24),
borderSide: BorderSide.none,
),
contentPadding: const EdgeInsets.symmetric(
horizontal: 16,
vertical: 10,
bottom: false,
child: ClipRRect(
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 15, sigmaY: 15),
child: Container(
color: Colors.transparent,
padding: const EdgeInsets.symmetric(horizontal: 12.0, vertical: 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: TextField(
controller: _controller,
onChanged: _handleOnChange,
keyboardType: TextInputType.multiline,
minLines: 1,
maxLines: 5,

// 1. Set the limit
maxLength: _charLimit,
// 2. CRITICAL: This allows them to keep typing past the limit so it shows "7000/5000"
maxLengthEnforcement: .none,

style: TextStyle(
// 3. Turn the typed text red if they exceed the limit
color: _isOverLimit ? Colors.red : Colors.black87,
fontSize: 15,
),
decoration: InputDecoration(
hintText: "Write a message...",
hintStyle: const TextStyle(color: Colors.black38),

fillColor: _isOverLimit
? Colors.red.withValues(alpha: 0.1)
: const Color(0xFFF5F5F5),
filled: true,
errorText: _isOverLimit ? 'character limit exceeded' : '',
counterStyle: TextStyle(
color: _isOverLimit ? Colors.red : Colors.black54,
fontWeight: _isOverLimit
? FontWeight.bold
: FontWeight.normal,
),

border: OutlineInputBorder(
borderRadius: BorderRadius.circular(24),
borderSide: _isOverLimit
? const BorderSide(color: Colors.red, width: 1.5)
: BorderSide.none,
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(24),
borderSide: _isOverLimit
? const BorderSide(color: Colors.red, width: 2)
: BorderSide.none,
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(24),
borderSide: _isOverLimit
? const BorderSide(color: Colors.red, width: 1.5)
: BorderSide.none,
),

contentPadding: const EdgeInsets.symmetric(
horizontal: 16,
vertical: 10,
),
),
),
),
),
),
const SizedBox(width: 8),
IconButton(
icon: const Icon(Icons.send, color: Color(0xFF1890FF)),
onPressed: _submit,
const SizedBox(width: 8),
IconButton(
icon: _isOverLimit
? const Icon(Icons.not_interested)
: const Icon(Icons.send, color: Color(0xFF1890FF)),
onPressed: _isOverLimit ? null : _submit,
),
],
),
],
),
),
),
);
Expand Down
9 changes: 8 additions & 1 deletion mobile/lib/widgets/custom_cards.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,22 @@ import '../controllers/chat.dart';

class CustomChatCard extends StatelessWidget {
final Conversation conversation;
final bool isSelected;
final Function? onLongPress;
final Function? onTap;

const CustomChatCard({super.key, required this.conversation});
const CustomChatCard({super.key, required this.conversation, required this.isSelected, this.onLongPress, this.onTap});

@override
Widget build(BuildContext context) {
final String timeLabel =
"${conversation.lastMessageTime.hour.toString().padLeft(2, '0')}:${conversation.lastMessageTime.minute.toString().padLeft(2, '0')}";

return InkWell(
onLongPress: () {

},

onTap: () async {
final controller = context.read<ChatController>();
await controller.openChat(conversation.chatUserId);
Expand Down