mirror of
https://bitbucket.org/myhomie/myhomie_app.git
synced 2025-12-06 17:11:19 +00:00
117 lines
4.2 KiB
Dart
117 lines
4.2 KiB
Dart
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:mycore_api/api.dart' as API;
|
|
import 'package:myhomie_app/Components/Custom_Navigation_Bar/CustomAppBar.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 DeviceDetailPage extends StatefulWidget {
|
|
const DeviceDetailPage({Key? key, this.deviceSummaryDTO, this.deviceDetailDTO}) : super(key: key);
|
|
|
|
final API.DeviceSummaryDTO? deviceSummaryDTO;
|
|
final API.DeviceDetailDTO? deviceDetailDTO;
|
|
|
|
@override
|
|
State<DeviceDetailPage> createState() => _DeviceDetailPageState();
|
|
}
|
|
|
|
class _DeviceDetailPageState extends State<DeviceDetailPage> {
|
|
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
|
API.DeviceDetailDTO? deviceDetailDTO;
|
|
|
|
@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.deviceSummaryDTO.id!);
|
|
|
|
var deviceName = widget.deviceSummaryDTO == null ? widget.deviceDetailDTO!.name! : widget.deviceSummaryDTO!.name!;
|
|
var deviceId = widget.deviceSummaryDTO == null ? widget.deviceDetailDTO!.id! : widget.deviceSummaryDTO!.id!;
|
|
|
|
return Scaffold(
|
|
key: _scaffoldKey,
|
|
appBar: CustomAppBar(
|
|
title: deviceName,
|
|
//titleIcon: getAlarmModeIcon(widget.alarmMode),
|
|
isTextSizeButton: true,
|
|
),
|
|
body: FutureBuilder(
|
|
future: homieAppContext.clientAPI.deviceApi!.deviceGetDetail(deviceId),
|
|
builder: (context, AsyncSnapshot<API.DeviceDetailDTO?> snapshot) {
|
|
if(snapshot.data != null ) {
|
|
deviceDetailDTO = 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: deviceDetailDTO!.name,
|
|
onChanged: (String value) {
|
|
setState(() {
|
|
deviceDetailDTO!.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;
|
|
},
|
|
),
|
|
),*/
|
|
Text(
|
|
deviceDetailDTO!.type.toString(),
|
|
style: TextStyle(
|
|
fontSize: 18.0,
|
|
fontWeight: FontWeight.bold
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
} else {
|
|
return const LoadingCommon();
|
|
}
|
|
}
|
|
)
|
|
);
|
|
}
|
|
}
|