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: [
_buildHeader(),
Expanded(
child: Padding(
child: SingleChildScrollView(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const SizedBox(height: 16),
_buildStatusCard(),
const SizedBox(height: 16),
_buildTrackingToggle(),
const Spacer(),
_buildActionButtons(),
const SizedBox(height: 12),
_buildSendButton(),
const SizedBox(height: 12),
_buildNavButtons(),
const SizedBox(height: 20),
],
),
@ -367,14 +370,9 @@ class _MainScreenState extends State<MainScreen> with TickerProviderStateMixin {
);
}
Widget _buildActionButtons() {
return Column(
children: [
if (_isTracking)
Padding(
padding: const EdgeInsets.only(bottom: 12),
child: SizedBox(
width: double.infinity,
Widget _buildSendButton() {
if (!_isTracking) return const SizedBox.shrink();
return SizedBox(
height: 44,
child: OutlinedButton.icon(
onPressed: () async {
@ -383,9 +381,7 @@ class _MainScreenState extends State<MainScreen> with TickerProviderStateMixin {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
success
? 'Location sent to server'
: 'Failed — check logs',
success ? 'Location sent to server' : 'Failed — check logs',
),
backgroundColor: const Color(0xFF1a1a1a),
),
@ -395,9 +391,7 @@ class _MainScreenState extends State<MainScreen> with TickerProviderStateMixin {
style: OutlinedButton.styleFrom(
foregroundColor: const Color(0xFF00bcd4),
side: const BorderSide(color: Color(0xFF00bcd4), width: 1),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(4),
),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(4)),
),
icon: const Icon(Icons.arrow_upward, size: 16),
label: const Text(
@ -409,9 +403,11 @@ class _MainScreenState extends State<MainScreen> with TickerProviderStateMixin {
),
),
),
),
),
Row(
);
}
Widget _buildNavButtons() {
return Row(
children: [
Expanded(
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(
backgroundColor: const Color(0xFF161616),
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: [
const Icon(Icons.terminal, color: Color(0xFF00bcd4), size: 18),
const SizedBox(width: 10),
Padding(
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(
'EVENT LOG',
style: TextStyle(
fontFamily: 'monospace',
fontSize: 14,
fontSize: 13,
fontWeight: FontWeight.w700,
letterSpacing: 2,
color: Color(0xFFe0e0e0),
),
),
const Spacer(),
const SizedBox(width: 16),
_buildFilterChip('ALL', null),
const SizedBox(width: 6),
_buildFilterChip('LOG', 'LOCATION'),
@ -126,15 +151,10 @@ class _StatusScreenState extends State<StatusScreen> {
_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
@ -142,10 +162,10 @@ class _StatusScreenState extends State<StatusScreen> {
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
const Icon(
Icons.inbox_outlined,
size: 48,
color: const Color(0xFF2a2a2a),
color: Color(0xFF2a2a2a),
),
const SizedBox(height: 16),
Text(
@ -176,7 +196,7 @@ class _StatusScreenState extends State<StatusScreen> {
itemCount: _filteredLogs.length,
itemBuilder: (context, 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 type = log['eventType'] as String? ?? 'UNKNOWN';
final msg = log['message'] as String? ?? '';
@ -224,13 +244,17 @@ class _StatusScreenState extends State<StatusScreen> {
final icon = _getLogIcon(type);
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 2),
child: Row(
padding: EdgeInsets.only(
left: 12,
right: 12,
top: index == 0 ? 6 : 8,
bottom: 6,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
width: 100,
child: Text(
// Line 1: timestamp
Text(
time,
style: const TextStyle(
fontFamily: 'monospace',
@ -238,19 +262,23 @@ class _StatusScreenState extends State<StatusScreen> {
color: Color(0xFF546e7a),
),
),
),
const SizedBox(height: 4),
// Line 2: type badge + icon + message
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
width: 20,
height: 20,
width: 18,
height: 18,
decoration: BoxDecoration(
color: color.withOpacity(0.15),
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(
padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 1),
padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 2),
decoration: BoxDecoration(
color: color.withOpacity(0.1),
borderRadius: BorderRadius.circular(2),
@ -279,6 +307,8 @@ class _StatusScreenState extends State<StatusScreen> {
),
],
),
],
),
);
}
}