diff --git a/lib/main.dart b/lib/main.dart index 1d5881c..df947ac 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,6 +1,5 @@ import 'package:dynamic_color/dynamic_color.dart'; import 'package:flutter/material.dart'; -import 'package:osram_controller/utils/irtransmitter.dart'; import 'package:osram_controller/utils/remote.dart'; import 'package:osram_controller/widgets/remote_view.dart'; diff --git a/lib/utils/ir.dart b/lib/utils/ir.dart index 449c70d..46bdde2 100644 --- a/lib/utils/ir.dart +++ b/lib/utils/ir.dart @@ -1,7 +1,5 @@ import 'package:flutter/services.dart'; -import 'package:osram_controller/utils/irtransmitter.dart'; - const platform = MethodChannel('org.talkingpanda/irtransmitter'); void transmit(int code) async { diff --git a/lib/utils/irtransmitter.dart b/lib/utils/irtransmitter.dart deleted file mode 100644 index a6588de..0000000 --- a/lib/utils/irtransmitter.dart +++ /dev/null @@ -1,12 +0,0 @@ -import 'dart:async'; -import 'dart:ffi'; -import 'dart:typed_data'; -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; - -class IRTransmitter { - static const platform = MethodChannel('org.talkingpanda/irtransmitter'); - void transmit(List list) async { - await platform.invokeMethod("transmit", {"list": list}); - } -} diff --git a/lib/widgets/create_remote.dart b/lib/widgets/create_remote.dart index 738c5b1..80cf7b8 100644 --- a/lib/widgets/create_remote.dart +++ b/lib/widgets/create_remote.dart @@ -15,12 +15,16 @@ class CreateRemote extends StatefulWidget { class _CreateRemoteState extends State { TextEditingController textEditingController = TextEditingController(); + late Remote remote; + @override + void initState() { + remote = widget.remote ?? Remote(buttons: [], name: "Untitled Remote"); + textEditingController.value = TextEditingValue(text: remote.name); + super.initState(); + } @override Widget build(BuildContext context) { - Remote remote = - widget.remote ?? Remote(buttons: [], name: "Untitled Remote"); - textEditingController.value = TextEditingValue(text: remote.name); return Scaffold( floatingActionButton: FloatingActionButton( onPressed: () { @@ -69,6 +73,7 @@ class _CreateRemoteState extends State { button: button, ), )); + setState(() { remote.buttons[index] = button; }); @@ -109,10 +114,12 @@ class _CreateRemoteState extends State { MaterialPageRoute( builder: (context) => const CreateButton(), )); + setState(() { remote.buttons.add(button); }); } catch (e) { + print(e); return; } }, diff --git a/lib/widgets/remote_view.dart b/lib/widgets/remote_view.dart index ea0f47c..6c537ce 100644 --- a/lib/widgets/remote_view.dart +++ b/lib/widgets/remote_view.dart @@ -14,6 +14,11 @@ class RemoteView extends StatefulWidget { } class RemoteViewState extends State { + @override + void initState() { + super.initState(); + } + @override Widget build(BuildContext context) { return Scaffold(