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.

AppBarPageTouchPoints.dart 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import 'package:touch_demonstrator/src/blocs/BlocProvider.dart';
  2. import 'package:touch_demonstrator/pages/DebugPage.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:touch_demonstrator/src/blocs/bluetoothBloc.dart';
  5. import 'package:touch_demonstrator/src/blocs/debugCounterBloc.dart';
  6. Widget buildAppBarPageTouchPoints(BuildContext context) {
  7. void _pageRouteDebugView() {
  8. print('Debug button pressed');
  9. Navigator.push(
  10. context, MaterialPageRoute(builder: (context) => DebugView()));
  11. }
  12. IconButton _buildDebugIconButton() {
  13. return IconButton(
  14. key: Key('debugButton'),
  15. icon: Icon(Icons.bug_report),
  16. onPressed: _pageRouteDebugView,
  17. );
  18. }
  19. StreamBuilder<bool> titleAppBar() {
  20. final bBloc = BlocProvider.of(context).bluetoothBlocGetter;
  21. var appBarText;
  22. return StreamBuilder<bool>(
  23. stream: bBloc.isConnected$,
  24. initialData: false,
  25. builder: (BuildContext context, AsyncSnapshot<bool> snapshot) {
  26. if (snapshot.hasData) {
  27. snapshot.data
  28. ? appBarText = 'Connected'
  29. : appBarText = 'Disconnected';
  30. return AnimatedSwitcher(
  31. duration: Duration(milliseconds: 300),
  32. transitionBuilder: (Widget child, Animation<double> opacity) {
  33. return FadeTransition(child: child, opacity: opacity);
  34. },
  35. child: Text(
  36. '$appBarText',
  37. key: ValueKey<String>(appBarText),
  38. textDirection: TextDirection.ltr,
  39. ),
  40. );
  41. } else
  42. return Text('Disconnected');
  43. });
  44. }
  45. List<Widget> actionsAppBar() {
  46. final debugBloc = BlocProvider.of(context).debugBlocGetter;
  47. return <Widget>[
  48. StreamBuilder<bool>(
  49. stream: debugBloc.debugEnabledStatus$,
  50. initialData: false,
  51. builder: (BuildContext context, AsyncSnapshot<bool> snapshotDebug) {
  52. if (snapshotDebug.hasData) {
  53. return snapshotDebug.data ? _buildDebugIconButton() : Container();
  54. } else
  55. return Container();
  56. },
  57. ),
  58. ];
  59. }
  60. return AppBar(
  61. title: titleAppBar(),
  62. actions: actionsAppBar(),
  63. );
  64. }