import 'package:flutter/material.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/brand_view_model.dart'; void main() => runApp(ProductBrandsPage()); class ProductBrandsPage extends StatefulWidget { @override _ProductBrandsPageState createState() => _ProductBrandsPageState(); } class _ProductBrandsPageState extends State { @override Widget build(BuildContext context) { return BaseView( onModelReady: (model) => model.getTopBrandsData(), builder: (_, model, wi) => AppScaffold( appBarTitle: 'Brands page', isShowAppBar: true, isPharmacy: true, body: Container( child: Column( children: [ Container( color: Colors.white, alignment: Alignment.topLeft, padding: EdgeInsets.only(left: 10.0, top: 10.0), child: Text( 'Top Brands', style: TextStyle( fontWeight: FontWeight.bold ), ), ), Container( height: 220, width: double.infinity, color: Colors.white, child: topBrand(), ), SizedBox( height: 10, ), Container( height: 100, width: double.infinity, color: Colors.white, child: IconButton( icon: Icon(Icons.search), onPressed: () { showSearch(context: context, delegate: SearchBar()); }, ), ), SizedBox( height: 10, ), Container( height: 280, width: double.infinity, color: Colors.white, child: ListView.builder( itemCount: model.brandsListList.length, itemBuilder: (BuildContext ctxt, int index) { return Container( margin: EdgeInsets.only(top: 50, left: 10), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, children: [ Text(model.brandsListList[index].name), SizedBox( height: 3, ), Divider(height: 1, color: Colors.grey) ], ), ); }), ), ], ), ), ), ); } } //topBrand() { // return BaseView( // onModelReady: (model) => model.getBrandsData(), // builder: (_, model, wi) => Column( // crossAxisAlignment: CrossAxisAlignment.start, // mainAxisAlignment: MainAxisAlignment.start, // children: [ // Container( // padding: EdgeInsets.all(10), // child: Text( // 'Top Brands', // ), // ), // Row( // children: [ // Container( // margin: EdgeInsets.fromLTRB(10.0, 10.0, 0.0, 0.0), // child: Container( // margin: EdgeInsets.only(bottom: 10.0), // child: Container( // margin: EdgeInsets.only(bottom: 10.0), // child: Container( // child: Container( // padding: EdgeInsets.symmetric( // horizontal: 10.0, vertical: 10.0), // decoration: BoxDecoration( // borderRadius: BorderRadius.circular(10), // border: Border( // top: BorderSide(width: 1.0, color: Colors.grey), // left: BorderSide(width: 1.0, color: Colors.grey), // right: BorderSide(width: 1.0, color: Colors.grey), // bottom: BorderSide(width: 1.0, color: Colors.grey), // ), // color: Colors.white, // ), // child: Image( // image: AssetImage( // 'assets/images/al-habib_onlne_pharmacy_bg.png'), // fit: BoxFit.cover, // width: 60, // height: 40, // ), // ), // ), // ), // ), // ), // ], // ), // Row( // children: [ // Container( // margin: EdgeInsets.fromLTRB(10.0, 10.0, 0.0, 0.0), // child: Container( // margin: EdgeInsets.only(bottom: 10.0), // child: Container( // margin: EdgeInsets.only(bottom: 10.0), // child: Container( // padding: EdgeInsets.only(left: 5), // child: Container( // padding: EdgeInsets.symmetric( // horizontal: 10.0, vertical: 10.0), // decoration: BoxDecoration( // borderRadius: BorderRadius.circular(10), // border: Border( // top: BorderSide(width: 1.0, color: Colors.grey), // left: BorderSide(width: 1.0, color: Colors.grey), // right: BorderSide(width: 1.0, color: Colors.grey), // bottom: BorderSide(width: 1.0, color: Colors.grey), // ), // color: Colors.white, // ), // child: Image( // image: AssetImage( // 'assets/images/al-habib_onlne_pharmacy_bg.png'), // fit: BoxFit.cover, // width: 60, // height: 40, // ), // ), // ), // ), // ), // ), // ], // ), // ], // ), // ); //} topBrand() { return BaseView( onModelReady: (model) => model.getTopBrandsData(), builder: (_, model, wi) => GridView.count( crossAxisCount: 4, children: List.generate( model.topBrandsListList.length, (index) => Column( children: [ Container( margin: EdgeInsets.fromLTRB(5.0, 10.0, 5.0, 0.0), child: Container( child: Container( child: Container( // padding: EdgeInsets.only(left: 5), child: Container( padding: EdgeInsets.symmetric( horizontal: 10.0, vertical: 10.0), decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), border: Border( top: BorderSide(width: 1.0, color: Colors.grey), left: BorderSide(width: 1.0, color: Colors.grey), right: BorderSide(width: 1.0, color: Colors.grey), bottom: BorderSide(width: 1.0, color: Colors.grey), ), color: Colors.white, ), child: Image.network( model.topBrandsListList[index].image.src.trim(), fit: BoxFit.cover, width: 60, height: 40, ), ), ), ), ), ), ], ), ), ), ); } brandSearch() { return Text('ENAD'); } class SearchBar extends SearchDelegate { @override List buildActions(BuildContext context) { return [ IconButton( icon: Icon(Icons.clear), onPressed: () { query = ""; }, ) ]; } @override Widget buildLeading(BuildContext context) { return IconButton( icon: AnimatedIcon( icon: AnimatedIcons.menu_arrow, progress: transitionAnimation, ), onPressed: () { close(context, null); }, ); } @override Widget buildResults(BuildContext context) { return Container( height: 100, width: 100, child: Card( color: Colors.red, child: Center( child: Text(query), ), ), ); } @override Widget buildSuggestions(BuildContext context) { return ListView.builder( itemCount: 5, itemBuilder: (context, index) => ListTile( leading: Icon(Icons.location_city), title: Text("Enad"), onTap: () { showResults(context); }, ), ); } }