Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // main.dart
- // Wera-Steuerung
- //
- // Created by Sascha Koop.
- // Copyright (c) 2019 __MyCompanyName__. All rights reserved.
- //ö
- import 'package:flutter/material.dart';
- void main() => runApp(MyApp());
- class MyApp extends StatelessWidget {
- @override
- Widget build(BuildContext context){
- return MaterialApp(
- debugShowCheckedModeBanner: false,
- home: Scaffold(
- appBar: AppBar(
- title: const Text('Erdgeschoss'),
- backgroundColor: Colors.cyan,
- actions: <Widget>[
- //Top-Bar Widget Buttons: Navigation
- //einzelne Lampen steuern
- IconButton(
- icon: Icon(Icons.lightbulb_outline),
- onPressed: () {
- //Navigation zur nächsten Seite
- print('Test Console');
- },
- ),
- //Settings-PopupMenu
- PopupMenuButton(
- itemBuilder: (BuildContext context) {
- return [
- PopupMenuItem(child: Text('Lampen')),
- PopupMenuItem(child: Text('Einstellungen')),
- ];
- },
- ),
- ],
- ),
- backgroundColor: Colors.cyan[100],
- body: MyStatefulWidget(),
- )
- );
- }
- }
- //Klasse für Body
- class MyStatefulWidget extends StatefulWidget {
- MyStatefulWidget({Key key}) : super(key: key);
- @override
- _MyStatefulWidgetState createState() => _MyStatefulWidgetState();
- }
- class _MyStatefulWidgetState extends State<MyStatefulWidget> {
- //Lampen Values = 0 -> Später: Server abfragen und per If-Statement den Value auf false/true setzen - je nach dem wie er auf dem Server gespeichert wurde
- //bool _lightErdgeschoss = false;
- bool _lightCafe = false;
- bool _lightFoyer = false;
- bool _lightJungenToilette = false;
- bool _lightGirlsToilette = false;
- bool _lightKueche = false;
- bool _lightUmkleiden = false;
- bool _lightTHausFirst = false;
- bool _lightTHausSecond = false;
- bool _lightTHausThird = false;
- bool _lightGaderobe = false;
- bool _lightLager = false;
- static const Color switchColor_active = Colors.red;
- @override
- Widget build(BuildContext context) {
- return SingleChildScrollView(
- child: Column(
- children: <Widget> [
- //Etagenbild
- new ClipRRect(
- borderRadius: BorderRadius.circular(2.5),
- child: Image.asset('images/weraforum_eg.png'),
- ),
- //If-Abfrage: Wenn Erdgeschosse _light* = true sind, dann soll automatisch auch _lightErdgeschoss = true sein.
- /*if (_lightErdgeschoss = true;
- || _lightCafe = true;
- || _lightFoyer = true;
- || _lightJungenToilette = true;
- || _lightGirlsToilette = true;
- || _lightKueche = true;
- || _lightUmkleiden = true;
- || _lightTHausFirst = true;
- || _lightTHausSecond = true;
- || _lightTHausThird = true;
- || _lightGaderobe = true;
- || _lightLager = true;
- ) {
- _lightErdgeschoss = true;
- },*/
- //Switch: Alle Lampen: Erdgeschoss
- /*Switch(
- activeColor: switchColor_active,
- value: _lightErdgeschoss,
- onChanged: (bool value) {
- setState(() {
- _lightErdgeschoss = value;
- _lightJungenToilette = value;
- _lightGirlsToilette = value;
- _lightFoyer = value;
- _lightCafe = value;
- _lightKueche = value;
- _lightUmkleiden = value;
- _lightTHausFirst = value;
- _lightTHausSecond = value;
- _lightTHausThird = value;
- _lightGaderobe = value;
- _lightLager = value;
- });
- },
- ),*/
- //Buttons nebeneinander: Zentriert
- new Center(
- child: ButtonBar(
- mainAxisSize: MainAxisSize.min,
- children: <Widget>[
- //Button: Alle Lampen *AN*
- RaisedButton(
- child: Text('ALLES AN', style: TextStyle(fontSize: 20)),
- color: Colors.cyan,
- shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(30.0)),
- padding: const EdgeInsets.all(15),
- onPressed: () {
- setState(() {
- _lightJungenToilette = true;
- _lightGirlsToilette = true;
- _lightFoyer = true;
- _lightCafe = true;
- _lightKueche = true;
- _lightUmkleiden = true;
- _lightTHausFirst = true;
- _lightTHausSecond = true;
- _lightTHausThird = true;
- _lightGaderobe = true;
- _lightLager = true;
- });
- },
- ),
- //Button: Alle Lampen *AUS*
- RaisedButton(
- child: Text('ALLES AUS', style: TextStyle(fontSize: 20)),
- color: Colors.cyan,
- shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(30.0)),
- padding: const EdgeInsets.all(15),
- onPressed: () {
- setState(() {
- _lightJungenToilette = false;
- _lightGirlsToilette = false;
- _lightFoyer = false;
- _lightCafe = false;
- _lightKueche = false;
- _lightUmkleiden = false;
- _lightTHausFirst = false;
- _lightTHausSecond = false;
- _lightTHausThird = false;
- _lightGaderobe = false;
- _lightLager = false;
- });
- },
- ),
- ],
- ),
- ),
- Divider(),
- /*****Einzelne Räume - Lampen Steuerung*****/
- //SwitchList: Café
- SwitchListTile(
- title: const Text('Café'),
- activeColor: switchColor_active,
- value: _lightCafe,
- onChanged: (bool value) {
- setState(() {
- _lightCafe = value;
- });
- },
- secondary: Icon(Icons.lightbulb_outline),
- ),
- Divider(),
- //SwitchList: Foyer
- SwitchListTile(
- title: const Text('Foyer'),
- activeColor: switchColor_active,
- value: _lightFoyer,
- onChanged: (bool value) {
- setState(() {
- _lightFoyer = value;
- });
- },
- secondary: const Icon(Icons.lightbulb_outline),
- ),
- Divider(),
- //SwitchList: Jungen-Toilette
- SwitchListTile(
- title: const Text('Jungen - Toilette'),
- activeColor: switchColor_active,
- value: _lightJungenToilette,
- onChanged: (bool value) {
- setState(() {
- _lightJungenToilette = value;
- });
- },
- secondary: const Icon(Icons.lightbulb_outline),
- ),
- Divider(),
- //SwitchList: Mädchen-Toilette
- SwitchListTile(
- title: const Text('Mädchen - Toilette'),
- activeColor: switchColor_active,
- value: _lightGirlsToilette,
- onChanged: (bool value) {
- setState(() {
- _lightGirlsToilette = value;
- });
- },
- secondary: const Icon(Icons.lightbulb_outline),
- ),
- Divider(),
- //SwitchList: Küche
- SwitchListTile(
- title: const Text('Küche'),
- activeColor: switchColor_active,
- value: _lightKueche,
- onChanged: (bool value) {
- setState(() {
- _lightKueche = value;
- });
- },
- secondary: const Icon(Icons.lightbulb_outline),
- ),
- Divider(),
- //SwitchList: Umkleiden
- SwitchListTile(
- title: const Text('Umkleiden'),
- activeColor: switchColor_active,
- value: _lightUmkleiden,
- onChanged: (bool value) {
- setState(() {
- _lightUmkleiden = value;
- });
- },
- secondary: const Icon(Icons.lightbulb_outline),
- ),
- Divider(),
- //SwitchList: Treppenhaus: 1
- SwitchListTile(
- title: const Text('Treppenhaus 1'),
- activeColor: switchColor_active,
- value: _lightTHausFirst,
- onChanged: (bool value) {
- setState(() {
- _lightTHausFirst = value;
- });
- },
- secondary: const Icon(Icons.lightbulb_outline),
- ),
- Divider(),
- //SwitchList: Treppenhaus: 2
- SwitchListTile(
- title: const Text('Treppenhaus 2'),
- activeColor: switchColor_active,
- value: _lightTHausSecond,
- onChanged: (bool value) {
- setState(() {
- _lightTHausSecond = value;
- });
- },
- secondary: const Icon(Icons.lightbulb_outline),
- ),
- Divider(),
- //SwitchList: Treppenhaus: 3
- SwitchListTile(
- title: const Text('Treppenhaus 3'),
- activeColor: switchColor_active,
- value: _lightTHausThird,
- onChanged: (bool value) {
- setState(() {
- _lightTHausThird = value;
- });
- },
- secondary: const Icon(Icons.lightbulb_outline),
- ),
- Divider(),
- //SwitchList: Gaderobe
- SwitchListTile(
- title: const Text('Gaderobe'),
- activeColor: switchColor_active,
- value: _lightGaderobe,
- onChanged: (bool value) {
- setState(() {
- _lightGaderobe = value;
- });
- },
- secondary: const Icon(Icons.lightbulb_outline),
- ),
- Divider(),
- //SwitchList: Lager - Unten
- SwitchListTile(
- title: const Text('Lager'),
- activeColor: switchColor_active,
- value: _lightLager,
- onChanged: (bool value) {
- setState(() {
- _lightLager = value;
- });
- },
- secondary: const Icon(Icons.lightbulb_outline),
- ),
- Divider(),
- ])
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement