fix: improve button layout and event log readability

This commit is contained in:
fiatcode 2026-04-30 15:56:16 +07:00
parent 02040081ce
commit c781fc5079
No known key found for this signature in database
2 changed files with 165 additions and 141 deletions

View file

@ -144,16 +144,19 @@ class _MainScreenState extends State<MainScreen> with TickerProviderStateMixin {
children: [ children: [
_buildHeader(), _buildHeader(),
Expanded( Expanded(
child: Padding( child: SingleChildScrollView(
padding: const EdgeInsets.symmetric(horizontal: 20), padding: const EdgeInsets.symmetric(horizontal: 20),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
const SizedBox(height: 16), const SizedBox(height: 16),
_buildStatusCard(), _buildStatusCard(),
const SizedBox(height: 16), const SizedBox(height: 16),
_buildTrackingToggle(), _buildTrackingToggle(),
const Spacer(), const SizedBox(height: 12),
_buildActionButtons(), _buildSendButton(),
const SizedBox(height: 12),
_buildNavButtons(),
const SizedBox(height: 20), const SizedBox(height: 20),
], ],
), ),
@ -367,14 +370,9 @@ class _MainScreenState extends State<MainScreen> with TickerProviderStateMixin {
); );
} }
Widget _buildActionButtons() { Widget _buildSendButton() {
return Column( if (!_isTracking) return const SizedBox.shrink();
children: [ return SizedBox(
if (_isTracking)
Padding(
padding: const EdgeInsets.only(bottom: 12),
child: SizedBox(
width: double.infinity,
height: 44, height: 44,
child: OutlinedButton.icon( child: OutlinedButton.icon(
onPressed: () async { onPressed: () async {
@ -383,9 +381,7 @@ class _MainScreenState extends State<MainScreen> with TickerProviderStateMixin {
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
SnackBar( SnackBar(
content: Text( content: Text(
success success ? 'Location sent to server' : 'Failed — check logs',
? 'Location sent to server'
: 'Failed — check logs',
), ),
backgroundColor: const Color(0xFF1a1a1a), backgroundColor: const Color(0xFF1a1a1a),
), ),
@ -395,9 +391,7 @@ class _MainScreenState extends State<MainScreen> with TickerProviderStateMixin {
style: OutlinedButton.styleFrom( style: OutlinedButton.styleFrom(
foregroundColor: const Color(0xFF00bcd4), foregroundColor: const Color(0xFF00bcd4),
side: const BorderSide(color: Color(0xFF00bcd4), width: 1), side: const BorderSide(color: Color(0xFF00bcd4), width: 1),
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(4)),
borderRadius: BorderRadius.circular(4),
),
), ),
icon: const Icon(Icons.arrow_upward, size: 16), icon: const Icon(Icons.arrow_upward, size: 16),
label: const Text( label: const Text(
@ -409,9 +403,11 @@ class _MainScreenState extends State<MainScreen> with TickerProviderStateMixin {
), ),
), ),
), ),
), );
), }
Row(
Widget _buildNavButtons() {
return Row(
children: [ children: [
Expanded( Expanded(
child: _buildNavButton( child: _buildNavButton(
@ -435,8 +431,6 @@ class _MainScreenState extends State<MainScreen> with TickerProviderStateMixin {
), ),
), ),
], ],
),
],
); );
} }

View file

@ -102,21 +102,46 @@ class _StatusScreenState extends State<StatusScreen> {
appBar: AppBar( appBar: AppBar(
backgroundColor: const Color(0xFF161616), backgroundColor: const Color(0xFF161616),
elevation: 0, elevation: 0,
title: Row( leading: IconButton(
icon: const Icon(
Icons.arrow_back,
color: Color(0xFF9e9e9e),
size: 20,
),
onPressed: () => Navigator.pop(context),
),
actions: [
IconButton(
icon: const Icon(Icons.refresh, color: Color(0xFF616161), size: 20),
onPressed: _loadLogs,
),
],
bottom: PreferredSize(
preferredSize: const Size.fromHeight(60),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
const Icon(Icons.terminal, color: Color(0xFF00bcd4), size: 18), Padding(
const SizedBox(width: 10), padding: const EdgeInsets.only(left: 16, top: 8),
child: Row(
children: [
const Icon(
Icons.terminal,
color: Color(0xFF00bcd4),
size: 16,
),
const SizedBox(width: 8),
const Text( const Text(
'EVENT LOG', 'EVENT LOG',
style: TextStyle( style: TextStyle(
fontFamily: 'monospace', fontFamily: 'monospace',
fontSize: 14, fontSize: 13,
fontWeight: FontWeight.w700, fontWeight: FontWeight.w700,
letterSpacing: 2, letterSpacing: 2,
color: Color(0xFFe0e0e0), color: Color(0xFFe0e0e0),
), ),
), ),
const Spacer(), const SizedBox(width: 16),
_buildFilterChip('ALL', null), _buildFilterChip('ALL', null),
const SizedBox(width: 6), const SizedBox(width: 6),
_buildFilterChip('LOG', 'LOCATION'), _buildFilterChip('LOG', 'LOCATION'),
@ -126,15 +151,10 @@ class _StatusScreenState extends State<StatusScreen> {
_buildFilterChip('ERR', 'ERROR'), _buildFilterChip('ERR', 'ERROR'),
], ],
), ),
actions: [
IconButton(
icon: const Icon(Icons.refresh, color: Color(0xFF616161), size: 20),
onPressed: _loadLogs,
), ),
Container(height: 1, color: const Color(0xFF2a2a2a)),
], ],
bottom: PreferredSize( ),
preferredSize: const Size.fromHeight(1),
child: Container(height: 1, color: const Color(0xFF2a2a2a)),
), ),
), ),
body: _filteredLogs.isEmpty body: _filteredLogs.isEmpty
@ -142,10 +162,10 @@ class _StatusScreenState extends State<StatusScreen> {
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Icon( const Icon(
Icons.inbox_outlined, Icons.inbox_outlined,
size: 48, size: 48,
color: const Color(0xFF2a2a2a), color: Color(0xFF2a2a2a),
), ),
const SizedBox(height: 16), const SizedBox(height: 16),
Text( Text(
@ -176,7 +196,7 @@ class _StatusScreenState extends State<StatusScreen> {
itemCount: _filteredLogs.length, itemCount: _filteredLogs.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
final log = _filteredLogs[index]; final log = _filteredLogs[index];
return _buildLogEntry(log); return _buildLogEntry(log, index);
}, },
), ),
); );
@ -216,7 +236,7 @@ class _StatusScreenState extends State<StatusScreen> {
); );
} }
Widget _buildLogEntry(Map<String, dynamic> log) { Widget _buildLogEntry(Map<String, dynamic> log, int index) {
final time = _formatTimestamp(log['timestamp'] as int? ?? 0); final time = _formatTimestamp(log['timestamp'] as int? ?? 0);
final type = log['eventType'] as String? ?? 'UNKNOWN'; final type = log['eventType'] as String? ?? 'UNKNOWN';
final msg = log['message'] as String? ?? ''; final msg = log['message'] as String? ?? '';
@ -224,13 +244,17 @@ class _StatusScreenState extends State<StatusScreen> {
final icon = _getLogIcon(type); final icon = _getLogIcon(type);
return Padding( return Padding(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 2), padding: EdgeInsets.only(
child: Row( left: 12,
right: 12,
top: index == 0 ? 6 : 8,
bottom: 6,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
SizedBox( // Line 1: timestamp
width: 100, Text(
child: Text(
time, time,
style: const TextStyle( style: const TextStyle(
fontFamily: 'monospace', fontFamily: 'monospace',
@ -238,19 +262,23 @@ class _StatusScreenState extends State<StatusScreen> {
color: Color(0xFF546e7a), color: Color(0xFF546e7a),
), ),
), ),
), const SizedBox(height: 4),
// Line 2: type badge + icon + message
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container( Container(
width: 20, width: 18,
height: 20, height: 18,
decoration: BoxDecoration( decoration: BoxDecoration(
color: color.withOpacity(0.15), color: color.withOpacity(0.15),
borderRadius: BorderRadius.circular(3), borderRadius: BorderRadius.circular(3),
), ),
child: Icon(icon, size: 12, color: color), child: Icon(icon, size: 11, color: color),
), ),
const SizedBox(width: 8), const SizedBox(width: 7),
Container( Container(
padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 1), padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 2),
decoration: BoxDecoration( decoration: BoxDecoration(
color: color.withOpacity(0.1), color: color.withOpacity(0.1),
borderRadius: BorderRadius.circular(2), borderRadius: BorderRadius.circular(2),
@ -279,6 +307,8 @@ class _StatusScreenState extends State<StatusScreen> {
), ),
], ],
), ),
],
),
); );
} }
} }