Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Timeline extends StatefulWidget {
- PageController pageController;
- Timeline({Key key, this.pageController}) : super(key: key);
- @override
- _HomeState createState() => _HomeState();
- }
- class _HomeState extends State<Timeline>
- with AutomaticKeepAliveClientMixin<Timeline> {
- // final AsyncMemoizer _memoizer = AsyncMemoizer();
- bool get wantKeepAlive => true; //flutter lib method
- bool isAuthorized = false;
- final LocalStorageService storageService = locator<LocalStorageService>();
- final logger = locator<CustomLoggerService>();
- final BrandRepository _brandRepository = BrandRepository();
- // final CategoryRepository _categoryRepository = CategoryRepository();
- @override
- void initState() {
- super.initState();
- }
- bool themeSwitch = false;
- dynamic themeColors() {
- if (themeSwitch) return Colors.black;
- return Colors.greenAccent;
- }
- @override
- Widget build(BuildContext context) {
- super.build(context);
- return DefaultTabController(
- length: 4,
- child: Scaffold(
- backgroundColor: Colors.white,
- appBar: _builAppBarWithTabs(),
- body: Center(
- child: ConstrainedBox(
- constraints: BoxConstraints(maxWidth: 1200),
- child: ListView(
- scrollDirection: Axis.vertical,
- children: <Widget>[
- Padding(
- padding: const EdgeInsets.only(bottom: 150),
- child: Container(
- height: 800,
- child: CustomScrollView(
- scrollDirection: Axis.vertical,
- slivers: <Widget>[
- SliverToBoxAdapter(
- child: MasonryGrid(
- column: getResponsiveColumnNumber(context, 1, 2, 6),
- children: <Widget>[
- // First Bloc
- BlocProvider(
- create: (context) {
- BrandBloc(repository: _brandRepository);
- },
- child: Container(
- width: 200,
- alignment: Alignment.center,
- height: 80,
- child: BrandScreen(
- brandBloc: context.bloc(),
- ),
- ),
- ),
- CategoryScreen(
- // Second Bloc
- categoryBloc: CategoryBloc(
- repository: context.repository(),
- ),
- ),
- Container(
- width: 200,
- alignment: Alignment.center,
- height: 330,
- child: _buildFeaturedItemsList(),
- ),
- Placeholder(
- strokeWidth: 0,
- color: Colors.white,
- )
- ],
- ),
- ),
- ],
- ),
- ),
- ),
- ],
- ),
- ),
- ),
- ),
- );
- }
- Widget _buildFeaturedItemsList() {
- return ListView.separated(
- primary: true,
- addAutomaticKeepAlives: true,
- // addSemanticIndexes: true,
- // addRepaintBoundaries: true,
- shrinkWrap: true,
- padding: EdgeInsets.only(left: 15, right: 15, bottom: 0),
- scrollDirection: Axis.horizontal,
- itemCount: 10,
- itemBuilder: (context, index) {
- return ProductsListItem(
- name: "3 David Klin",
- currentPrice: 249,
- originalPrice: 499,
- discount: 50,
- imageUrl:
- "https://images-na.ssl-images-amazon.com/images/I/71O0zS0DT0L._UX342_.jpg",
- productRate: 3,
- );
- },
- separatorBuilder: (context, index) => const SizedBox(width: 2),
- );
- }
- AppBar _builAppBarWithTabs() {
- return AppBar(
- actionsIconTheme: IconThemeData(
- color: Colors.black,
- ),
- elevation: 0,
- backgroundColor: Colors.white,
- actions: <Widget>[
- Badge(
- showBadge: false,
- position: BadgePosition.topRight(),
- badgeContent: Text('3'),
- child: IconButton(
- icon: FaIcon(FontAwesomeIcons.bell),
- onPressed: () {
- Navigator.of(context).push(
- PageRouteBuilder(
- opaque: false, // set to false
- pageBuilder: (_, __, ___) {
- return Scaffold(
- backgroundColor: Color.fromRGBO(255, 255, 255, 0.9),
- body: Container(
- decoration: BoxDecoration(
- border: Border.all(
- width: 40,
- color: Colors
- .transparent), //color is transparent so that it does not blend with the actual color specified
- borderRadius: const BorderRadius.all(
- const Radius.circular(30.0)),
- // color: Color.fromRGBO(255, 0, 0,
- // 0.5) // Specifies the background color and the opacity
- ),
- child: CustomListView(
- separatorBuilder: (context, index) => Divider(
- thickness: 3,
- height: 10,
- ),
- loadingBuilder: CustomListLoading.defaultBuilder,
- itemBuilder: (context, index, item) {
- return ListTile(
- title: Text(item['title']),
- subtitle: Text(item['body']),
- );
- },
- adapter: NetworkListAdapter(
- url: 'https://jsonplaceholder.typicode.com/posts',
- limitParam: '_limit',
- offsetParam: '_start',
- ),
- empty: Text(
- 'No Notifications !\n Buy something!',
- style: subtitleStyle,
- ),
- header: Center(
- child: Text(
- 'Notifications',
- style: subtitleStyle,
- ),
- ),
- // Item provider adapter (default: null)
- // adapter: ListAdapter (
- // fetchItems: (int offset, int limit) {
- // return ListItems([
- // ListTile(),
- // ]);
- // },
- // ),
- // Callback function to build widget if exception occurs during fetching items
- errorBuilder: (BuildContext context, _,
- CustomListViewState state) {
- return Column(
- children: <Widget>[
- Text('details.error.toString()'),
- RaisedButton(
- onPressed: () => state.loadMore(),
- child: Text('Retry'),
- ),
- ],
- );
- },
- ),
- ),
- );
- },
- ),
- );
- },
- ),
- ),
- IconButton(
- icon: FaIcon(FontAwesomeIcons.search),
- onPressed: () {
- widget.pageController.animateToPage(1,
- duration: Duration(milliseconds: 500),
- curve: Curves.easeInOut);
- }),
- ],
- bottom: TabBar(
- labelPadding: EdgeInsets.symmetric(horizontal: 20),
- indicatorColor: kDarkColor,
- labelColor: kDarkColor,
- indicatorWeight: 2,
- unselectedLabelColor: Colors.black,
- isScrollable: true,
- tabs: [
- Tab(child: Text('Timeline.mostPopularTab'.tr())),
- Tab(child: Text('Timeline.menTab'.tr())),
- Tab(child: Text('Timeline.womenTab'.tr())),
- Tab(child: Text('Timeline.kidsTab'.tr())),
- ],
- ),
- title: logoImage,
- );
- }
- }
Add Comment
Please, Sign In to add comment