Advertisement
Guest User

test_wera_app_sako

a guest
Feb 26th, 2020
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 10.13 KB | None | 0 0
  1. //
  2. //  main.dart
  3. //  Wera-Steuerung
  4. //
  5. //  Created by Sascha Koop.
  6. //  Copyright (c) 2019 __MyCompanyName__. All rights reserved.
  7. //ö
  8.  
  9. import 'package:flutter/material.dart';
  10.  
  11. void main() => runApp(MyApp());
  12.  
  13. class MyApp extends StatelessWidget {
  14.   @override
  15.   Widget build(BuildContext context){
  16.     return MaterialApp(
  17.       debugShowCheckedModeBanner: false,
  18.       home: Scaffold(
  19.         appBar: AppBar(
  20.           title: const Text('Erdgeschoss'),
  21.           backgroundColor: Colors.cyan,
  22.           actions: <Widget>[
  23.             //Top-Bar Widget Buttons: Navigation
  24.  
  25.             //einzelne Lampen steuern
  26.             IconButton(
  27.               icon: Icon(Icons.lightbulb_outline),
  28.               onPressed: () {
  29.                 //Navigation zur nächsten Seite
  30.                 print('Test Console');
  31.               },
  32.             ),
  33.  
  34.             //Settings-PopupMenu
  35.             PopupMenuButton(
  36.               itemBuilder: (BuildContext context) {
  37.                 return [
  38.                   PopupMenuItem(child: Text('Lampen')),
  39.                   PopupMenuItem(child: Text('Einstellungen')),
  40.                 ];
  41.               },
  42.             ),
  43.  
  44.           ],
  45.         ),
  46.         backgroundColor: Colors.cyan[100],
  47.         body: MyStatefulWidget(),
  48.         )
  49.       );
  50.   }
  51. }
  52.  
  53. //Klasse für Body
  54. class MyStatefulWidget extends StatefulWidget {
  55.   MyStatefulWidget({Key key}) : super(key: key);
  56.  
  57.   @override
  58.   _MyStatefulWidgetState createState() => _MyStatefulWidgetState();
  59. }
  60.  
  61.  
  62. class _MyStatefulWidgetState extends State<MyStatefulWidget> {
  63.   //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
  64.   //bool _lightErdgeschoss = false;
  65.   bool _lightCafe = false;
  66.   bool _lightFoyer = false;
  67.   bool _lightJungenToilette = false;
  68.   bool _lightGirlsToilette = false;
  69.   bool _lightKueche = false;
  70.   bool _lightUmkleiden = false;
  71.   bool _lightTHausFirst = false;
  72.   bool _lightTHausSecond = false;
  73.   bool _lightTHausThird = false;
  74.   bool _lightGaderobe = false;
  75.   bool _lightLager = false;
  76.  
  77.   static const Color switchColor_active = Colors.red;
  78.  
  79.   @override
  80.   Widget build(BuildContext context) {
  81.     return SingleChildScrollView(
  82.       child: Column(
  83.       children: <Widget> [
  84.  
  85.         //Etagenbild
  86.         new ClipRRect(
  87.           borderRadius: BorderRadius.circular(2.5),
  88.           child: Image.asset('images/weraforum_eg.png'),
  89.         ),
  90.  
  91.         //If-Abfrage: Wenn Erdgeschosse _light* = true sind, dann soll automatisch auch _lightErdgeschoss = true sein.
  92.         /*if (_lightErdgeschoss = true;
  93.           || _lightCafe = true;
  94.           || _lightFoyer = true;
  95.           || _lightJungenToilette = true;
  96.           || _lightGirlsToilette = true;
  97.           || _lightKueche = true;
  98.           || _lightUmkleiden = true;
  99.           || _lightTHausFirst = true;
  100.           || _lightTHausSecond = true;
  101.           || _lightTHausThird = true;
  102.           || _lightGaderobe = true;
  103.           || _lightLager = true;
  104.         ) {
  105.           _lightErdgeschoss = true;
  106.         },*/
  107.  
  108.         //Switch: Alle Lampen: Erdgeschoss
  109.         /*Switch(
  110.           activeColor: switchColor_active,
  111.           value: _lightErdgeschoss,
  112.           onChanged: (bool value) {
  113.             setState(() {
  114.               _lightErdgeschoss = value;
  115.               _lightJungenToilette = value;
  116.               _lightGirlsToilette = value;
  117.               _lightFoyer = value;
  118.               _lightCafe = value;
  119.               _lightKueche = value;
  120.               _lightUmkleiden = value;
  121.               _lightTHausFirst = value;
  122.               _lightTHausSecond = value;
  123.               _lightTHausThird = value;
  124.               _lightGaderobe = value;
  125.               _lightLager = value;
  126.             });
  127.           },
  128.         ),*/
  129.  
  130.         //Buttons nebeneinander: Zentriert
  131.         new Center(
  132.           child: ButtonBar(
  133.             mainAxisSize: MainAxisSize.min,
  134.             children: <Widget>[
  135.  
  136.               //Button: Alle Lampen *AN*
  137.               RaisedButton(
  138.                 child: Text('ALLES AN', style: TextStyle(fontSize: 20)),
  139.                 color: Colors.cyan,
  140.                 shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(30.0)),
  141.                 padding: const EdgeInsets.all(15),              
  142.                 onPressed: () {
  143.                   setState(() {
  144.                     _lightJungenToilette = true;
  145.                     _lightGirlsToilette = true;
  146.                     _lightFoyer = true;
  147.                     _lightCafe = true;
  148.                     _lightKueche = true;
  149.                     _lightUmkleiden = true;
  150.                     _lightTHausFirst = true;
  151.                     _lightTHausSecond = true;
  152.                     _lightTHausThird = true;
  153.                     _lightGaderobe = true;
  154.                     _lightLager = true;
  155.                   });
  156.                 },
  157.               ),
  158.  
  159.               //Button: Alle Lampen *AUS*
  160.               RaisedButton(
  161.                 child: Text('ALLES AUS', style: TextStyle(fontSize: 20)),
  162.                 color: Colors.cyan,
  163.                 shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(30.0)),
  164.                 padding: const EdgeInsets.all(15),  
  165.                 onPressed: () {
  166.                   setState(() {
  167.                     _lightJungenToilette = false;
  168.                     _lightGirlsToilette = false;
  169.                     _lightFoyer = false;
  170.                     _lightCafe = false;
  171.                     _lightKueche = false;
  172.                     _lightUmkleiden = false;
  173.                     _lightTHausFirst = false;
  174.                     _lightTHausSecond = false;
  175.                     _lightTHausThird = false;
  176.                     _lightGaderobe = false;
  177.                     _lightLager = false;
  178.                   });
  179.                 },
  180.               ),
  181.  
  182.             ],
  183.           ),
  184.         ),
  185.         Divider(),
  186.  
  187.         /*****Einzelne Räume - Lampen Steuerung*****/
  188.         //SwitchList: Café
  189.         SwitchListTile(
  190.         title: const Text('Café'),
  191.         activeColor: switchColor_active,
  192.         value: _lightCafe,
  193.         onChanged: (bool value) {
  194.           setState(() {
  195.             _lightCafe = value;
  196.           });
  197.         },
  198.         secondary: Icon(Icons.lightbulb_outline),
  199.       ),
  200.       Divider(),
  201.  
  202.       //SwitchList: Foyer
  203.       SwitchListTile(
  204.         title: const Text('Foyer'),
  205.         activeColor: switchColor_active,
  206.         value: _lightFoyer,
  207.         onChanged: (bool value) {
  208.           setState(() {
  209.             _lightFoyer = value;
  210.           });
  211.         },
  212.         secondary: const Icon(Icons.lightbulb_outline),
  213.       ),
  214.       Divider(),
  215.  
  216.       //SwitchList: Jungen-Toilette
  217.       SwitchListTile(
  218.         title: const Text('Jungen - Toilette'),
  219.         activeColor: switchColor_active,
  220.         value: _lightJungenToilette,
  221.         onChanged: (bool value) {
  222.           setState(() {
  223.             _lightJungenToilette = value;
  224.           });
  225.         },
  226.         secondary: const Icon(Icons.lightbulb_outline),
  227.       ),
  228.       Divider(),
  229.  
  230.       //SwitchList: Mädchen-Toilette
  231.       SwitchListTile(
  232.         title: const Text('Mädchen - Toilette'),
  233.         activeColor: switchColor_active,
  234.         value: _lightGirlsToilette,
  235.         onChanged: (bool value) {
  236.           setState(() {
  237.             _lightGirlsToilette = value;
  238.           });
  239.         },
  240.         secondary: const Icon(Icons.lightbulb_outline),
  241.       ),
  242.       Divider(),
  243.  
  244.       //SwitchList: Küche
  245.         SwitchListTile(
  246.         title: const Text('Küche'),
  247.         activeColor: switchColor_active,
  248.         value: _lightKueche,
  249.         onChanged: (bool value) {
  250.           setState(() {
  251.             _lightKueche = value;
  252.           });
  253.         },
  254.         secondary: const Icon(Icons.lightbulb_outline),
  255.       ),
  256.       Divider(),
  257.  
  258.       //SwitchList: Umkleiden
  259.         SwitchListTile(
  260.         title: const Text('Umkleiden'),
  261.         activeColor: switchColor_active,
  262.         value: _lightUmkleiden,
  263.         onChanged: (bool value) {
  264.           setState(() {
  265.             _lightUmkleiden = value;
  266.           });
  267.         },
  268.         secondary: const Icon(Icons.lightbulb_outline),
  269.       ),
  270.       Divider(),
  271.  
  272.       //SwitchList: Treppenhaus: 1
  273.         SwitchListTile(
  274.         title: const Text('Treppenhaus 1'),
  275.         activeColor: switchColor_active,
  276.         value: _lightTHausFirst,
  277.         onChanged: (bool value) {
  278.           setState(() {
  279.             _lightTHausFirst = value;
  280.           });
  281.         },
  282.         secondary: const Icon(Icons.lightbulb_outline),
  283.       ),
  284.       Divider(),
  285.  
  286.       //SwitchList: Treppenhaus: 2
  287.         SwitchListTile(
  288.         title: const Text('Treppenhaus 2'),
  289.         activeColor: switchColor_active,
  290.         value: _lightTHausSecond,
  291.         onChanged: (bool value) {
  292.           setState(() {
  293.             _lightTHausSecond = value;
  294.           });
  295.         },
  296.         secondary: const Icon(Icons.lightbulb_outline),
  297.       ),
  298.       Divider(),
  299.  
  300.       //SwitchList: Treppenhaus: 3
  301.         SwitchListTile(
  302.         title: const Text('Treppenhaus 3'),
  303.         activeColor: switchColor_active,
  304.         value: _lightTHausThird,
  305.         onChanged: (bool value) {
  306.           setState(() {
  307.             _lightTHausThird = value;
  308.           });
  309.         },
  310.         secondary: const Icon(Icons.lightbulb_outline),
  311.       ),
  312.       Divider(),
  313.  
  314.       //SwitchList: Gaderobe
  315.         SwitchListTile(
  316.         title: const Text('Gaderobe'),
  317.         activeColor: switchColor_active,
  318.         value: _lightGaderobe,
  319.         onChanged: (bool value) {
  320.           setState(() {
  321.             _lightGaderobe = value;
  322.           });
  323.         },
  324.         secondary: const Icon(Icons.lightbulb_outline),
  325.       ),
  326.       Divider(),
  327.  
  328.       //SwitchList: Lager - Unten
  329.         SwitchListTile(
  330.         title: const Text('Lager'),
  331.         activeColor: switchColor_active,
  332.         value: _lightLager,
  333.         onChanged: (bool value) {
  334.           setState(() {
  335.             _lightLager = value;
  336.           });
  337.         },
  338.         secondary: const Icon(Icons.lightbulb_outline),
  339.       ),
  340.       Divider(),
  341.  
  342.     ])
  343.     );
  344.   }
  345. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement