Advertisement
Guest User

Untitled

a guest
May 21st, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 7.08 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2. import 'package:tabunganku/src/provider/inherited.dart';
  3. import 'package:tabunganku/src/provider/blocProvider.dart';
  4. import 'package:tabunganku/src/blocs/dashboardBloc.dart';
  5. import 'package:tabunganku/src/blocs/pemasukanBloc.dart';
  6. import 'package:tabunganku/src/ui/pemasukan.dart';
  7.  
  8. class Home extends StatelessWidget {
  9.   Map<String, String> date = {
  10.     "date": (DateTime.now().toString()).split('.')[0]
  11.   };
  12.  
  13.   @override
  14.   Widget build(BuildContext context) {
  15.     final width = MediaQuery.of(context).size.width;
  16.     final height = MediaQuery.of(context).size.height;
  17.     final _dashboardBloc = BlocProvider.of(context);
  18.  
  19.     Widget _dashboard(Orientation orientation) {
  20.       return Container(
  21.         alignment: Alignment.centerLeft,
  22.         width: width,
  23.         height:
  24.             orientation == Orientation.landscape ? 0.4 * height : 0.2 * height,
  25.         padding: EdgeInsets.all(8),
  26.         decoration: BoxDecoration(
  27.           borderRadius: BorderRadius.all(Radius.circular(5)),
  28.           gradient: LinearGradient(
  29.             colors: [Colors.cyan, Colors.blueAccent],
  30.           ),
  31.           boxShadow: [
  32.             BoxShadow(
  33.                 color: Colors.black26,
  34.                 blurRadius: 4,
  35.                 spreadRadius: 1,
  36.                 offset: Offset(1, 1))
  37.           ],
  38.         ),
  39.         child: Column(
  40.           crossAxisAlignment: CrossAxisAlignment.start,
  41.           mainAxisAlignment: MainAxisAlignment.start,
  42.           children: <Widget>[
  43.             // StreamBuilder(
  44.             //   stream: _dashboardBloc.resultStream,
  45.             //   initialData: 0,
  46.             //   builder: (context, snapshot) {
  47.             //     if (snapshot.hasData) {
  48.             //       var _data = snapshot.data;
  49.             //       return Text(
  50.             //         "Saldo : $_data",
  51.             //         textAlign: TextAlign.start,
  52.             //         style: TextStyle(
  53.             //           color: Colors.white,
  54.             //           fontSize: 20,
  55.             //           fontWeight: FontWeight.w300,
  56.             //         ),
  57.             //       );
  58.             //     } else {
  59.             //       return SizedBox();
  60.             //     }
  61.             //   },
  62.             // ),
  63.             Divider(
  64.               color: Colors.transparent,
  65.               height: 14,
  66.             ),
  67.             Row(
  68.               mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  69.               crossAxisAlignment: CrossAxisAlignment.center,
  70.               children: <Widget>[
  71.                 Column(
  72.                   children: <Widget>[
  73.                     // StreamBuilder(
  74.                     //   stream: _dashboardBloc.resultStream,
  75.                     //   initialData: 0,
  76.                     //   builder: (context, snapshot) {
  77.                     //     if (snapshot.hasData) {
  78.                     //       var _data = snapshot.data;
  79.                     //       return Text(
  80.                     //         "$_data",
  81.                     //         textAlign: TextAlign.start,
  82.                     //         style: TextStyle(
  83.                     //           color: Colors.white,
  84.                     //           fontSize: 35,
  85.                     //           fontWeight: FontWeight.w300,
  86.                     //         ),
  87.                     //       );
  88.                     //     } else {
  89.                     //       return SizedBox();
  90.                     //     }
  91.                     //   },
  92.                     // ),
  93.                     Container(
  94.                       child: Text(
  95.                         "Pemasukan",
  96.                         style: TextStyle(
  97.                           color: Colors.white,
  98.                           fontSize: 20,
  99.                           fontWeight: FontWeight.w300,
  100.                         ),
  101.                       ),
  102.                     ),
  103.                   ],
  104.                 ),
  105.                 Column(
  106.                   children: <Widget>[
  107.                     Text(
  108.                       "10",
  109.                       style: TextStyle(
  110.                         color: Colors.white,
  111.                         fontSize: 35,
  112.                         fontWeight: FontWeight.w300,
  113.                       ),
  114.                     ),
  115.                     Container(
  116.                       child: Text(
  117.                         "Penarikan",
  118.                         style: TextStyle(
  119.                           color: Colors.white,
  120.                           fontSize: 20,
  121.                           fontWeight: FontWeight.w300,
  122.                         ),
  123.                       ),
  124.                     ),
  125.                   ],
  126.                 )
  127.               ],
  128.             )
  129.           ],
  130.         ),
  131.       );
  132.     }
  133.  
  134.     Widget _drawer = Drawer(
  135.       child: Container(
  136.         height: height,
  137.         color: Colors.white,
  138.         child: ListView(
  139.           padding: EdgeInsets.zero,
  140.           children: <Widget>[
  141.             DrawerHeader(
  142.               decoration: BoxDecoration(
  143.                 color: Colors.white,
  144.               ),
  145.               child: Align(
  146.                 alignment: Alignment.center,
  147.                 child: Text(
  148.                   "TabunganKu",
  149.                   style: TextStyle(
  150.                     fontSize: 40,
  151.                     fontWeight: FontWeight.w200,
  152.                   ),
  153.                 ),
  154.               ),
  155.             ),
  156.             ListTile(
  157.               title: Text("Pemasukan"),
  158.               onTap: () {
  159.                 Navigator.push(
  160.                   context,
  161.                   MaterialPageRoute(
  162.                     fullscreenDialog: true,
  163.                     builder: (context){
  164.                       return Pemasukan();
  165.                     }
  166.                   ),
  167.                 );
  168.                 // Navigator.of(context).pushNamed("/pemasukan");
  169.               },
  170.             ),
  171.             ListTile(
  172.               title: Text("Penarikan"),
  173.               onTap: () {
  174.                 Navigator.of(context).pushNamed("/penarikan");
  175.               },
  176.             ),
  177.             ListTile(
  178.               title: Text("Support Us"),
  179.             ),
  180.           ],
  181.         ),
  182.       ),
  183.     );
  184.  
  185.     Widget _body(Widget child) {
  186.       return Container(
  187.         color: Colors.white,
  188.         padding: const EdgeInsets.all(10),
  189.         alignment: Alignment.center,
  190.         child: Column(
  191.           mainAxisAlignment: MainAxisAlignment.start,
  192.           crossAxisAlignment: CrossAxisAlignment.center,
  193.           children: [child],
  194.         ),
  195.       );
  196.     }
  197.  
  198.     return Scaffold(
  199.       appBar: AppBar(
  200.         elevation: 0,
  201.         title: Text("TabunganKu"),
  202.       ),
  203.       drawer: _drawer,
  204.       body: OrientationBuilder(
  205.         builder: (context, Orientation orientation) {
  206.           return _body(_dashboard(orientation));
  207.         },
  208.       ),
  209.       floatingActionButton: FloatingActionButton(
  210.         // onPressed: null,
  211.         onPressed: () {
  212.           print(_dashboardBloc.widget.bloc);
  213.         },
  214.         // onPressed: (){print(_pemasukanBloc);},
  215.         child: Icon(
  216.           Icons.add,
  217.         ),
  218.       ),
  219.     );
  220.   }
  221. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement