mirror of
https://bitbucket.org/myhomie/myhomie_app.git
synced 2025-12-06 09:01:20 +00:00
87 lines
2.9 KiB
Dart
87 lines
2.9 KiB
Dart
import 'package:flare_flutter/flare_actor.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:myhomie_app/Helpers/MQTTHelper.dart';
|
|
import 'package:myhomie_app/app_context.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
class DebugPage extends StatefulWidget {
|
|
DebugPage({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
_DebugPageState createState() => _DebugPageState();
|
|
}
|
|
|
|
class _DebugPageState extends State<DebugPage> {
|
|
List<String> lastMessages = [];
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final AppContext appContext = Provider.of<AppContext>(context);
|
|
String lastMessage = "test";
|
|
|
|
//lastMessage = MQTTHelper.instance.getLastMessage() == null ? "rien" : MQTTHelper.instance.getLastMessage();
|
|
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: Text("Debug"),
|
|
),
|
|
body: Center(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: <Widget>[
|
|
/*new Container(
|
|
width: 150,
|
|
height: 150,
|
|
child: FlareActor(
|
|
'assets/animations/MDLF_animation.flr',
|
|
alignment: Alignment.center,
|
|
fit: BoxFit.scaleDown,
|
|
animation: 'Rotate',
|
|
),
|
|
),*/
|
|
new Expanded(
|
|
child: new ListView.separated
|
|
(
|
|
reverse: true,
|
|
separatorBuilder: (context, index) {
|
|
return Container(
|
|
width: 50,
|
|
height: 50,
|
|
child: FlareActor(
|
|
'assets/animations/MDLF_animation.flr',
|
|
alignment: Alignment.center,
|
|
fit: BoxFit.scaleDown,
|
|
animation: 'Rotate',
|
|
),
|
|
);
|
|
},
|
|
itemCount: appContext.getLastMQTTMessages()?.length,
|
|
itemBuilder: (BuildContext ctxt, int Index) {
|
|
if (appContext.getLastMQTTMessages().length > 0) {
|
|
if (appContext.getLastMQTTMessages()[Index].toString().length > 350) {
|
|
var textToShow = appContext.getLastMQTTMessages()[Index].toString().substring(0,350);
|
|
return new Text("$textToShow ...");
|
|
} else {
|
|
return new Text(appContext.getLastMQTTMessages()[Index].toString());
|
|
}
|
|
}else {
|
|
return new Text("rien");
|
|
}
|
|
}
|
|
)
|
|
),
|
|
],
|
|
),
|
|
),
|
|
/*floatingActionButton: FloatingActionButton(
|
|
onPressed: () => {},
|
|
tooltip: 'Increment',
|
|
child: Icon(Icons.add),
|
|
),*/
|
|
);
|
|
}
|
|
|
|
Widget buildBody(BuildContext context, int index) {
|
|
return new Text(lastMessages[index]);
|
|
}
|
|
} |