Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Widget appBarWidget(BuildContext context) {
- return PreferredSize(
- preferredSize: Size.fromHeight(80),
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- AppBar(
- elevation: 0.0,
- centerTitle: true,
- iconTheme: IconThemeData(color: HexColor("#49516D")),
- titleSpacing: 0,
- actions: [
- IconButton(
- splashColor: Colors.transparent,
- enableFeedback: true,
- icon: SvgPicture.asset(
- "assets/image/icons/filter.svg",
- color: HexColor("#49516D"),
- ),
- onPressed: () => {
- showModalBottomSheet(
- enableDrag: true,
- isScrollControlled: true,
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.only(
- topRight: Radius.circular(10),
- topLeft: Radius.circular(10),
- ),
- ),
- context: context,
- builder: (context) => SingleChildScrollView(
- child: modalFilter(context) // Buka modal filter,
- ),
- )
- },
- ),
- IconButton(
- splashColor: Colors.transparent,
- icon: Stack(
- children: <Widget>[
- SvgPicture.asset("assets/image/icons/notification.svg"),
- Positioned(
- top: 0.0,
- right: -1.0,
- child: Icon(
- Icons.brightness_1,
- size: 8.0,
- color: Colors.redAccent,
- ),
- ),
- ],
- ),
- onPressed: null,
- )
- ],
- backgroundColor: HexColor("#F9F9F9"),
- )
- ],
- ),
- );
- }
- Widget modalFilter(BuildContext context) {
- void filterListener(BuildContext context, FilterState state) {
- state.maybeMap(
- orElse: () {},
- onLoading: (value) {
- _isLoadingLocation = false;
- _isLoadingPrice = false;
- },
- onResponseLocation: (value) {
- _isLoadingLocation = true;
- _listDataLocation = value.list;
- },
- typePrice: (value) {
- _isLoadingPrice = true;
- _listPriceType = value.list;
- },
- );
- }
- if (_networkStatus) {
- return BlocProvider(
- create: (context) => getIt<FilterCubit>()
- ..getListLocation()
- ..getTypePrice(),
- child: BlocConsumer<FilterCubit, FilterState>(
- listener: filterListener,
- builder: (context, state) {
- return (_isLoadingLocation == true && _isLoadingPrice == true)
- ? Container(
- child: Padding(
- padding: EdgeInsets.only(
- top: 20,
- left: 10,
- right: 10,
- bottom: MediaQuery.of(context).viewInsets.bottom,
- ),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- mainAxisSize: MainAxisSize.min,
- children: [
- Container(
- margin: const EdgeInsets.only(bottom: 20),
- child: Text(
- "Filter Pencarian",
- style: TextStyle(
- fontSize: 18,
- fontWeight: FontWeight.bold,
- ),
- ),
- ),
- priceType(context, _listPriceType), // Widget ChoiceChip
- Container(
- margin: const EdgeInsets.only(
- bottom: 20,
- ),
- child: Center(
- child: ButtonWidget(
- onTap: () {
- print(_priceTypeSelected);
- _listCubit.getListAds(
- typePrice: _priceTypeSelected.id,
- );
- },
- width: 200,
- splashColor: "#dde3f7",
- textColor: "#ffffff",
- label: "Terapkan Filter",
- backgroundColor: "#4F69C7",
- ),
- ),
- ),
- ],
- ),
- ),
- )
- : SizedBox(
- height: 200,
- child: Center(
- child: CircularProgressIndicator(),
- ),
- );
- },
- ),
- );
- } else {
- return SizedBox(
- height: 200,
- child: Center(child: Text("Periksa Koneksi Internet")),
- );
- }
- }
- Widget priceType(BuildContext context, List<PriceType> _listPriceType) {
- return Container(
- margin: EdgeInsets.only(bottom: 15),
- child: Column(
- mainAxisAlignment: MainAxisAlignment.start,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Container(
- margin: EdgeInsets.only(bottom: 5),
- child: Text(
- "Harga yang ditawarkan",
- style: TextStyle(fontSize: 15.0, color: HexColor("#49516D")),
- ),
- ),
- Wrap(
- children: _buildTypePrice(_listPriceType), // Build item
- )
- ],
- ),
- );
- }
- _buildTypePrice(List<PriceType> _listPriceType) {
- List<Widget> choices = List();
- _listPriceType.forEach((item) {
- choices.add(Container(
- padding: EdgeInsets.symmetric(horizontal: 5),
- child: ChoiceChip(
- label: Text(item.type),
- selected: _priceTypeSelected == item,
- onSelected: (selected) {
- setState(() {
- _priceTypeSelected = item;
- });
- },
- ),
- ));
- });
- return choices;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement