UI debugging + git ignore

This commit is contained in:
mr
2024-08-22 15:46:16 +02:00
parent ceeebfc964
commit 1db9ef0794
26 changed files with 1568 additions and 302 deletions

View File

@@ -1,18 +1,28 @@
import 'package:alert_banner/exports.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:json_string/json_string.dart';
import 'package:oc_front/core/sections/header/header.dart';
import 'package:oc_front/models/logs.dart';
import 'package:oc_front/widgets/dialog/alert.dart';
class LogsWidget extends StatefulWidget {
final List<Log> items;
LogsWidget ({ Key? key, required this.items }): super(key: key);
String? level;
String search = "";
LogsWidget ({ Key? key, this.search = "", required this.items, this.level }): super(key: key);
@override LogsWidgetState createState() => LogsWidgetState();
}
class LogsWidgetState extends State<LogsWidget> {
@override Widget build(BuildContext context) {
List<LogWidget> itemRows = widget.items.map((e) => LogWidget(item: e)).toList();
return SingleChildScrollView( child: Column( children: itemRows ) );
List<LogWidget> itemRows = widget.items.where((element) => (element.message?.toLowerCase().contains(widget.search.toLowerCase()) ?? true)
&& (widget.level?.contains(element.level ?? "") ?? true) ).map((e) => LogWidget(item: e)).toList();
return Stack( children: [
SingleChildScrollView( child: itemRows.isEmpty ?
Container( height: MediaQuery.of(context).size.height - 100 - HeaderConstants.height,
child: const Center( child: Text("no log registered", style: TextStyle(color: Colors.grey, fontSize: 25 ),)))
: Column( children: [...itemRows, Container(height: 50,) ] ) ),
]);
}
}
@@ -24,23 +34,31 @@ class LogWidget extends StatefulWidget {
}
class LogWidgetState extends State<LogWidget> {
@override Widget build(BuildContext context) {
return Padding( padding: const EdgeInsets.only(top: 10, left: 30, right: 30), child: Wrap( children: [
Map<String, dynamic> map = {};
try { map = JsonString(widget.item.rawMessage?.replaceAll("\\", "") ?? "").decodedValue as Map<String, dynamic>;
} catch (e) { /* */}
return Container(
decoration: const BoxDecoration(
border: Border(bottom: BorderSide(color: Colors.white)),
),
padding: const EdgeInsets.only(top: 10, left: 30, right: 30, bottom: 10),
child: Wrap( children: [
Row( mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container( width: 10, height: 15, color: widget.item.level?.toLowerCase() == "info" ? Colors.green :
( widget.item.level?.toLowerCase() == "error" ? Colors.red : (
widget.item.level?.toLowerCase() == "warning" ? Colors.orange : Colors.blue))),
InkWell( mouseCursor: widget.item.map.isEmpty ? MouseCursor.defer : SystemMouseCursors.click, onTap: () {
if (widget.item.map.isNotEmpty ) {
InkWell( mouseCursor: map.isEmpty ? MouseCursor.defer : SystemMouseCursors.click, onTap: () {
if (map.isNotEmpty ) {
setState(() {
widget.expanded = !widget.expanded;
});
}
}, child: Container( height: 20,
}, child: SizedBox( height: 20,
child: Padding( padding: EdgeInsets.symmetric(horizontal: widget.expanded ? 0 : 5),
child: Icon( widget.expanded ? Icons.keyboard_arrow_down_outlined : Icons.arrow_forward_ios, size: widget.expanded ? 25 : 15,
color: widget.item.map.isEmpty ? Colors.grey : Colors.black, weight: widget.expanded ? 100 : 1000,)))),
color: map.isEmpty ? Colors.grey : Colors.black, weight: widget.expanded ? 100 : 1000,)))),
Padding( padding: const EdgeInsets.only(right: 10),
child: Text("${widget.item.timestamp?.toString()}",
style: const TextStyle(fontSize: 13, color: Colors.black, fontWeight: FontWeight.w500))),
@@ -57,10 +75,10 @@ class LogWidgetState extends State<LogWidget> {
decoration: BoxDecoration( color: Colors.grey,
borderRadius: BorderRadius.circular(4)),
padding: const EdgeInsets.all(10),
child: Column( children: widget.item.map.keys.map((e) =>
child: Column( children: map.keys.map((e) =>
Padding( padding: const EdgeInsets.all(2), child: Row( mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [Flexible( child:Text("$e: \"${widget.item.map[e]}\"",
children: [Flexible( child:Text("$e: \"${map[e]}\"",
style: const TextStyle(fontSize: 11, color: Colors.white))), ])
)).toList()
)) : Container(),