Major UI overhaul
This commit is contained in:
@@ -13,7 +13,10 @@ import '../../providers/profile_provider.dart';
|
||||
import '../../providers/tasks_provider.dart';
|
||||
import '../../providers/tickets_provider.dart';
|
||||
import '../../providers/typing_provider.dart';
|
||||
import '../../widgets/app_breakpoints.dart';
|
||||
import '../../widgets/mono_text.dart';
|
||||
import '../../widgets/responsive_body.dart';
|
||||
import '../../widgets/status_pill.dart';
|
||||
import '../../widgets/task_assignment_section.dart';
|
||||
import '../../widgets/typing_dots.dart';
|
||||
|
||||
@@ -80,248 +83,326 @@ class _TicketDetailScreenState extends ConsumerState<TicketDetailScreen> {
|
||||
: ticket?.respondedAt;
|
||||
|
||||
return ResponsiveBody(
|
||||
child: Column(
|
||||
children: [
|
||||
if (ticket != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
if (ticket == null) {
|
||||
return const Center(child: Text('Ticket not found.'));
|
||||
}
|
||||
|
||||
final isWide = constraints.maxWidth >= AppBreakpoints.desktop;
|
||||
final detailsContent = Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Align(
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
ticket.subject,
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(
|
||||
context,
|
||||
).textTheme.titleLarge?.copyWith(fontWeight: FontWeight.w700),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
Align(
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
_filedByLabel(profilesAsync, ticket),
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Wrap(
|
||||
spacing: 12,
|
||||
runSpacing: 8,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
children: [
|
||||
Align(
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
ticket.subject,
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
||||
fontWeight: FontWeight.w700,
|
||||
_buildStatusChip(context, ref, ticket, canPromote),
|
||||
_MetaBadge(
|
||||
label: 'Office',
|
||||
value: _officeLabel(officesAsync, ticket),
|
||||
),
|
||||
_MetaBadge(
|
||||
label: 'Ticket ID',
|
||||
value: ticket.id,
|
||||
isMono: true,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Text(ticket.description),
|
||||
const SizedBox(height: 12),
|
||||
_buildTatRow(context, ticket, effectiveRespondedAt),
|
||||
if (taskForTicket != null) ...[
|
||||
const SizedBox(height: 16),
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: TaskAssignmentSection(
|
||||
taskId: taskForTicket.id,
|
||||
canAssign: showAssign,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
IconButton(
|
||||
tooltip: 'Open task',
|
||||
onPressed: () => context.go('/tasks/${taskForTicket.id}'),
|
||||
icon: const Icon(Icons.open_in_new),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
],
|
||||
);
|
||||
|
||||
final detailsCard = Card(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: SingleChildScrollView(child: detailsContent),
|
||||
),
|
||||
);
|
||||
|
||||
final messagesCard = Card(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 16, 16, 8),
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: messagesAsync.when(
|
||||
data: (messages) {
|
||||
if (messages.isEmpty) {
|
||||
return const Center(child: Text('No messages yet.'));
|
||||
}
|
||||
final profileById = {
|
||||
for (final profile in profilesAsync.valueOrNull ?? [])
|
||||
profile.id: profile,
|
||||
};
|
||||
return ListView.builder(
|
||||
reverse: true,
|
||||
padding: const EdgeInsets.fromLTRB(0, 16, 0, 72),
|
||||
itemCount: messages.length,
|
||||
itemBuilder: (context, index) {
|
||||
final message = messages[index];
|
||||
final currentUserId =
|
||||
Supabase.instance.client.auth.currentUser?.id;
|
||||
final isMe =
|
||||
currentUserId != null &&
|
||||
message.senderId == currentUserId;
|
||||
final senderName = message.senderId == null
|
||||
? 'System'
|
||||
: profileById[message.senderId]?.fullName ??
|
||||
message.senderId!;
|
||||
final bubbleColor = isMe
|
||||
? Theme.of(context).colorScheme.primaryContainer
|
||||
: Theme.of(
|
||||
context,
|
||||
).colorScheme.surfaceContainerHighest;
|
||||
final textColor = isMe
|
||||
? Theme.of(
|
||||
context,
|
||||
).colorScheme.onPrimaryContainer
|
||||
: Theme.of(context).colorScheme.onSurface;
|
||||
|
||||
return Align(
|
||||
alignment: isMe
|
||||
? Alignment.centerRight
|
||||
: Alignment.centerLeft,
|
||||
child: Column(
|
||||
crossAxisAlignment: isMe
|
||||
? CrossAxisAlignment.end
|
||||
: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (!isMe)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 4),
|
||||
child: Text(
|
||||
senderName,
|
||||
style: Theme.of(
|
||||
context,
|
||||
).textTheme.labelSmall,
|
||||
),
|
||||
),
|
||||
Container(
|
||||
margin: const EdgeInsets.only(bottom: 12),
|
||||
padding: const EdgeInsets.all(12),
|
||||
constraints: const BoxConstraints(
|
||||
maxWidth: 520,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: bubbleColor,
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: const Radius.circular(16),
|
||||
topRight: const Radius.circular(16),
|
||||
bottomLeft: Radius.circular(
|
||||
isMe ? 16 : 4,
|
||||
),
|
||||
bottomRight: Radius.circular(
|
||||
isMe ? 4 : 16,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: _buildMentionText(
|
||||
message.content,
|
||||
textColor,
|
||||
profilesAsync.valueOrNull ?? [],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
loading: () =>
|
||||
const Center(child: CircularProgressIndicator()),
|
||||
error: (error, _) => Center(
|
||||
child: Text('Failed to load messages: $error'),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
Align(
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
_filedByLabel(profilesAsync, ticket),
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Wrap(
|
||||
spacing: 12,
|
||||
runSpacing: 8,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
children: [
|
||||
_buildStatusChip(context, ref, ticket, canPromote),
|
||||
Text('Office: ${_officeLabel(officesAsync, ticket)}'),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Text(ticket.description),
|
||||
const SizedBox(height: 12),
|
||||
_buildTatRow(context, ticket, effectiveRespondedAt),
|
||||
if (taskForTicket != null) ...[
|
||||
const SizedBox(height: 16),
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: TaskAssignmentSection(
|
||||
taskId: taskForTicket.id,
|
||||
canAssign: showAssign,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
IconButton(
|
||||
tooltip: 'Open task',
|
||||
onPressed: () =>
|
||||
context.go('/tasks/${taskForTicket.id}'),
|
||||
icon: const Icon(Icons.open_in_new),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
const Divider(height: 1),
|
||||
Expanded(
|
||||
child: messagesAsync.when(
|
||||
data: (messages) {
|
||||
if (messages.isEmpty) {
|
||||
return const Center(child: Text('No messages yet.'));
|
||||
}
|
||||
final profileById = {
|
||||
for (final profile in profilesAsync.valueOrNull ?? [])
|
||||
profile.id: profile,
|
||||
};
|
||||
return ListView.builder(
|
||||
reverse: true,
|
||||
padding: const EdgeInsets.fromLTRB(0, 16, 0, 72),
|
||||
itemCount: messages.length,
|
||||
itemBuilder: (context, index) {
|
||||
final message = messages[index];
|
||||
final currentUserId =
|
||||
Supabase.instance.client.auth.currentUser?.id;
|
||||
final isMe =
|
||||
currentUserId != null &&
|
||||
message.senderId == currentUserId;
|
||||
final senderName = message.senderId == null
|
||||
? 'System'
|
||||
: profileById[message.senderId]?.fullName ??
|
||||
message.senderId!;
|
||||
final bubbleColor = isMe
|
||||
? Theme.of(context).colorScheme.primaryContainer
|
||||
: Theme.of(context).colorScheme.surfaceContainerHighest;
|
||||
final textColor = isMe
|
||||
? Theme.of(context).colorScheme.onPrimaryContainer
|
||||
: Theme.of(context).colorScheme.onSurface;
|
||||
|
||||
return Align(
|
||||
alignment: isMe
|
||||
? Alignment.centerRight
|
||||
: Alignment.centerLeft,
|
||||
SafeArea(
|
||||
top: false,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(0, 8, 0, 12),
|
||||
child: Column(
|
||||
crossAxisAlignment: isMe
|
||||
? CrossAxisAlignment.end
|
||||
: CrossAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (!isMe)
|
||||
if (typingState.userIds.isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 4),
|
||||
padding: const EdgeInsets.only(bottom: 6),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 10,
|
||||
vertical: 6,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(
|
||||
context,
|
||||
).colorScheme.surfaceContainerHighest,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
_typingLabel(
|
||||
typingState.userIds,
|
||||
profilesAsync,
|
||||
),
|
||||
style: Theme.of(
|
||||
context,
|
||||
).textTheme.labelSmall,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
TypingDots(
|
||||
size: 8,
|
||||
color: Theme.of(
|
||||
context,
|
||||
).colorScheme.primary,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
if (_mentionQuery != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8),
|
||||
child: _buildMentionList(profilesAsync),
|
||||
),
|
||||
if (!canSendMessages)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8),
|
||||
child: Text(
|
||||
senderName,
|
||||
style: Theme.of(context).textTheme.labelSmall,
|
||||
'Messaging is disabled for closed tickets.',
|
||||
style: Theme.of(context).textTheme.labelMedium,
|
||||
),
|
||||
),
|
||||
Container(
|
||||
margin: const EdgeInsets.only(bottom: 12),
|
||||
padding: const EdgeInsets.all(12),
|
||||
constraints: const BoxConstraints(maxWidth: 520),
|
||||
decoration: BoxDecoration(
|
||||
color: bubbleColor,
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: const Radius.circular(16),
|
||||
topRight: const Radius.circular(16),
|
||||
bottomLeft: Radius.circular(isMe ? 16 : 4),
|
||||
bottomRight: Radius.circular(isMe ? 4 : 16),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextField(
|
||||
controller: _messageController,
|
||||
decoration: const InputDecoration(
|
||||
hintText: 'Message...',
|
||||
),
|
||||
enabled: canSendMessages,
|
||||
textInputAction: TextInputAction.send,
|
||||
onChanged: canSendMessages
|
||||
? (_) => _handleComposerChanged(
|
||||
profilesAsync.valueOrNull ?? [],
|
||||
Supabase
|
||||
.instance
|
||||
.client
|
||||
.auth
|
||||
.currentUser
|
||||
?.id,
|
||||
canSendMessages,
|
||||
)
|
||||
: null,
|
||||
onSubmitted: canSendMessages
|
||||
? (_) => _handleSendMessage(
|
||||
ref,
|
||||
profilesAsync.valueOrNull ?? [],
|
||||
Supabase
|
||||
.instance
|
||||
.client
|
||||
.auth
|
||||
.currentUser
|
||||
?.id,
|
||||
canSendMessages,
|
||||
)
|
||||
: null,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: _buildMentionText(
|
||||
message.content,
|
||||
textColor,
|
||||
profilesAsync.valueOrNull ?? [],
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
IconButton(
|
||||
tooltip: 'Send',
|
||||
onPressed: canSendMessages
|
||||
? () => _handleSendMessage(
|
||||
ref,
|
||||
profilesAsync.valueOrNull ?? [],
|
||||
Supabase
|
||||
.instance
|
||||
.client
|
||||
.auth
|
||||
.currentUser
|
||||
?.id,
|
||||
canSendMessages,
|
||||
)
|
||||
: null,
|
||||
icon: const Icon(Icons.send),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
loading: () => const Center(child: CircularProgressIndicator()),
|
||||
error: (error, _) =>
|
||||
Center(child: Text('Failed to load messages: $error')),
|
||||
),
|
||||
),
|
||||
SafeArea(
|
||||
top: false,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(0, 8, 0, 12),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (typingState.userIds.isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 6),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 10,
|
||||
vertical: 6,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(
|
||||
context,
|
||||
).colorScheme.surfaceContainerHighest,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
_typingLabel(typingState.userIds, profilesAsync),
|
||||
style: Theme.of(context).textTheme.labelSmall,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
TypingDots(
|
||||
size: 8,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
if (_mentionQuery != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8),
|
||||
child: _buildMentionList(profilesAsync),
|
||||
),
|
||||
if (!canSendMessages)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8),
|
||||
child: Text(
|
||||
'Messaging is disabled for closed tickets.',
|
||||
style: Theme.of(context).textTheme.labelMedium,
|
||||
),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextField(
|
||||
controller: _messageController,
|
||||
decoration: const InputDecoration(
|
||||
hintText: 'Message...',
|
||||
),
|
||||
enabled: canSendMessages,
|
||||
textInputAction: TextInputAction.send,
|
||||
onChanged: canSendMessages
|
||||
? (_) => _handleComposerChanged(
|
||||
profilesAsync.valueOrNull ?? [],
|
||||
Supabase.instance.client.auth.currentUser?.id,
|
||||
canSendMessages,
|
||||
)
|
||||
: null,
|
||||
onSubmitted: canSendMessages
|
||||
? (_) => _handleSendMessage(
|
||||
ref,
|
||||
profilesAsync.valueOrNull ?? [],
|
||||
Supabase.instance.client.auth.currentUser?.id,
|
||||
canSendMessages,
|
||||
)
|
||||
: null,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
IconButton(
|
||||
tooltip: 'Send',
|
||||
onPressed: canSendMessages
|
||||
? () => _handleSendMessage(
|
||||
ref,
|
||||
profilesAsync.valueOrNull ?? [],
|
||||
Supabase.instance.client.auth.currentUser?.id,
|
||||
canSendMessages,
|
||||
)
|
||||
: null,
|
||||
icon: const Icon(Icons.send),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
if (isWide) {
|
||||
return Row(
|
||||
children: [
|
||||
Expanded(flex: 2, child: detailsCard),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(flex: 3, child: messagesCard),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
detailsCard,
|
||||
const SizedBox(height: 12),
|
||||
Expanded(child: messagesCard),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -778,13 +859,9 @@ class _TicketDetailScreenState extends ConsumerState<TicketDetailScreen> {
|
||||
bool canPromote,
|
||||
) {
|
||||
final isLocked = ticket.status == 'promoted' || ticket.status == 'closed';
|
||||
final chip = Chip(
|
||||
label: Text(_statusLabel(ticket.status)),
|
||||
backgroundColor: _statusColor(context, ticket.status),
|
||||
labelStyle: TextStyle(
|
||||
color: _statusTextColor(context, ticket.status),
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
final chip = StatusPill(
|
||||
label: _statusLabel(ticket.status),
|
||||
isEmphasized: ticket.status != 'pending',
|
||||
);
|
||||
|
||||
if (isLocked) {
|
||||
@@ -834,23 +911,39 @@ class _TicketDetailScreenState extends ConsumerState<TicketDetailScreen> {
|
||||
bool _canAssignStaff(String role) {
|
||||
return role == 'admin' || role == 'dispatcher' || role == 'it_staff';
|
||||
}
|
||||
}
|
||||
|
||||
Color _statusColor(BuildContext context, String status) {
|
||||
return switch (status) {
|
||||
'pending' => Colors.amber.shade300,
|
||||
'promoted' => Colors.blue.shade300,
|
||||
'closed' => Colors.green.shade300,
|
||||
_ => Theme.of(context).colorScheme.surfaceContainerHighest,
|
||||
};
|
||||
}
|
||||
class _MetaBadge extends StatelessWidget {
|
||||
const _MetaBadge({required this.label, required this.value, this.isMono});
|
||||
|
||||
Color _statusTextColor(BuildContext context, String status) {
|
||||
return switch (status) {
|
||||
'pending' => Colors.brown.shade900,
|
||||
'promoted' => Colors.blue.shade900,
|
||||
'closed' => Colors.green.shade900,
|
||||
_ => Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
};
|
||||
final String label;
|
||||
final String value;
|
||||
final bool? isMono;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final border = Theme.of(context).colorScheme.outlineVariant;
|
||||
final background = Theme.of(context).colorScheme.surfaceContainerLow;
|
||||
final textStyle = Theme.of(context).textTheme.labelSmall;
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||
decoration: BoxDecoration(
|
||||
color: background,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: border),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(label, style: textStyle),
|
||||
const SizedBox(width: 6),
|
||||
if (isMono == true)
|
||||
MonoText(value, style: textStyle)
|
||||
else
|
||||
Text(value, style: textStyle),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user