import 'dart:ui'; import 'package:flutter/material.dart'; //import 'package:flutter_svg/flutter_svg.dart'; import 'package:touch_demonstrator/pages/PageTouchPoints.dart'; import 'package:touch_demonstrator/src/blocs/BlocProvider.dart'; //bloc: import 'package:flutter/animation.dart'; class Button extends StatelessWidget { /// Button that navigates to the page 'PageTouchPoints' @override Widget build(BuildContext context) { return Hero( tag: 'SearchHero', child: Padding( padding: const EdgeInsets.all(8.0), child: RaisedButton( color: Theme.of(context).accentColor, shape: StadiumBorder(), onPressed: () { Navigator.push(context, MaterialPageRoute(builder: (context) => PageTouchPoints())); }, child: Text( 'Search and Connect Touchpad', style: TextStyle(color: Colors.white), ), ), ), ); } } class TouchPad extends StatelessWidget { /// Image of the touch pad @override Widget build(BuildContext context) { return Padding( padding: const EdgeInsets.all(8.0), child: Image.asset('assets/trackpad.png'), ); } } class ReusableWidgets { getAppBar(String title) { return AppBar( title: Text(title), ); } getAppBar2(BuildContext context) { final bBloc = BlocProvider.of(context).bluetoothBlocGetter; String appBarText; return AppBar( title: StreamBuilder( stream: bBloc.isConnected$, initialData: false, builder: (BuildContext context, AsyncSnapshot snapshot) { if (snapshot.hasData) { if (snapshot.data) { appBarText = 'Connected'; } else { // _showSnackbar('Disconnected'); // return Text('Disconnected'); appBarText = 'Disconnected'; } return AnimatedSwitcher( duration: const Duration(milliseconds: 350), transitionBuilder: (Widget child, Animation opacity) { return FadeTransition(child: child, opacity: opacity); }, child: new Text( '$appBarText', // Must have this key to build a unique widget when _count changes. key: new ValueKey(appBarText), textScaleFactor: 1.0, textDirection: TextDirection.ltr, ), ); } else return Text('Disconnected'); }), // actions: [ // enableDebug ?IconButton( // icon: Icon(Icons.build), // onPressed: () { // print('pressed'); // Navigator.push( // context, MaterialPageRoute(builder: (context) => DebugView())); // }, // ):Container(), // ], ); } }