SHARE
TWEET

Untitled

a guest Jun 18th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Drawer buildDrawer(BuildContext context, String currentRoute) {
  2.   return Drawer(
  3.     child: ListView(
  4.       children: <Widget>[
  5.         const DrawerHeader(
  6.           child: const Center(
  7.             child: const Text('Flutter Map Examples'),
  8.           ),
  9.         ),
  10.         ListTile(
  11.           title: const Text('SwibloMap'),
  12.           selected: currentRoute == SwibloMap.route,
  13.           onTap: () {
  14.             Navigator.pushReplacementNamed(context, SwibloMap.route);
  15.           },
  16.         ),
  17.         ListTile(
  18.           title: const Text('LogOut'),
  19.           selected: currentRoute == LaunchPad.route,
  20.           onTap: () {
  21.             Navigator.pushReplacementNamed(context, LaunchPad.route);
  22.           },
  23.         ),
  24.       ],
  25.     ),
  26.   );
  27. }
  28.  
  29. class SwibloMap extends StatelessWidget {
  30.   static const String route = 'swiblo_map';
  31.  
  32.   @override
  33.   Widget build(BuildContext context) {
  34.     var mapOverlayWidget = MapOverlayWidget();
  35.     var mapCoreWidget = MapCoreWidget();
  36.    
  37.     return Scaffold(
  38.       appBar: AppBar(title: Text('Derp')),
  39.       drawer: buildDrawer(context, route),
  40.       body: Column(
  41.             children: [
  42.               Padding(
  43.                 padding: EdgeInsets.only(top: 2.0, bottom: 2.0),
  44.                 child: Text(
  45.                     'This is a map that is showing derp'),
  46.               ),
  47.               Flexible(
  48.                   child: mapCoreWidget
  49.               ),
  50.               mapOverlayWidget
  51.             ],
  52.           )
  53.     );
  54.   }
  55.  
  56. //  @override
  57. //  void dispose() {
  58. //    //super.dispose();
  59. //    overlayBloc.dispose();
  60. //  }
  61. }
  62.  
  63.  
  64. class MapOverlayWidget extends StatefulWidget {
  65.  
  66.   @override
  67.   State<StatefulWidget> createState() {
  68.     return MapOverlayWidgetState();
  69.   }
  70. }
  71.  
  72. class MapOverlayWidgetState extends State<MapOverlayWidget> {
  73.   var currentDisplay = false;
  74.   SwibloBlocService swibloBlocService = SwibloBlocService();
  75.   var overlayEntry;
  76.  
  77.   dismissOverlay(BuildContext context) {
  78.     if (overlayEntry != null) {
  79.       overlayEntry.remove();
  80.     }
  81.   }
  82.  
  83.   showOverlay(BuildContext context, OverlayLoaded state) {
  84.     OverlayState overlayState = Overlay.of(context);
  85.     overlayEntry = OverlayEntry(
  86.         builder: (context) =>
  87.             Positioned(
  88.                 bottom: 0.0,
  89.                 left: 10,
  90.                 right: 10,
  91.                 child: Column(
  92.                   children: <Widget>[
  93.                     Text(state.overlayModel.displayText,
  94.                     style: TextStyle(fontSize: 20),),
  95.                     AudioAppBox()
  96.                   ],
  97.                 )
  98.             ));
  99.     overlayState.insert(overlayEntry);
  100.   }
  101.  
  102.   @override
  103.   Widget build(BuildContext context) {
  104.     swibloBlocService.updateContext(context);
  105.  
  106.     return BlocListener(
  107.         bloc: swibloBlocService.getBloc(),
  108.         listener: (context, state) {
  109. //          if (state is InitialOverlayState) {
  110. //            print("Initial State " + state.toString());
  111. //          }
  112.  
  113.           if (state is OverlayLoaded) {
  114.             showOverlay(context, state);
  115.           }
  116.  
  117.           if (state is OverlayNotShowing) {
  118.             dismissOverlay(context);
  119.           }
  120.         },
  121.         child: Container()
  122.     );
  123.   }
  124.  
  125.   @override
  126.   void dispose() {
  127.     dismissOverlay(context);
  128.     super.dispose();
  129.   }
  130. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top