This repository has been archived on 2023-11-13. You can view files and clone it, but cannot push or open issues or pull requests.
imagini/web_native/lib/screens/home_screen.dart
2021-02-11 15:47:42 -05:00

106 lines
2.7 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
class HomeScreen extends StatefulWidget {
static const String PATH = '/Home';
HomeScreen({Key key}) : super(key: key);
@override
_HomeScreenState createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
// HomeBloc bloc;
void _init(){
// if(null == bloc){
// bloc = HomeBloc(AppProvider.getApplication(context));
// }
}
@override
void dispose() {
super.dispose();
// bloc.dispose();
}
@override
Widget build(BuildContext context) {
_init();
return PlatformScaffold(
body: _buildGridView(),
bottomNavBar: _buildNavBar()
);
}
Widget _buildNavBar() {
return PlatformNavBar(
currentIndex: 0,
itemChanged: (index) => setState(
() {
// _selectedTabIndex = index;
print(index);
},
),
items: [
BottomNavigationBarItem(
label: "Gallery",
icon: Icon(PlatformIcons(context).collections),
),
BottomNavigationBarItem(
label: "Me",
icon: Icon(PlatformIcons(context).person),
),
BottomNavigationBarItem(
label: "Settings",
icon: Icon(PlatformIcons(context).settings),
),
],
);
}
Widget _buildGridView() {
// return GridView.builder(
// itemCount: 5,
// gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(
// childAspectRatio: (1 / 1),
// crossAxisCount: 2),
// itemBuilder: (BuildContext context, int index) {
// return _buildCard("https://i.imgur.com/CgSGqUz.jpeg");
// }
// );
return new StaggeredGridView.countBuilder(
crossAxisCount: 4,
itemCount: 80,
itemBuilder: (BuildContext context, int index) => _buildCard("https://i.imgur.com/CgSGqUz.jpeg"),
// itemBuilder: (BuildContext context, int index) => new Container(
// color: Colors.green,
// child: new Center(
// child: new CircleAvatar(
// backgroundColor: Colors.white,
// child: new Text('$index'),
// ),
// )),
staggeredTileBuilder: (int index) =>
// new StaggeredTile.count(2, index.isEven ? 2 : 1),
new StaggeredTile.fit(2),
mainAxisSpacing: 4.0,
crossAxisSpacing: 4.0,
);
}
Widget _buildCard(charImageUrl) {
return new Image.network(
charImageUrl,
fit: BoxFit.contain,
);
}
}