fyral_comms 0.3.4
fyral_comms: ^0.3.4 copied to clipboard
Communication feature package for Fleet Glide Admin
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:fyral_comms/comms.dart';
void main() {
runApp(const CommsExampleApp());
}
/// A premium Example Application demonstrating the usage of the `comms` package.
class CommsExampleApp extends StatelessWidget {
const CommsExampleApp({super.key});
static final GoRouter _router = GoRouter(
initialLocation: '/',
routes: [
GoRoute(
path: '/',
builder: (context, state) => CommsPage(
currentUserId: 2,
onConversationSelected: (conversation) =>
context.push("/chat/${conversation.name}"),
conversations: [
CommsGroup.fromJson(const {
"id": 1,
"group_type": "topic",
"name": "General Support",
"driver_user_id": 2,
"allow_replies": true,
"status": "open",
"created_at": "2026-08-18T12:44:58.688479",
"updated_at": "2026-08-19T05:41:54.986662",
"participants": [
{
"id": 1,
"group_id": 1,
"user_id": 2,
"last_read_message_id": null,
"unread_count": 5,
"tagged_message": null,
},
],
"driver_user": {
"id": 2,
"username": "testdriver",
"email": "testdriver@fleetglide.com",
"phone": "5555551234",
"profile_pic": null,
"role_id": 2,
"is_active": true,
"role": {
"id": 2,
"name": "driver",
"description":
"Access to view assignments and update trip details",
"created_at": "2026-08-17T12:23:01.672948",
"updated_at": "2026-08-17T12:23:01.672969",
},
},
"creator": {
"id": 2,
"username": "testdriver",
"email": "testdriver@fleetglide.com",
"phone": "5555551234",
"profile_pic": null,
"role_id": 2,
"is_active": true,
"role": {
"id": 2,
"name": "driver",
"description":
"Access to view assignments and update trip details",
"created_at": "2026-08-17T12:23:01.672948",
"updated_at": "2026-08-17T12:23:01.672969",
},
},
"last_message": {
"id": 3,
"message_content": "Sample Test message",
"created_at": "2026-08-19T05:41:54.594931",
"sender": {
"id": 2,
"username": "testdriver",
"email": "testdriver@fleetglide.com",
"phone": "5555551234",
"profile_pic": null,
"role_id": 2,
"is_active": true,
"role": {
"id": 2,
"name": "driver",
"description":
"Access to view assignments and update trip details",
"created_at": "2026-08-17T12:23:01.672948",
"updated_at": "2026-08-17T12:23:01.672969",
},
},
},
}),
],
),
),
GoRoute(
path: '/chat/:title',
builder: (context, state) {
final title = state.pathParameters['title'] ?? 'Chat';
return ConversationDetailPage(
title: title,
userId: 2,
onReactionSelected: (message, reaction) {
final scaffoldMessenger = ScaffoldMessenger.of(context);
scaffoldMessenger.clearSnackBars();
scaffoldMessenger.showSnackBar(
SnackBar(
content: Text(
'Reaction "$reaction" added to message: "${message['text']}"',
),
duration: const Duration(seconds: 2),
),
);
},
);
},
),
],
);
@override
Widget build(BuildContext context) {
return MaterialApp.router(
title: 'Comms Package Example',
themeMode: ThemeMode.system,
debugShowCheckedModeBanner: false,
// Premium Light Theme
theme: ThemeData(
useMaterial3: true,
brightness: Brightness.light,
colorScheme: ColorScheme.fromSeed(
seedColor: const Color(0xFF653DAA), // Modern purple seed color
primary: const Color(0xFF653DAA),
secondary: const Color(0xFFF97316), // Vibrant orange
surface: Colors.white,
onSurface: const Color(0xFF1E293B),
),
scaffoldBackgroundColor: const Color(0xFFF8FAFC),
appBarTheme: const AppBarTheme(
backgroundColor: Colors.transparent,
elevation: 0,
centerTitle: false,
),
),
// Premium Dark Theme
darkTheme: ThemeData(
useMaterial3: true,
brightness: Brightness.dark,
colorScheme: ColorScheme.fromSeed(
seedColor: const Color(0xFF8B5CF6),
brightness: Brightness.dark,
primary: const Color(0xFFA78BFA),
secondary: const Color(0xFFFB923C),
surface: const Color(0xFF0F172A),
onSurface: const Color(0xFFF1F5F9),
),
scaffoldBackgroundColor: const Color(0xFF020617),
appBarTheme: const AppBarTheme(
backgroundColor: Colors.transparent,
elevation: 0,
centerTitle: false,
),
),
routerConfig: _router,
);
}
}