diff --git a/frontend/lib/devices.dart b/frontend/lib/devices.dart new file mode 100644 index 0000000..6cc210a --- /dev/null +++ b/frontend/lib/devices.dart @@ -0,0 +1,35 @@ +import 'dart:async'; +import 'dart:convert'; + +import 'package:flutter/material.dart'; +import 'package:http/http.dart' as http; + +class Category { + final String name; + List devices; + + Category(this.name) : devices = []; + + static Future> fetch(String base_url) async { + final response = await http.get(Uri.parse("$base_url/devices")); + + if (response.statusCode == 200) { + List categories = []; + + Map> json = jsonDecode(response.body); + + return categories; + } else { + throw Exception("Failed to fetch devices"); + } + } +} + +class Device { + final int device_id; + bool led_state; + bool power_state; + double power_draw; + + Device(this.device_id, this.led_state, this.power_state, this.power_draw); +} diff --git a/frontend/lib/main.dart b/frontend/lib/main.dart index dda5554..0e95d83 100644 --- a/frontend/lib/main.dart +++ b/frontend/lib/main.dart @@ -1,5 +1,7 @@ import 'package:flutter/material.dart'; +import 'devices.dart'; + void main() { runApp(const MyApp()); } @@ -105,13 +107,9 @@ class _MyHomePageState extends State { // wireframe for each widget. mainAxisAlignment: MainAxisAlignment.center, children: [ - const Text( - 'You have pushed the button this many times:', - ), - Text( - '$_counter', - style: Theme.of(context).textTheme.headlineMedium, - ), + Table( + border: TableBorder.all(), + ) ], ), ),