added filter apply button

This commit is contained in:
Komek Hayytnazarov 2023-03-29 17:30:58 +05:00
parent 4e8ef06b54
commit 0ad4fa8dee
48 changed files with 368 additions and 111 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 B

View File

@ -1,12 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="?android:colorBackground" />
<!-- You can insert your own image assets here -->
<!-- <item>
<bitmap
android:gravity="center"
android:src="@mipmap/launch_image" />
</item> -->
<item>
<bitmap android:gravity="fill" android:src="@drawable/background"/>
</item>
<item>
<bitmap android:gravity="center" android:src="@drawable/splash"/>
</item>
</layer-list>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 B

View File

@ -1,12 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/white" />
<!-- You can insert your own image assets here -->
<!-- <item>
<bitmap
android:gravity="center"
android:src="@mipmap/launch_image" />
</item> -->
<item>
<bitmap android:gravity="fill" android:src="@drawable/background"/>
</item>
<item>
<bitmap android:gravity="center" android:src="@drawable/splash"/>
</item>
</layer-list>

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is off -->
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:forceDarkAllowed">false</item>
<item name="android:windowFullscreen">false</item>
<item name="android:windowSplashScreenBackground">#ffffff</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Flutter UI initializes, as well as behind your Flutter UI while its
running.
This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
</resources>

View File

@ -5,6 +5,8 @@
<!-- Show a splash screen on the activity. Automatically removed when
Flutter draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
<item name="android:forceDarkAllowed">false</item>
<item name="android:windowFullscreen">false</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -36,6 +36,8 @@ PODS:
- Flutter (1.0.0)
- flutter_local_notifications (0.0.1):
- Flutter
- flutter_native_splash (0.0.1):
- Flutter
- FMDB (2.7.5):
- FMDB/standard (= 2.7.5)
- FMDB/standard (2.7.5)
@ -90,6 +92,7 @@ DEPENDENCIES:
- firebase_messaging (from `.symlinks/plugins/firebase_messaging/ios`)
- Flutter (from `Flutter`)
- flutter_local_notifications (from `.symlinks/plugins/flutter_local_notifications/ios`)
- flutter_native_splash (from `.symlinks/plugins/flutter_native_splash/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/ios`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/ios`)
- sqflite (from `.symlinks/plugins/sqflite/ios`)
@ -122,6 +125,8 @@ EXTERNAL SOURCES:
:path: Flutter
flutter_local_notifications:
:path: ".symlinks/plugins/flutter_local_notifications/ios"
flutter_native_splash:
:path: ".symlinks/plugins/flutter_native_splash/ios"
path_provider_foundation:
:path: ".symlinks/plugins/path_provider_foundation/ios"
shared_preferences_foundation:
@ -148,6 +153,7 @@ SPEC CHECKSUMS:
FirebaseMessaging: fd93783258c53ae5cdb9b41bf0c51606a677f2d5
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
flutter_local_notifications: 0c0b1ae97e741e1521e4c1629a459d04b9aec743
flutter_native_splash: 52501b97d1c0a5f898d687f1646226c1f93c56ef
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
GoogleDataTransport: ea169759df570f4e37bdee1623ec32a7e64e67c4
GoogleUtilities: c2bdc4cf2ce786c4d2e6b3bcfd599a25ca78f06f

View File

@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "background.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 B

View File

@ -1,23 +1,56 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "LaunchImage.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"filename" : "LaunchImageDark.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "LaunchImage@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"filename" : "LaunchImageDark@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "LaunchImage@3x.png",
"idiom" : "universal",
"scale" : "3x"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"filename" : "LaunchImageDark@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 B

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 B

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 B

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -16,13 +16,19 @@
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" image="LaunchImage" translatesAutoresizingMaskIntoConstraints="NO" id="YRO-k0-Ey4">
</imageView>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" image="LaunchBackground" translatesAutoresizingMaskIntoConstraints="NO" id="tWc-Dq-wcI"/>
<imageView opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" image="LaunchImage" translatesAutoresizingMaskIntoConstraints="NO" id="YRO-k0-Ey4"></imageView>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="YRO-k0-Ey4" firstAttribute="centerX" secondItem="Ze5-6b-2t3" secondAttribute="centerX" id="1a2-6s-vTC"/>
<constraint firstItem="YRO-k0-Ey4" firstAttribute="centerY" secondItem="Ze5-6b-2t3" secondAttribute="centerY" id="4X2-HB-R7a"/>
<constraint firstItem="YRO-k0-Ey4" firstAttribute="leading" secondItem="Ze5-6b-2t3" secondAttribute="leading" id="3T2-ad-Qdv"/>
<constraint firstItem="tWc-Dq-wcI" firstAttribute="bottom" secondItem="Ze5-6b-2t3" secondAttribute="bottom" id="RPx-PI-7Xg"/>
<constraint firstItem="tWc-Dq-wcI" firstAttribute="top" secondItem="Ze5-6b-2t3" secondAttribute="top" id="SdS-ul-q2q"/>
<constraint firstAttribute="trailing" secondItem="tWc-Dq-wcI" secondAttribute="trailing" id="Swv-Gf-Rwn"/>
<constraint firstAttribute="trailing" secondItem="YRO-k0-Ey4" secondAttribute="trailing" id="TQA-XW-tRk"/>
<constraint firstItem="YRO-k0-Ey4" firstAttribute="bottom" secondItem="Ze5-6b-2t3" secondAttribute="bottom" id="duK-uY-Gun"/>
<constraint firstItem="tWc-Dq-wcI" firstAttribute="leading" secondItem="Ze5-6b-2t3" secondAttribute="leading" id="kV7-tw-vXt"/>
<constraint firstItem="YRO-k0-Ey4" firstAttribute="top" secondItem="Ze5-6b-2t3" secondAttribute="top" id="xPn-NY-SIU"/>
</constraints>
</view>
</viewController>
@ -32,6 +38,7 @@
</scene>
</scenes>
<resources>
<image name="LaunchImage" width="168" height="185"/>
<image name="LaunchImage" width="526" height="526"/>
<image name="LaunchBackground" width="1" height="1"/>
</resources>
</document>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<dict>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>CFBundleDevelopmentRegion</key>
@ -52,5 +52,7 @@
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
</dict>
<key>UIStatusBarHidden</key>
<false/>
</dict>
</plist>

View File

@ -12,9 +12,17 @@ class GridViewLoadMoreWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Transform.translate(
return Column(
children: [
Transform.translate(
offset: Offset(index % 2 == 0 ? context.width / 4 : 0, 0),
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 30),
child: CustomLoader(),
),
),
SizedBox(height: 40),
],
);
}
}

View File

@ -78,7 +78,7 @@ class FilterController extends GetxController {
// if model is selected, then deselect it
if (state.selectedPriceFilterModelId == model.id) {
state.selectedPriceFilterModelId = 0;
state.selectedPriceFilterModelId.value = 0;
state.selectedPriceFilter.value = null;
// state.startPrice.text = '';
// state.endPrice.text = '';
@ -89,7 +89,7 @@ class FilterController extends GetxController {
debugPrint('state.filterableQueryParams ${state.filterableQueryParams}');
} else {
state.selectedPriceFilterModelId = model.id;
state.selectedPriceFilterModelId.value = model.id;
state.selectedPriceFilter.value = model;
// state.startPrice.text = model.start.toString();
// state.endPrice.text = model.end.toString();
@ -109,6 +109,7 @@ class FilterController extends GetxController {
}
void onFilterPageClosed() {
debugPrint('onFilterPageClosed');
ProductListController plc = Get.put(ProductListController());
plc.reset();
plc.fetchProducts();
@ -175,4 +176,26 @@ class FilterController extends GetxController {
state.isFiltersLoading.value = false;
}
void clearAllFilters() {
debugPrint('clearAllFilters');
// clear price filters
state.selectedPriceFilterModelId.value = 0;
state.selectedPriceFilter.value = null;
for (int i = 0; i < state.filterModels.length; i++) {
state.filterModels[i].selectedOptions.clear();
}
state.filterModels.refresh();
final categoryId = state.filterableQueryParams['category_id'];
state.filterableQueryParams.clear();
state.filterableQueryParams['category_id'] = categoryId;
debugPrint('debugPoint');
calculateTotalAppliedFilter();
}
}

View File

@ -22,9 +22,12 @@ class FilterPage extends StatelessWidget {
() => fc.getFilters(),
),
)
: ListView.builder(
: SingleChildScrollView(
child: Column(
children: [
ListView.builder(
shrinkWrap: true,
// physics: NeverScrollableScrollPhysics(),
physics: NeverScrollableScrollPhysics(),
// separatorBuilder: (context, index) => AppTheme.appColorDivider,
itemCount: fc.state.filterModels.length,
itemBuilder: (_, index) => FilterCard(
@ -32,6 +35,21 @@ class FilterPage extends StatelessWidget {
controller: fc,
),
),
// button
fc.state.isFiltersLoading.value
? SizedBox.shrink()
: Padding(
padding: const EdgeInsets.all(16.0),
child: ColoredButton(
title: 'done'.tr,
callback: fc.onFilterPageClosed,
btnColor: ThemeColor.mainColor,
),
),
],
),
),
);
},
);
@ -53,7 +71,6 @@ class FilterCard extends StatelessWidget {
context: context,
builder: (context) => BSChooseFilter(
model: model,
),
);
},
@ -138,3 +155,8 @@ class FilterCard extends StatelessWidget {
);
}
}
/*
,
*/

View File

@ -12,10 +12,10 @@ class FilterState {
int selectedSortModelId = 1;
List<PriceFilterModel> priceModels = [];
int selectedPriceFilterModelId = 0;
RxInt selectedPriceFilterModelId = 0.obs;
Rxn<PriceFilterModel> selectedPriceFilter = new Rxn<PriceFilterModel>();
List<FilterModel> filterModels = [];
RxList<FilterModel> filterModels = <FilterModel>[].obs;
RxInt totalAppliedFilter = 0.obs;
// RxMap<String, dynamic> selectedFilter = <String, dynamic>{}.obs;

View File

@ -2,9 +2,9 @@ import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import '../controller.dart';
import '../../../../app.dart';
final double appbarHeight = kToolbarHeight; //60.h;
final double appbarHeight = 96.h;
class FilterAppbarWidget extends StatelessWidget implements PreferredSizeWidget {
const FilterAppbarWidget({Key? key}) : super(key: key);
@ -65,6 +65,32 @@ class FilterAppbarWidget extends StatelessWidget implements PreferredSizeWidget
),
],
),
SizedBox(height: 8.h),
Row(
children: [
SizedBox(width: 6),
CircleNumberWidget(number: fc.state.totalAppliedFilter.value),
SizedBox(width: 12),
Text(
'applied'.tr,
style: new TextStyle(
fontSize: 14.sp,
color: ThemeColor.color717278,
),
),
Spacer(),
fc.state.totalAppliedFilter.value != 0 && !fc.state.isFiltersLoading.value
? SizedBox(
height: 30.h,
child: TextButton(
child: Text('clear'.tr),
style: TextButton.styleFrom(foregroundColor: ThemeColor.mainColor),
onPressed: fc.clearAllFilters,
),
)
: SizedBox.shrink(),
],
),
],
),
),

View File

@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_native_splash/flutter_native_splash.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:shared_preferences/shared_preferences.dart';
@ -9,23 +10,38 @@ import 'app/core/utils/notification_service.dart';
DBHelper dbHelper = DBHelper();
Future<void> _initAppInitials() async {
WidgetsFlutterBinding.ensureInitialized();
// HttpOverrides.global = MyHttpOverrides();
await ScreenUtil.ensureScreenSize();
await initLoginStatus();
}
// Firebase initials is separated, app needs to be initialized
// regardless Firebase
Future<void> _initFBInitials() async {
try {
await initFCMFunctions();
} catch (e) {
debugPrint('FCM error: $e');
}
}
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await _initAppInitials();
final String locale = await getLocale();
FlutterNativeSplash.remove();
// FB functions needs to init after
/// [FlutterNativeSplash.remove()]
await _initFBInitials();
SharedPreferences prefs = await SharedPreferences.getInstance();
final String? lang = prefs.getString(Constants.LOCALE);
await initLoginStatus();
runApp(ElektronikaShopApp(lang: lang));
runApp(ElektronikaShopApp(lang: locale));
}
class ElektronikaShopApp extends StatelessWidget {

View File

@ -382,6 +382,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.4.2+2"
flutter_native_splash:
dependency: "direct main"
description:
name: flutter_native_splash
sha256: bd36d1a7f05ff8378cad17d20c33ca904630bfd3fcf8b15c9e8237efbccfad0a
url: "https://pub.dev"
source: hosted
version: "2.2.0+1"
flutter_rating_bar:
dependency: "direct main"
description:
@ -909,6 +917,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.3.1"
universal_io:
dependency: transitive
description:
name: universal_io
sha256: "06866290206d196064fd61df4c7aea1ffe9a4e7c4ccaa8fcded42dd41948005d"
url: "https://pub.dev"
source: hosted
version: "2.2.0"
url_launcher:
dependency: "direct main"
description:

View File

@ -43,6 +43,7 @@ dependencies:
firebase_messaging: ^14.1.1
firebase_core: ^2.3.0
flutter_local_notifications: ^12.0.4
flutter_native_splash: ^2.2.0+1
dev_dependencies:
flutter_test:
@ -50,6 +51,10 @@ dev_dependencies:
lint: ^1.7.2
flutter_launcher_icons: "^0.9.2"
flutter_native_splash:
image: assets/logo/icon-rounded.png
color: "#ffffff"
flutter:
uses-material-design: true
fonts:

View File

@ -28,8 +28,16 @@
<title>elektronika</title>
<link rel="manifest" href="manifest.json">
<script src="splash/splash.js"></script>
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport"/>
<link rel="stylesheet" type="text/css" href="splash/style.css">
</head>
<body>
<picture id="splash">
<source srcset="splash/img/light-1x.png 1x, splash/img/light-2x.png 2x, splash/img/light-3x.png 3x, splash/img/light-4x.png 4x" media="(prefers-color-scheme: light)">
<source srcset="splash/img/dark-1x.png 1x, splash/img/dark-2x.png 2x, splash/img/dark-3x.png 3x, splash/img/dark-4x.png 4x" media="(prefers-color-scheme: dark)">
<img class="center" aria-hidden="true" src="splash/img/light-1x.png" alt=""/>
</picture>
<!-- This script installs service_worker.js to provide PWA functionality to
application. For more information, see:
https://developers.google.com/web/fundamentals/primers/service-workers -->

BIN
web/splash/img/dark-1x.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

BIN
web/splash/img/dark-2x.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

BIN
web/splash/img/dark-3x.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
web/splash/img/dark-4x.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

BIN
web/splash/img/light-1x.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

BIN
web/splash/img/light-2x.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

BIN
web/splash/img/light-3x.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
web/splash/img/light-4x.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

7
web/splash/splash.js Normal file
View File

@ -0,0 +1,7 @@
function removeSplashFromWeb() {
const elem = document.getElementById("splash");
if (elem) {
elem.remove();
}
document.body.style.background = "transparent";
}

43
web/splash/style.css Normal file
View File

@ -0,0 +1,43 @@
body {
margin:0;
height:100%;
background: #ffffff;
background-size: 100% 100%;
}
.center {
margin: 0;
position: absolute;
top: 50%;
left: 50%;
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.contain {
display:block;
width:100%; height:100%;
object-fit: contain;
}
.stretch {
display:block;
width:100%; height:100%;
}
.cover {
display:block;
width:100%; height:100%;
object-fit: cover;
}
@media (prefers-color-scheme: dark) {
body {
margin:0;
height:100%;
background: #ffffff;
background-size: 100% 100%;
}
}