Advertisement
Guest User

Untitled

a guest
Aug 14th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 3.36 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2. import 'package:adaTeman/utils/utils.dart';
  3. import 'package:adaTeman/components/infos/locationInfo.dart';
  4. import 'package:adaTeman/locations.dart';
  5. import 'package:adaTeman/postPage/detailKategori.dart';
  6. import 'package:adaTeman/search.dart';
  7.  
  8. class ExploreView extends StatefulWidget {
  9.  
  10.   var location = "Jalan Haji Saimang";
  11.  
  12.   @override
  13.   _ExploreViewState createState() => _ExploreViewState();
  14. }
  15.  
  16. class _ExploreViewState extends State<ExploreView> {
  17.  
  18.   var util = new Util();
  19.  
  20.   getLocation(BuildContext context) async {
  21.     final result = await Navigator.push(
  22.       context,
  23.       MaterialPageRoute(builder: (context) => MapPage()),
  24.     );
  25.     if (result != null) {
  26.       setState(() {
  27.         widget.location = result;
  28.       });
  29.     }
  30.   }
  31.  
  32.   @override
  33.   Widget build(BuildContext context) {
  34.     return Container(
  35.       color: util.hexToColor("#FAFAFA"),
  36.       child: new Column(
  37.         children: <Widget>[
  38.           new InkWell(
  39.             child: new LocationInfo(location: widget.location),
  40.             onTap: () {
  41.               getLocation(context);
  42.             },
  43.           ),
  44.           new Padding(
  45.               padding: EdgeInsets.only(top: 10.0)
  46.           ),
  47.           new Divider(
  48.             color: util.hexToColor("#000000"),
  49.             height: 0.0,
  50.           ),
  51.           new Expanded(
  52.             child: GridView.count(
  53.               primary: true,
  54.               childAspectRatio: 1.0,
  55.               crossAxisCount: 2,
  56.               children: <Widget>[
  57.                 _makeGridCell("Education"),
  58.                 _makeGridCell("Outdoor & Travel"),
  59.                 _makeGridCell("Electronics"),
  60.                 _makeGridCell("Men's Fashion"),
  61.                 _makeGridCell("Sports"),
  62.                 _makeGridCell("Women's Fashion"),
  63.                 _makeGridCell("Music"),
  64.                 _makeGridCell("Cooking"),
  65.                 _makeGridCell("Leisure"),
  66.                 _makeGridCell("Miscellaneous"),
  67.               ],
  68.             ),
  69.           ),
  70.         ],
  71.       ),
  72.     );
  73.   }
  74.  
  75.   Widget _makeGridCell(String categoryName) {
  76.     return Container(
  77.       child: new Card(
  78.         elevation: 0.0,
  79.         child: InkWell(
  80.             child: Column(
  81.               crossAxisAlignment: CrossAxisAlignment.stretch,
  82.               mainAxisAlignment: MainAxisAlignment.center,
  83.               mainAxisSize: MainAxisSize.min,
  84.               verticalDirection: VerticalDirection.down,
  85.               children: <Widget>[
  86.                 new Center(
  87.                   child: new Image(
  88.                     image: util.itemCategoryParseToImage(categoryName),
  89.                     height: 48.0,
  90.                     width: 48.0,
  91.                   ),
  92.                 ),
  93.                 new Padding(
  94.                   padding: EdgeInsets.all(6.0),
  95.                 ),
  96.                 new Center(
  97.                   child: Text(categoryName),
  98.                 ),
  99.               ],
  100.             ),
  101.             onTap: () {
  102.               Navigator.push(
  103.                   context,
  104.                   MaterialPageRoute(
  105.                       builder: (context) => CategoryDetail(category: categoryName)
  106.                   )
  107.               );
  108.             }
  109.         ),
  110.       ),
  111.       decoration: BoxDecoration(
  112.         border: new Border.all(color: util.hexToColor("#DDDDDD"))
  113.       ),
  114.     );
  115.   }
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement