Skip to content

Commit

Permalink
fix remote not updating when a button is added
Browse files Browse the repository at this point in the history
  • Loading branch information
TalkingPanda0 committed Jan 16, 2024
1 parent 4541986 commit 775fcbd
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 18 deletions.
1 change: 0 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
2 changes: 0 additions & 2 deletions lib/utils/ir.dart
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
12 changes: 0 additions & 12 deletions lib/utils/irtransmitter.dart

This file was deleted.

13 changes: 10 additions & 3 deletions lib/widgets/create_remote.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@ class CreateRemote extends StatefulWidget {

class _CreateRemoteState extends State<CreateRemote> {
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: () {
Expand Down Expand Up @@ -69,6 +73,7 @@ class _CreateRemoteState extends State<CreateRemote> {
button: button,
),
));

setState(() {
remote.buttons[index] = button;
});
Expand Down Expand Up @@ -109,10 +114,12 @@ class _CreateRemoteState extends State<CreateRemote> {
MaterialPageRoute(
builder: (context) => const CreateButton(),
));

setState(() {
remote.buttons.add(button);
});
} catch (e) {
print(e);
return;
}
},
Expand Down
5 changes: 5 additions & 0 deletions lib/widgets/remote_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ class RemoteView extends StatefulWidget {
}

class RemoteViewState extends State<RemoteView> {
@override
void initState() {
super.initState();
}

@override
Widget build(BuildContext context) {
return Scaffold(
Expand Down

0 comments on commit 775fcbd

Please sign in to comment.