refactor: Move widgets to lib
This commit is contained in:
parent
3a200a98d8
commit
c8827ae1b2
86 changed files with 136 additions and 136 deletions
65
lib/widgets/log_view.dart
Normal file
65
lib/widgets/log_view.dart
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class LogViewer extends StatefulWidget {
|
||||
@override
|
||||
_LogViewerState createState() => _LogViewerState();
|
||||
}
|
||||
|
||||
class _LogViewerState extends State<LogViewer> {
|
||||
Level logLevel = Level.debug;
|
||||
double fontSize = 14;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final outputEvents = Logs()
|
||||
.outputEvents
|
||||
.where((e) => e.level.index >= logLevel.index)
|
||||
.toList();
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.black,
|
||||
appBar: AppBar(
|
||||
title: Text(logLevel.toString()),
|
||||
leading: BackButton(),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: Icon(Icons.zoom_in_outlined),
|
||||
onPressed: () => setState(() => fontSize++),
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(Icons.zoom_out_outlined),
|
||||
onPressed: () => setState(() => fontSize--),
|
||||
),
|
||||
PopupMenuButton<Level>(
|
||||
itemBuilder: (context) => Level.values
|
||||
.map((level) => PopupMenuItem(
|
||||
value: level,
|
||||
child: Text(level.toString()),
|
||||
))
|
||||
.toList(),
|
||||
onSelected: (Level level) => setState(() => logLevel = level),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: ListView.builder(
|
||||
itemCount: outputEvents.length,
|
||||
itemBuilder: (context, i) => SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Text(outputEvents[i].toDisplayString()),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension on LogEvent {
|
||||
String toDisplayString() {
|
||||
var str = '# $title';
|
||||
if (exception != null) {
|
||||
str += ' - ${exception.toString()}';
|
||||
}
|
||||
if (stackTrace != null) {
|
||||
str += '\n${stackTrace.toString()}';
|
||||
}
|
||||
return str;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue