123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- import 'package:touch_demonstrator/src/blocs/BlocProvider.dart';
- import 'package:touch_demonstrator/pages/DebugPage.dart';
- import 'package:flutter/material.dart';
- import 'package:touch_demonstrator/src/blocs/bluetoothBloc.dart';
- import 'package:touch_demonstrator/src/blocs/debugCounterBloc.dart';
-
- Widget buildAppBarPageTouchPoints(BuildContext context) {
- void _pageRouteDebugView() {
- print('Debug button pressed');
- Navigator.push(
- context, MaterialPageRoute(builder: (context) => DebugView()));
- }
-
- IconButton _buildDebugIconButton() {
- return IconButton(
- key: Key('debugButton'),
- icon: Icon(Icons.bug_report),
- onPressed: _pageRouteDebugView,
- );
- }
-
- StreamBuilder<bool> titleAppBar() {
- final bBloc = BlocProvider.of(context).bluetoothBlocGetter;
- var appBarText;
- return StreamBuilder<bool>(
- stream: bBloc.isConnected$,
- initialData: false,
- builder: (BuildContext context, AsyncSnapshot<bool> snapshot) {
- if (snapshot.hasData) {
- snapshot.data
- ? appBarText = 'Connected'
- : appBarText = 'Disconnected';
- return AnimatedSwitcher(
- duration: Duration(milliseconds: 300),
- transitionBuilder: (Widget child, Animation<double> opacity) {
- return FadeTransition(child: child, opacity: opacity);
- },
- child: Text(
- '$appBarText',
- key: ValueKey<String>(appBarText),
- textDirection: TextDirection.ltr,
- ),
- );
- } else
- return Text('Disconnected');
- });
- }
-
- List<Widget> actionsAppBar() {
- final debugBloc = BlocProvider.of(context).debugBlocGetter;
- return <Widget>[
- StreamBuilder<bool>(
- stream: debugBloc.debugEnabledStatus$,
- initialData: false,
- builder: (BuildContext context, AsyncSnapshot<bool> snapshotDebug) {
- if (snapshotDebug.hasData) {
- return snapshotDebug.data ? _buildDebugIconButton() : Container();
- } else
- return Container();
- },
- ),
- ];
- }
-
- return AppBar(
- title: titleAppBar(),
- actions: actionsAppBar(),
- );
- }
|