From a2b6fa0725167f1bb903fd5ce9397f1a8b7a6089 Mon Sep 17 00:00:00 2001 From: Dan Cojocaru Date: Fri, 17 Jun 2022 21:59:14 +0300 Subject: [PATCH] Added choice of component kind when creating --- lib/pages/edit_component.dart | 46 +++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/lib/pages/edit_component.dart b/lib/pages/edit_component.dart index ca7e385..ce89ba0 100644 --- a/lib/pages/edit_component.dart +++ b/lib/pages/edit_component.dart @@ -1,3 +1,5 @@ +import 'dart:math'; + import 'package:collection/collection.dart'; import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; @@ -305,6 +307,48 @@ class EditComponentPage extends HookWidget { childCount: outputs.value.length, ), ), + if (truthTable.value == null && logicExpression.value == null) ...[ + SliverToBoxAdapter( + child: Column( + children: [ + const Divider(), + Text( + 'Choose component kind', + style: Theme.of(context).textTheme.headline4, + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: OutlinedButton( + onPressed: () { + logicExpression.value = ''; + }, + child: const Text('Logic Expression'), + ), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: OutlinedButton( + onPressed: () { + final row = "0" * outputs.value.length; + truthTable.value = List.generate(pow(2, inputs.value.length) as int, (_) => row); + }, + child: const Text('Truth Table'), + ), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: OutlinedButton( + onPressed: null, + child: const Text('Visual Designer'), + ), + ), + ], + ), + ), + ], + if (logicExpression.value != null) ...[ + + ], if (truthTable.value != null) ...[ SliverToBoxAdapter( child: Padding( @@ -328,8 +372,6 @@ class EditComponentPage extends HookWidget { ), ), ) - ] else ...[ - ], ], ),