Skip to content
This repository was archived by the owner on Feb 20, 2023. It is now read-only.

demands page filter menu fixed #189

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions assets/translations/ar-SY.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@
"demands_type": "İhtiyaç türü ({})",
"you_can_only_select_10_categories": "En fazla 10 ihtiyaç eklenebilir.",
"clear": "Temizle",
"clear_filters": "Filtereleri Temizle",
"help_demands": "Yardım Talepleri",
"help_demands_not_found": "Yardım Talepleri Bulunamadı",
"my_support_demand": "Destek Talebim",
"create_demand": "Talep Oluştur",
"recreate_demand": "Talebi Yeniden Oluştur",
Expand Down
2 changes: 2 additions & 0 deletions assets/translations/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@
"demands_type": "İhtiyaç türü ({})",
"you_can_only_select_10_categories": "En fazla 10 ihtiyaç eklenebilir.",
"clear": "Temizle",
"clear_filters": "Filtereleri Temizle",
"help_demands": "Yardım Talepleri",
"help_demands_not_found": "Yardım Talepleri Bulunamadı",
"my_support_demand": "Destek Talebim",
"create_demand": "Talep Oluştur",
"recreate_demand": "Talebi Yeniden Oluştur",
Expand Down
2 changes: 2 additions & 0 deletions assets/translations/tr-TR.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@
"demands_type": "İhtiyaç türü ({})",
"you_can_only_select_10_categories": "En fazla 10 ihtiyaç eklenebilir.",
"clear": "Temizle",
"clear_filters": "Filtereleri Temizle",
"help_demands": "Yardım Talepleri",
"help_demands_not_found": "Yardım Talepleri Bulunamadı",
"my_support_demand": "Destek Talebim",
"create_demand": "Talep Oluştur",
"recreate_demand": "Talebi Yeniden Oluştur",
Expand Down
156 changes: 121 additions & 35 deletions lib/pages/demands_page/demands_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ import 'package:afet_destek/data/repository/demands_repository.dart';
import 'package:afet_destek/gen/translations/locale_keys.g.dart';
import 'package:afet_destek/pages/demands_page/state/demands_cubit.dart';
import 'package:afet_destek/pages/demands_page/widgets/demand_filter_popup.dart';
import 'package:afet_destek/pages/demands_page/widgets/demand_title.dart';
import 'package:afet_destek/pages/demands_page/widgets/demands_page_appbar.dart';
import 'package:afet_destek/pages/demands_page/widgets/generic_grid_list.dart';
import 'package:afet_destek/pages/demands_page/widgets/list_view_responsive.dart';
import 'package:afet_destek/pages/demands_page/widgets/mobile_list_view.dart';
import 'package:afet_destek/shared/extensions/translation_extension.dart';
import 'package:afet_destek/shared/state/app_cubit.dart';
import 'package:afet_destek/shared/theme/color_extensions.dart';
import 'package:afet_destek/shared/widgets/loader.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -68,6 +70,7 @@ class _DemandsPageViewState extends State<_DemandsPageView> {

@override
Widget build(BuildContext context) {
final size = MediaQuery.of(context).size;
final state = context.watch<DemandsCubit>().state;
final demands = state.demands;

Expand All @@ -81,46 +84,129 @@ class _DemandsPageViewState extends State<_DemandsPageView> {
isAuthorized: widget.isAuthorized,
hasAnyFilters: state.hasAnyFilters,
),
body: demands.isEmpty
? Center(
child: Text(
state.hasAnyFilters
? LocaleKeys.can_not_find_result_try_clearing_filters
.getStr()
: LocaleKeys.no_demand_yet.getStr(),
textAlign: TextAlign.center,
body: Column(
mainAxisAlignment: size.width >= 1000
? MainAxisAlignment.start
: MainAxisAlignment.center,
children: [
if (size.width >= 1000 && demands.isEmpty)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 100),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
DemandTitle(
title: LocaleKeys.help_demands_not_found.getStr(),
),
Builder(
builder: (ctx) {
return TextButton.icon(
onPressed: () => Scaffold.of(ctx).openEndDrawer(),
icon: Stack(
children: [
Icon(
Icons.filter_list,
color: context.appColors.black,
),
if (state.hasAnyFilters) ...[
Positioned(
top: 0,
right: 0,
child: Container(
width: 8,
height: 8,
decoration: BoxDecoration(
color: context.appColors.mainRed,
shape: BoxShape.circle,
),
),
),
],
],
),
label: Text(
LocaleKeys.filter.getStr(),
style: Theme.of(context)
.textTheme
.headlineSmall
?.copyWith(
color: context.appColors.black,
),
),
);
},
),
],
),
SizedBox(
height: size.height / 2 - 100,
),
],
),
),
if (demands.isEmpty)
Center(
child: Column(
children: [
Text(
state.hasAnyFilters
? LocaleKeys.can_not_find_result_try_clearing_filters
.getStr()
: LocaleKeys.no_demand_yet.getStr(),
textAlign: TextAlign.center,
),
const SizedBox(
height: 20,
),
ElevatedButton(
onPressed: () {
context.read<DemandsCubit>().setFilters(
categoryIds: null,
filterRadiusKm: null,
);
},
child: Text(LocaleKeys.clear_filters.getStr()),
)
],
),
)
: Center(
child: ListViewResponsive(
desktop: GenericListView(
scrollController: _scrollController,
demands: demands,
state: state,
maxWidth: 1450,
crossAxisCount: 3,
),
mobile: MobileList(
scrollController: _scrollController,
demands: demands,
state: state,
),
tablet: GenericListView(
scrollController: _scrollController,
demands: demands,
state: state,
maxWidth: 1000,
crossAxisCount: 2,
),
largeDesktop: GenericListView(
scrollController: _scrollController,
demands: demands,
state: state,
maxWidth: 2200,
crossAxisCount: 4,
else
Expanded(
child: Center(
child: ListViewResponsive(
desktop: GenericListView(
scrollController: _scrollController,
demands: demands,
state: state,
maxWidth: 1450,
crossAxisCount: 3,
),
mobile: MobileList(
scrollController: _scrollController,
demands: demands,
state: state,
),
tablet: GenericListView(
scrollController: _scrollController,
demands: demands,
state: state,
maxWidth: 1000,
crossAxisCount: 2,
),
largeDesktop: GenericListView(
scrollController: _scrollController,
demands: demands,
state: state,
maxWidth: 2200,
crossAxisCount: 4,
),
),
),
),
],
),
endDrawer: DemandFilterDrawer(
demandsCubit: context.read<DemandsCubit>(),
),
Expand Down
15 changes: 7 additions & 8 deletions lib/pages/demands_page/widgets/demand_filter_popup.dart
Original file line number Diff line number Diff line change
Expand Up @@ -231,15 +231,14 @@ class _DemandFilterDrawerState extends State<DemandFilterDrawer> {
ElevatedButton getElevatedButton({required bool isFilterButton}) {
return ElevatedButton(
onPressed: isFilterButton ? _onSave : _onClear,
style: ButtonStyle(
backgroundColor: MaterialStatePropertyAll<Color>(
isFilterButton ? context.appColors.mainRed : context.appColors.white,
),
shape: MaterialStatePropertyAll<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
style: ElevatedButton.styleFrom(
backgroundColor: isFilterButton
? context.appColors.mainRed
: context.appColors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
padding: EdgeInsets.zero,
),
child: Text(
isFilterButton ? LocaleKeys.filter.getStr() : LocaleKeys.clear.getStr(),
Expand Down
12 changes: 7 additions & 5 deletions lib/pages/demands_page/widgets/demand_title.dart
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import 'package:afet_destek/gen/translations/locale_keys.g.dart';
import 'package:afet_destek/shared/extensions/translation_extension.dart';
import 'package:afet_destek/shared/theme/color_extensions.dart';
import 'package:flutter/material.dart';

class DemandTitle extends StatelessWidget {
const DemandTitle({
super.key,
required this.title,
});

final String title;
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(15),
child: Text(
LocaleKeys.help_demands.getStr(),
style: Theme.of(context).textTheme.displaySmall,
title,
style: Theme.of(context).textTheme.headlineSmall?.copyWith(
color: context.appColors.black,
),
),
);
}
Expand Down
27 changes: 0 additions & 27 deletions lib/pages/demands_page/widgets/demands_page_appbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -132,33 +132,6 @@ class DemandPageAppBar extends StatelessWidget implements PreferredSizeWidget {
),
),
const SizedBox(width: 12),
Builder(
builder: (ctx) {
return IconButton(
icon: Stack(
children: [
const Icon(Icons.filter_list),
if (hasAnyFilters) ...[
Positioned(
top: 0,
right: 0,
child: Container(
width: 8,
height: 8,
decoration: BoxDecoration(
color: context.appColors.mainRed,
shape: BoxShape.circle,
),
),
),
],
],
),
onPressed: () => Scaffold.of(ctx).openEndDrawer(),
);
},
),
const SizedBox(width: 8),
],
),
);
Expand Down
46 changes: 45 additions & 1 deletion lib/pages/demands_page/widgets/generic_grid_list.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import 'package:afet_destek/data/models/demand.dart';
import 'package:afet_destek/gen/translations/locale_keys.g.dart';
import 'package:afet_destek/pages/demands_page/state/demands_state.dart';
import 'package:afet_destek/pages/demands_page/widgets/demand_card.dart';
import 'package:afet_destek/pages/demands_page/widgets/demand_title.dart';
import 'package:afet_destek/shared/extensions/translation_extension.dart';
import 'package:afet_destek/shared/theme/color_extensions.dart';
import 'package:afet_destek/shared/widgets/app_info_banner.dart';
import 'package:afet_destek/shared/widgets/loader.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -33,7 +36,48 @@ class GenericListView extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const AppInfoBanner(),
const DemandTitle(),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
DemandTitle(title: LocaleKeys.help_demands.getStr()),
Builder(
builder: (ctx) {
return TextButton.icon(
onPressed: () => Scaffold.of(ctx).openEndDrawer(),
icon: Stack(
children: [
Icon(
Icons.filter_list,
color: context.appColors.black,
),
if (state.hasAnyFilters) ...[
Positioned(
top: 0,
right: 0,
child: Container(
width: 8,
height: 8,
decoration: BoxDecoration(
color: context.appColors.mainRed,
shape: BoxShape.circle,
),
),
),
],
],
),
label: Text(
LocaleKeys.filter.getStr(),
style:
Theme.of(context).textTheme.headlineSmall?.copyWith(
color: context.appColors.black,
),
),
);
},
),
],
),
Expanded(
child: MasonryGridView.builder(
// crossAxisCount: crossAxisCount,
Expand Down
9 changes: 8 additions & 1 deletion lib/pages/demands_page/widgets/mobile_list_view.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import 'package:afet_destek/data/models/demand.dart';
import 'package:afet_destek/gen/translations/locale_keys.g.dart';
import 'package:afet_destek/pages/demands_page/state/demands_cubit.dart';
import 'package:afet_destek/pages/demands_page/state/demands_state.dart';
import 'package:afet_destek/pages/demands_page/widgets/demand_card.dart';
import 'package:afet_destek/pages/demands_page/widgets/demand_title.dart';
import 'package:afet_destek/shared/extensions/translation_extension.dart';
import 'package:afet_destek/shared/theme/color_extensions.dart';
import 'package:afet_destek/shared/widgets/app_info_banner.dart';
import 'package:afet_destek/shared/widgets/loader.dart';
Expand Down Expand Up @@ -37,7 +39,12 @@ class MobileList extends StatelessWidget {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (index == 0) ...[const AppInfoBanner(), const DemandTitle()],
if (index == 0) ...[
const AppInfoBanner(),
DemandTitle(
title: LocaleKeys.help_demands.getStr(),
)
],
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 16,
Expand Down
Loading