feat(App): update Finlytic Flutter app UI and blocs
This commit is contained in:
@@ -0,0 +1,177 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import '../../core/network/api_client.dart';
|
||||
import '../../core/network/signalr_service.dart';
|
||||
import '../../core/theme/app_theme.dart';
|
||||
import '../../core/theme/theme_picker_dialog.dart';
|
||||
import '../../features/auth/bloc/auth_bloc.dart';
|
||||
import '../../features/auth/models/user_model.dart';
|
||||
import '../../features/search/widgets/asset_search_dialog.dart';
|
||||
|
||||
/// Global System App Bar displaying current tab title, connection status LED, spotlight search, theme switcher, and profile menu.
|
||||
class GlobalAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||
final UserModel user;
|
||||
final ApiClient apiClient;
|
||||
final SignalRService signalRService;
|
||||
final String currentTabTitle;
|
||||
|
||||
const GlobalAppBar({
|
||||
super.key,
|
||||
required this.user,
|
||||
required this.apiClient,
|
||||
required this.signalRService,
|
||||
required this.currentTabTitle,
|
||||
});
|
||||
|
||||
@override
|
||||
Size get preferredSize => const Size.fromHeight(kToolbarHeight);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final activeTheme = AppTheme.activePreset;
|
||||
|
||||
return AppBar(
|
||||
backgroundColor: activeTheme.cardSurface,
|
||||
elevation: activeTheme.brightness == Brightness.dark ? 0 : 1,
|
||||
title: Row(
|
||||
children: [
|
||||
Icon(Icons.auto_graph_rounded, color: activeTheme.primaryColor, size: 26),
|
||||
const SizedBox(width: 10),
|
||||
Text('Finlytic Enterprise', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18, color: activeTheme.textPrimary)),
|
||||
const SizedBox(width: 12),
|
||||
Text('•', style: TextStyle(color: activeTheme.textMuted, fontSize: 16)),
|
||||
const SizedBox(width: 12),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: activeTheme.glassSurface,
|
||||
borderRadius: BorderRadius.circular(activeTheme.borderRadius * 0.6),
|
||||
border: Border.all(color: activeTheme.glassBorder),
|
||||
),
|
||||
child: Text(
|
||||
currentTabTitle,
|
||||
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 13.5, color: activeTheme.accentColor),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
// Connection Status LED Indicator
|
||||
ListenableBuilder(
|
||||
listenable: signalRService,
|
||||
builder: (context, _) {
|
||||
final isOnline = signalRService.isConnected;
|
||||
final color = isOnline ? activeTheme.primaryColor : activeTheme.accentRed;
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: color.withValues(alpha: 0.15),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: color.withValues(alpha: 0.4)),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 8,
|
||||
height: 8,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: color,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
isOnline ? 'Online' : 'Offline',
|
||||
style: TextStyle(color: color, fontSize: 11, fontWeight: FontWeight.bold),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: Icon(Icons.palette_outlined, color: activeTheme.accentColor),
|
||||
tooltip: 'Design & Theme',
|
||||
onPressed: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (_) => const ThemePickerDialog(),
|
||||
);
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(Icons.search, color: activeTheme.primaryColor),
|
||||
tooltip: 'Asset-Suche',
|
||||
onPressed: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (_) => AssetSearchDialog(apiClient: apiClient),
|
||||
);
|
||||
},
|
||||
),
|
||||
// User Profile Dropdown Menu
|
||||
PopupMenuButton<String>(
|
||||
offset: const Offset(0, 48),
|
||||
color: activeTheme.cardSurface,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(activeTheme.borderRadius),
|
||||
side: BorderSide(color: activeTheme.glassBorder),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
child: Row(
|
||||
children: [
|
||||
CircleAvatar(
|
||||
radius: 16,
|
||||
backgroundColor: activeTheme.primaryColor.withValues(alpha: 0.2),
|
||||
child: Text(
|
||||
user.email.isNotEmpty ? user.email[0].toUpperCase() : 'U',
|
||||
style: TextStyle(color: activeTheme.primaryColor, fontWeight: FontWeight.bold, fontSize: 13),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
user.fullName.isNotEmpty ? user.fullName : user.email,
|
||||
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 13, color: activeTheme.textPrimary),
|
||||
),
|
||||
Icon(Icons.arrow_drop_down, color: activeTheme.textMuted),
|
||||
],
|
||||
),
|
||||
),
|
||||
onSelected: (value) {
|
||||
if (value == 'logout') {
|
||||
context.read<AuthBloc>().add(LogoutRequested());
|
||||
} else if (value == 'theme') {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (_) => const ThemePickerDialog(),
|
||||
);
|
||||
}
|
||||
},
|
||||
itemBuilder: (context) => [
|
||||
PopupMenuItem(
|
||||
enabled: false,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(user.email, style: TextStyle(fontWeight: FontWeight.bold, color: activeTheme.textPrimary)),
|
||||
Text('Rolle: ${user.role}', style: TextStyle(fontSize: 11, color: activeTheme.textMuted)),
|
||||
Divider(color: activeTheme.glassBorder),
|
||||
],
|
||||
),
|
||||
),
|
||||
const PopupMenuItem(
|
||||
value: 'theme',
|
||||
child: Row(children: [Icon(Icons.palette_outlined, size: 18), SizedBox(width: 8), Text('Design & Themes')]),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'logout',
|
||||
child: Row(children: [Icon(Icons.logout, color: activeTheme.accentRed, size: 18), const SizedBox(width: 8), Text('Abmelden', style: TextStyle(color: activeTheme.accentRed))]),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user