mirror of
https://bitbucket.org/myhomie/myhomie_app.git
synced 2025-12-06 00:51:19 +00:00
140 lines
5.3 KiB
Dart
140 lines
5.3 KiB
Dart
import 'dart:convert';
|
|
import 'dart:typed_data';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:mycore_api/api.dart';
|
|
|
|
import 'package:mycore_api/api.dart' as API;
|
|
import 'package:myhomie_app/Components/Alarms/getCurrentAlarmModeIcon.dart';
|
|
import 'package:myhomie_app/Components/Custom_Navigation_Bar/CustomAppBar.dart';
|
|
import 'package:myhomie_app/Components/check_input_container.dart';
|
|
import 'package:myhomie_app/Components/loading_common.dart';
|
|
import 'package:myhomie_app/Components/string_input_container.dart';
|
|
import 'package:myhomie_app/Models/homieContext.dart';
|
|
import 'package:myhomie_app/app_context.dart';
|
|
import 'package:myhomie_app/constants.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
class RoomDetailPage extends StatefulWidget {
|
|
const RoomDetailPage({Key? key, required this.roomMainDetailDTO}) : super(key: key);
|
|
|
|
final API.RoomMainDetailDTO roomMainDetailDTO;
|
|
|
|
@override
|
|
State<RoomDetailPage> createState() => _RoomDetailPagePageState();
|
|
}
|
|
|
|
class _RoomDetailPagePageState extends State<RoomDetailPage> {
|
|
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
|
API.RoomDetailDTO? roomDetailDTO;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final appContext = Provider.of<AppContext>(context);
|
|
Size size = MediaQuery.of(context).size;
|
|
//final notchInset = MediaQuery.of(context).padding;
|
|
|
|
HomieAppContext homieAppContext = appContext.getContext();
|
|
|
|
debugPrint(widget.roomMainDetailDTO.id!);
|
|
|
|
return Scaffold(
|
|
key: _scaffoldKey,
|
|
appBar: CustomAppBar(
|
|
title: widget.roomMainDetailDTO.name!,
|
|
//titleIcon: getAlarmModeIcon(widget.alarmMode),
|
|
isTextSizeButton: true,
|
|
),
|
|
body: FutureBuilder(
|
|
future: homieAppContext.clientAPI.roomApi!.roomGetDetail(widget.roomMainDetailDTO.id!),
|
|
builder: (context, AsyncSnapshot<API.RoomDetailDTO?> snapshot) {
|
|
if(snapshot.data != null ) {
|
|
roomDetailDTO = snapshot.data;
|
|
|
|
return SingleChildScrollView(
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.max,
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
SizedBox(
|
|
width: size.width *1.1,
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: StringInputContainer(
|
|
label: "Nom:",
|
|
color: kMainColor,
|
|
textColor: Colors.white,
|
|
initialValue: roomDetailDTO!.name,
|
|
onChanged: (String value) {
|
|
setState(() {
|
|
roomDetailDTO!.name = value;
|
|
// TODO SAVE or not
|
|
});
|
|
},
|
|
),
|
|
),
|
|
),
|
|
/*Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: CheckInputContainer(
|
|
icon: Icons.notifications_active,
|
|
label: "Notification :",
|
|
fontSize: 20,
|
|
isChecked: alarmModeDetailDTO!.notification!,
|
|
onChanged: (bool value) {
|
|
alarmModeDetailDTO!.notification = value;
|
|
},
|
|
),
|
|
),*/
|
|
ExpansionTile(
|
|
title: Text(
|
|
"Devices",
|
|
style: TextStyle(
|
|
fontSize: 18.0,
|
|
fontWeight: FontWeight.bold
|
|
),
|
|
),
|
|
children: [
|
|
for(var device in roomDetailDTO!.devices!)
|
|
ExpansionTile(
|
|
title: Text(device.name!),
|
|
children: <Widget>[
|
|
ListTile(
|
|
title: Text("type: "+ (device.type != null ? device.type!.value : 'no type') ),
|
|
),
|
|
ListTile(
|
|
title: Text("status: "+ device.status.toString()),
|
|
),
|
|
ListTile(
|
|
title: Text("last update date: "+ device.lastStateDate!.toLocal().toString()),
|
|
),
|
|
ListTile(
|
|
title: Text("lastState: "+ (device.lastState != null ? device.lastState! : 'no data')),
|
|
)
|
|
],
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
);
|
|
} else {
|
|
return const LoadingCommon();
|
|
}
|
|
}
|
|
)
|
|
);
|
|
}
|
|
}
|