72 lines
2.2 KiB
Dart
72 lines
2.2 KiB
Dart
import 'package:birzha/components/baseWidget.dart';
|
|
import 'package:birzha/components/postlist.dart';
|
|
import 'package:birzha/components/searchBar.dart';
|
|
import 'package:birzha/components/tabview.dart';
|
|
import 'package:birzha/constants.dart';
|
|
import 'package:birzha/models/categories/category.dart';
|
|
import 'package:birzha/new/themes/colors.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:birzha/core/lazyload/lazyload.dart';
|
|
import 'package:birzha/models/products/post.dart';
|
|
|
|
class ProductsScreen extends StatefulWidget {
|
|
const ProductsScreen({Key? key, required this.category, required this.route, this.headerToolBar = const []}) : super(key: key);
|
|
|
|
final RemoteCategory category;
|
|
final String route;
|
|
final List<Widget> headerToolBar;
|
|
|
|
@override
|
|
_ProductsScreenState createState() => _ProductsScreenState();
|
|
}
|
|
|
|
class _ProductsScreenState extends State<ProductsScreen> {
|
|
FetchController<Post> controller = FetchController();
|
|
|
|
late RemoteCategory primal;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
primal = widget.category.copy;
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
controller.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return BaseWidget(
|
|
appBar: BaseAppBar(
|
|
color: ThemeColor.white,
|
|
goBack: () {
|
|
Tabnavigator.backDispatcher(context);
|
|
},
|
|
after: [...widget.headerToolBar],
|
|
customChild: primal is! SearchableMixin
|
|
? null
|
|
: ActualSearchBar(
|
|
onSubmit: (word) {
|
|
(primal as SearchableMixin).search(word);
|
|
setState(() {
|
|
controller.refresh();
|
|
});
|
|
},
|
|
route: Tabnavigator.currentRoute(context) + '/${widget.route}'),
|
|
title: primal.name,
|
|
),
|
|
body: Container(
|
|
color: Theme.of(context).backgroundColor,
|
|
child: PostList(
|
|
contentPadding: EdgeInsets.symmetric(horizontal: AppConstants.horizontalPadding(context), vertical: AppConstants.verticalPadding(context)),
|
|
before: [],
|
|
category: primal,
|
|
fetchController: controller),
|
|
),
|
|
);
|
|
}
|
|
}
|