feat: revamp UI with dark terminal aesthetic
This commit is contained in:
parent
d673f01a2d
commit
02040081ce
3 changed files with 825 additions and 201 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'bridge/location_bridge.dart';
|
||||
|
||||
class StatusScreen extends StatefulWidget {
|
||||
|
|
@ -11,10 +12,17 @@ class StatusScreen extends StatefulWidget {
|
|||
class _StatusScreenState extends State<StatusScreen> {
|
||||
List<Map<String, dynamic>> _logs = [];
|
||||
final ScrollController _scrollController = ScrollController();
|
||||
String _filter = 'ALL';
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
SystemChrome.setSystemUIOverlayStyle(
|
||||
const SystemUiOverlayStyle(
|
||||
statusBarColor: Color(0xFF0d0d0d),
|
||||
statusBarIconBrightness: Brightness.light,
|
||||
),
|
||||
);
|
||||
_loadLogs();
|
||||
}
|
||||
|
||||
|
|
@ -40,65 +48,236 @@ class _StatusScreenState extends State<StatusScreen> {
|
|||
|
||||
String _formatTimestamp(int timestamp) {
|
||||
final dt = DateTime.fromMillisecondsSinceEpoch(timestamp);
|
||||
return '${dt.hour.toString().padLeft(2, '0')}:${dt.minute.toString().padLeft(2, '0')}:${dt.second.toString().padLeft(2, '0')}';
|
||||
final ms = (dt.millisecond / 1000).toStringAsFixed(3).substring(2);
|
||||
return '${dt.hour.toString().padLeft(2, '0')}:${dt.minute.toString().padLeft(2, '0')}:${dt.second.toString().padLeft(2, '0')}.$ms';
|
||||
}
|
||||
|
||||
Color _getLogColor(String eventType) {
|
||||
switch (eventType) {
|
||||
case 'ERROR':
|
||||
return Colors.red;
|
||||
return const Color(0xFFff5252);
|
||||
case 'WARNING':
|
||||
return Colors.orange;
|
||||
return const Color(0xFFffb74d);
|
||||
case 'LOCATION':
|
||||
return Colors.green;
|
||||
return const Color(0xFF69f0ae);
|
||||
case 'SYNC':
|
||||
return Colors.cyan;
|
||||
return const Color(0xFF40c4ff);
|
||||
case 'HEARTBEAT':
|
||||
return Colors.yellow;
|
||||
return const Color(0xFFffe082);
|
||||
case 'FILTERED':
|
||||
return Colors.grey;
|
||||
return const Color(0xFF546e7a);
|
||||
default:
|
||||
return Colors.white;
|
||||
return const Color(0xFF78909c);
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildTerminalLine(Map<String, dynamic> log) {
|
||||
final time = _formatTimestamp(log['timestamp'] as int? ?? 0);
|
||||
final type = log['eventType'] as String? ?? 'UNKNOWN';
|
||||
final msg = log['message'] as String? ?? '';
|
||||
final color = _getLogColor(type);
|
||||
IconData _getLogIcon(String eventType) {
|
||||
switch (eventType) {
|
||||
case 'ERROR':
|
||||
return Icons.close;
|
||||
case 'WARNING':
|
||||
return Icons.warning;
|
||||
case 'LOCATION':
|
||||
return Icons.gps_fixed;
|
||||
case 'SYNC':
|
||||
return Icons.cloud_upload;
|
||||
case 'HEARTBEAT':
|
||||
return Icons.favorite;
|
||||
case 'FILTERED':
|
||||
return Icons.filter_alt;
|
||||
default:
|
||||
return Icons.info;
|
||||
}
|
||||
}
|
||||
|
||||
return Text(
|
||||
'[$time] $type: $msg',
|
||||
style: TextStyle(fontFamily: 'monospace', fontSize: 12, color: color),
|
||||
);
|
||||
List<Map<String, dynamic>> get _filteredLogs {
|
||||
if (_filter == 'ALL') return _logs;
|
||||
return _logs.where((l) => l['eventType'] == _filter).toList();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: const Color(0xFF0d0d0d),
|
||||
appBar: AppBar(
|
||||
title: Text('Event Log'),
|
||||
actions: [IconButton(icon: Icon(Icons.refresh), onPressed: _loadLogs)],
|
||||
),
|
||||
body: Container(
|
||||
color: Colors.black,
|
||||
child: _logs.isEmpty
|
||||
? Center(
|
||||
child: Text(
|
||||
'No logs yet. Start tracking to see logs.',
|
||||
style: TextStyle(color: Colors.grey),
|
||||
),
|
||||
)
|
||||
: ListView.builder(
|
||||
controller: _scrollController,
|
||||
padding: EdgeInsets.all(8),
|
||||
itemCount: _logs.length,
|
||||
itemBuilder: (context, index) {
|
||||
final log = _logs[index];
|
||||
return _buildTerminalLine(log);
|
||||
},
|
||||
backgroundColor: const Color(0xFF161616),
|
||||
elevation: 0,
|
||||
title: Row(
|
||||
children: [
|
||||
const Icon(Icons.terminal, color: Color(0xFF00bcd4), size: 18),
|
||||
const SizedBox(width: 10),
|
||||
const Text(
|
||||
'EVENT LOG',
|
||||
style: TextStyle(
|
||||
fontFamily: 'monospace',
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w700,
|
||||
letterSpacing: 2,
|
||||
color: Color(0xFFe0e0e0),
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
_buildFilterChip('ALL', null),
|
||||
const SizedBox(width: 6),
|
||||
_buildFilterChip('LOG', 'LOCATION'),
|
||||
const SizedBox(width: 6),
|
||||
_buildFilterChip('SYNC', 'SYNC'),
|
||||
const SizedBox(width: 6),
|
||||
_buildFilterChip('ERR', 'ERROR'),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.refresh, color: Color(0xFF616161), size: 20),
|
||||
onPressed: _loadLogs,
|
||||
),
|
||||
],
|
||||
bottom: PreferredSize(
|
||||
preferredSize: const Size.fromHeight(1),
|
||||
child: Container(height: 1, color: const Color(0xFF2a2a2a)),
|
||||
),
|
||||
),
|
||||
body: _filteredLogs.isEmpty
|
||||
? Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.inbox_outlined,
|
||||
size: 48,
|
||||
color: const Color(0xFF2a2a2a),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
_filter == 'ALL'
|
||||
? 'No events recorded'
|
||||
: 'No $_filter events',
|
||||
style: const TextStyle(
|
||||
fontFamily: 'monospace',
|
||||
fontSize: 13,
|
||||
color: Color(0xFF424242),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'Start tracking to capture events',
|
||||
style: TextStyle(
|
||||
fontFamily: 'monospace',
|
||||
fontSize: 11,
|
||||
color: const Color(0xFF424242).withOpacity(0.6),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: ListView.builder(
|
||||
controller: _scrollController,
|
||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
itemCount: _filteredLogs.length,
|
||||
itemBuilder: (context, index) {
|
||||
final log = _filteredLogs[index];
|
||||
return _buildLogEntry(log);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildFilterChip(String label, String? eventType) {
|
||||
final isSelected = _filter == (eventType ?? 'ALL');
|
||||
return GestureDetector(
|
||||
onTap: () => setState(() => _filter = eventType ?? 'ALL'),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 3),
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected
|
||||
? const Color(0xFF00bcd4).withOpacity(0.15)
|
||||
: Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(3),
|
||||
border: Border.all(
|
||||
color: isSelected
|
||||
? const Color(0xFF00bcd4).withOpacity(0.5)
|
||||
: const Color(0xFF2a2a2a),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontFamily: 'monospace',
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.w700,
|
||||
letterSpacing: 1,
|
||||
color: isSelected
|
||||
? const Color(0xFF00bcd4)
|
||||
: const Color(0xFF424242),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildLogEntry(Map<String, dynamic> log) {
|
||||
final time = _formatTimestamp(log['timestamp'] as int? ?? 0);
|
||||
final type = log['eventType'] as String? ?? 'UNKNOWN';
|
||||
final msg = log['message'] as String? ?? '';
|
||||
final color = _getLogColor(type);
|
||||
final icon = _getLogIcon(type);
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 2),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 100,
|
||||
child: Text(
|
||||
time,
|
||||
style: const TextStyle(
|
||||
fontFamily: 'monospace',
|
||||
fontSize: 10,
|
||||
color: Color(0xFF546e7a),
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: 20,
|
||||
height: 20,
|
||||
decoration: BoxDecoration(
|
||||
color: color.withOpacity(0.15),
|
||||
borderRadius: BorderRadius.circular(3),
|
||||
),
|
||||
child: Icon(icon, size: 12, color: color),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 1),
|
||||
decoration: BoxDecoration(
|
||||
color: color.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(2),
|
||||
),
|
||||
child: Text(
|
||||
type,
|
||||
style: TextStyle(
|
||||
fontFamily: 'monospace',
|
||||
fontSize: 9,
|
||||
fontWeight: FontWeight.w700,
|
||||
letterSpacing: 1,
|
||||
color: color,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Text(
|
||||
msg,
|
||||
style: const TextStyle(
|
||||
fontFamily: 'monospace',
|
||||
fontSize: 11,
|
||||
color: Color(0xFF9e9e9e),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue