Masterarbeit Richard Stern. Flutter App, sich mit einem Bluetooth-Gerät verbindet und Berührungen auf einem Sensor visualisiert.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

uiComponents.dart 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. import 'dart:ui';
  2. import 'package:flutter/material.dart';
  3. //import 'package:flutter_svg/flutter_svg.dart';
  4. import 'package:touch_demonstrator/pages/PageTouchPoints.dart';
  5. import 'package:touch_demonstrator/src/blocs/BlocProvider.dart'; //bloc:
  6. import 'package:flutter/animation.dart';
  7. class Button extends StatelessWidget {
  8. /// Button that navigates to the page 'PageTouchPoints'
  9. @override
  10. Widget build(BuildContext context) {
  11. return Hero(
  12. tag: 'SearchHero',
  13. child: Padding(
  14. padding: const EdgeInsets.all(8.0),
  15. child: RaisedButton(
  16. color: Theme.of(context).accentColor,
  17. shape: StadiumBorder(),
  18. onPressed: () {
  19. Navigator.push(context,
  20. MaterialPageRoute(builder: (context) => PageTouchPoints()));
  21. },
  22. child: Text(
  23. 'Search and Connect Touchpad',
  24. style: TextStyle(color: Colors.white),
  25. ),
  26. ),
  27. ),
  28. );
  29. }
  30. }
  31. class TouchPad extends StatelessWidget {
  32. /// Image of the touch pad
  33. @override
  34. Widget build(BuildContext context) {
  35. return Padding(
  36. padding: const EdgeInsets.all(8.0),
  37. child: Image.asset('assets/trackpad.png'),
  38. );
  39. }
  40. }
  41. class ReusableWidgets {
  42. getAppBar(String title) {
  43. return AppBar(
  44. title: Text(title),
  45. );
  46. }
  47. getAppBar2(BuildContext context) {
  48. final bBloc = BlocProvider.of(context).bluetoothBlocGetter;
  49. String appBarText;
  50. return AppBar(
  51. title: StreamBuilder<bool>(
  52. stream: bBloc.isConnected$,
  53. initialData: false,
  54. builder: (BuildContext context, AsyncSnapshot<bool> snapshot) {
  55. if (snapshot.hasData) {
  56. if (snapshot.data) {
  57. appBarText = 'Connected';
  58. } else {
  59. // _showSnackbar('Disconnected');
  60. // return Text('Disconnected');
  61. appBarText = 'Disconnected';
  62. }
  63. return AnimatedSwitcher(
  64. duration: const Duration(milliseconds: 350),
  65. transitionBuilder: (Widget child, Animation<double> opacity) {
  66. return FadeTransition(child: child, opacity: opacity);
  67. },
  68. child: new Text(
  69. '$appBarText',
  70. // Must have this key to build a unique widget when _count changes.
  71. key: new ValueKey<String>(appBarText),
  72. textScaleFactor: 1.0,
  73. textDirection: TextDirection.ltr,
  74. ),
  75. );
  76. } else
  77. return Text('Disconnected');
  78. }),
  79. // actions: <Widget>[
  80. // enableDebug ?IconButton(
  81. // icon: Icon(Icons.build),
  82. // onPressed: () {
  83. // print('pressed');
  84. // Navigator.push(
  85. // context, MaterialPageRoute(builder: (context) => DebugView()));
  86. // },
  87. // ):Container(),
  88. // ],
  89. );
  90. }
  91. }