57377b1b21
Re-theme TasQ with a refined enterprise "Cyber/IT" identity on Material 3. Functionality is unchanged — only color/shape tokens and a few state widgets. Foundation: - Hand-tuned light + dark ColorSchemes (deep-slate surfaces, azure/teal/violet accents), tightened 12-16dp shape language, flat hairline-outlined cards. - New AppStatusColors theme extension (success/warning/danger/info/neutral, per-brightness) replacing scattered raw Colors.green/orange/red/grey so status color is consistent and legible in dark mode. - New TechChip mono primitive; StatusPill.kind; M3Card hairline variants; tightened AppSurfaces radii. Per-screen: - Tokenized status colors + radii across dashboard, tickets, tasks, IT service requests, attendance, whereabouts, network map, reports charts, auth, and shared/admin screens. Added _ticketStatusKind/_taskStatusKind/_isrStatusKind mappers so status carries meaning consistently. - Fixed white pie-slice borders for dark mode; dropped ad-hoc dialog radius overrides in favor of the theme default. Categorical palettes (leave-type icons, team color picker, distribution charts) intentionally preserved. Verified: flutter analyze lib clean; flutter build web green; visual QA in light and dark (dashboard, tickets, attendance). Co-Authored-By: claude-flow <ruv@ruv.net>
100 lines
3.1 KiB
Dart
100 lines
3.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../../theme/app_status_colors.dart';
|
|
import '../../theme/m3_motion.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:permission_handler/permission_handler.dart';
|
|
|
|
import '../../services/permission_service.dart';
|
|
|
|
/// A simple screen showing every permission the app declares in
|
|
/// [appPermissions] along with its current status. Users can tap "Grant" to
|
|
/// request a permission, or open the system settings if it has been permanently
|
|
/// denied.
|
|
class PermissionsScreen extends ConsumerStatefulWidget {
|
|
const PermissionsScreen({super.key});
|
|
|
|
@override
|
|
ConsumerState<PermissionsScreen> createState() => _PermissionsScreenState();
|
|
}
|
|
|
|
class _PermissionsScreenState extends ConsumerState<PermissionsScreen> {
|
|
late Map<Permission, PermissionStatus> _statuses;
|
|
bool _loading = true;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_refreshStatuses();
|
|
}
|
|
|
|
Future<void> _refreshStatuses() async {
|
|
setState(() => _loading = true);
|
|
final statuses = await getAllStatuses();
|
|
setState(() {
|
|
_statuses = statuses;
|
|
_loading = false;
|
|
});
|
|
}
|
|
|
|
Future<void> _request(Permission permission) async {
|
|
final status = await requestPermission(permission);
|
|
setState(() {
|
|
_statuses[permission] = status;
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
if (_loading) {
|
|
return Scaffold(
|
|
appBar: AppBar(title: const Text('Permissions')),
|
|
body: const Center(child: CircularProgressIndicator()),
|
|
);
|
|
}
|
|
|
|
return Scaffold(
|
|
appBar: AppBar(title: const Text('Permissions')),
|
|
body: ListView.separated(
|
|
padding: const EdgeInsets.all(16),
|
|
itemCount: appPermissions.length,
|
|
separatorBuilder: (context, index) => const Divider(),
|
|
itemBuilder: (context, index) {
|
|
final info = appPermissions[index];
|
|
final status = _statuses[info.permission];
|
|
final granted = status?.isGranted == true;
|
|
final permanent = status?.isPermanentlyDenied == true;
|
|
|
|
return ListTile(
|
|
title: Text(info.label),
|
|
subtitle: Text(status?.toString() ?? 'unknown'),
|
|
trailing: granted
|
|
? Icon(
|
|
Icons.check,
|
|
color: AppStatusColors.of(context).success.color,
|
|
)
|
|
: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
if (permanent)
|
|
TextButton(
|
|
onPressed: openAppSettings,
|
|
child: const Text('Settings'),
|
|
),
|
|
TextButton(
|
|
onPressed: () => _request(info.permission),
|
|
child: const Text('Grant'),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
},
|
|
),
|
|
floatingActionButton: M3Fab(
|
|
onPressed: _refreshStatuses,
|
|
tooltip: 'Refresh',
|
|
icon: const Icon(Icons.refresh),
|
|
),
|
|
);
|
|
}
|
|
}
|