Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- Handled exceptions
  • Loading branch information
umair13adil committed Feb 4, 2023
1 parent 3033fa9 commit c9bfde3
Show file tree
Hide file tree
Showing 54 changed files with 216 additions and 215 deletions.
18 changes: 14 additions & 4 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,31 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 31
compileSdkVersion 33

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = '1.8'
}

lintOptions {
disable 'InvalidPackage'
checkReleaseBuilds false
}

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.openflutter.openflutterecommerce"
minSdkVersion 18
targetSdkVersion 31
targetSdkVersion 33
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down
10 changes: 4 additions & 6 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
buildscript {
ext.kotlin_version = '1.3.50'
ext.kotlin_version = '1.5.20'
repositories {
google()
jcenter()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.android.tools.build:gradle:4.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}

rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}

Expand Down
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
2 changes: 1 addition & 1 deletion ios/Flutter/.last_build_id
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0e81f4131a64923bd5ca5804c4d3b13f
2a331d4dad0001170383022c3954ea22
4 changes: 2 additions & 2 deletions lib/data/model/category.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ class ProductCategory extends Equatable {
return ProductCategory(
entity.id,
parentId: entity.parentId,
name: entity.title,
name: entity.title!,
description: entity.description,
image: CommerceImage(
0,//TODO: remove id from CommerceImage
entity.image,
entity.image!,
''
)
);
Expand Down
10 changes: 5 additions & 5 deletions lib/data/model/product.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,16 @@ class Product extends Equatable {
}
List<ProductCategory> categories = [];
if ( entity.categories.isNotEmpty ){
entity.categories.forEach((category) => categories.add(ProductCategory(category.id, name: category.title, image: CommerceImage.placeHolder())));
entity.categories.forEach((category) => categories.add(ProductCategory(category.id, name: category.title!, image: CommerceImage.placeHolder())));
}
List<HashTag> hashTags = [];
if ( entity.hashTags.isNotEmpty ){
entity.hashTags.forEach((hashTag) => hashTags.add(HashTag(id: hashTag.id, title: hashTag.title)));
if ( entity.hashTags!.isNotEmpty == true ){
entity.hashTags!.forEach((hashTag) => hashTags.add(HashTag(id: hashTag.id, title: hashTag.title)));
}
return Product(
entity.id,
title: entity.title,
subTitle: entity.subTitle,
subTitle: entity.subTitle!,
shortDescription: entity.description,
description: entity.description,
price: entity.price ?? 0,
Expand All @@ -117,7 +117,7 @@ class Product extends Equatable {
images: images,
//TODO: add selectable attributes selectableAttributes: [],
isFavorite: entity.isFavourite,
selectableAttributes: entity.selectableAttributes, created: DateTime.now(), properties: {}
selectableAttributes: entity.selectableAttributes!, created: DateTime.now(), properties: {}
);
} else {
throw EntityModelMapperException(message: 'Entity should be of type ProductEntity');
Expand Down
2 changes: 1 addition & 1 deletion lib/data/model/promo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Promo extends Equatable {
promoCode: entity.promoCode,
discount: entity.discountPercent,
textColor: Colors.white,
daysLeft: entity.dateExpires.difference(DateTime.now()).inDays,
daysLeft: entity.dateExpires!.difference(DateTime.now()).inDays,
image: ""
);
} else {
Expand Down
7 changes: 3 additions & 4 deletions lib/data/network/network_status.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import 'package:data_connection_checker/data_connection_checker.dart';


abstract class NetworkStatus {
Future<bool> get isConnected;
}

class NetworkStatusImpl implements NetworkStatus {
final DataConnectionChecker connectionChecker;

NetworkStatusImpl(this.connectionChecker);
NetworkStatusImpl();

@override
Future<bool> get isConnected => connectionChecker.hasConnection;
Future<bool> get isConnected => Future.value(true);
}
2 changes: 1 addition & 1 deletion lib/data/repositories/abstract/cart_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ abstract class CartRepository {
Future<Promo> getAppliedPromo();

///applies promo to cart
Future setPromo(Promo promo);
Future setPromo(Promo? promo);

//get cart total price
double getTotalPrice();
Expand Down
4 changes: 2 additions & 2 deletions lib/data/repositories/cart_repository_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ class CartRepositoryImpl extends CartRepository{
}

@override
Future setPromo(Promo promo) async {
cartProductDataStorage.appliedPromo = promo;
Future setPromo(Promo? promo) async {
cartProductDataStorage.appliedPromo = promo!;
}

@override
Expand Down
2 changes: 1 addition & 1 deletion lib/data/woocommerce/models/promo_code_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class PromoCodeModel extends PromoCodeEntity {
'amount': discountPercent,
'discount_type': 'percent',
'description': title,
'date_expires':DateFormat('yyyy-MM-ddTHH:mm:ss').format(dateExpires)
'date_expires':DateFormat('yyyy-MM-ddTHH:mm:ss').format(dateExpires!)
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ class RemoteProductRepository extends ProductRepository {
int pageSize = AppConsts.page_size,
int categoryId = 0,
bool isFavorite = false,
SortRules sortRules = const SortRules(),
required FilterRules filterRules}) async {
SortRules sortRules = const SortRules(), FilterRules? filterRules}) async {
// TODO: implement getProducts
try
{
Expand Down
37 changes: 15 additions & 22 deletions lib/domain/entities/product/product_category_entity.dart
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
import 'package:openflutterecommerce/domain/entities/entity.dart';

class ProductCategoryEntity extends Entity<int> {
final String title;
final String description;
final String image;
final String thumb;
final int parentId;
final int orderNumber;
final int count;
final String? title;
final String? description;
final String? image;
final String? thumb;
final int? parentId;
final int? orderNumber;
final int? count;

ProductCategoryEntity(
{required int id,
required this.title,
required this.description,
required this.image,
required this.thumb,
required this.parentId,
required this.orderNumber,
required this.count}) : super(id);
{required int id, this.title, this.description, this.image, this.thumb, this.parentId, this.orderNumber, this.count}) : super(id);

@override
Map<String, dynamic> toMap() {
Expand All @@ -36,12 +29,12 @@ class ProductCategoryEntity extends Entity<int> {
@override
List<Object> get props => [
id,
title,
description,
image,
thumb,
parentId,
orderNumber,
count
title!,
description!,
image!,
thumb!,
parentId!,
orderNumber!,
count!
];
}
16 changes: 6 additions & 10 deletions lib/domain/entities/product/product_entity.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import 'package:openflutterecommerce/domain/entities/product/product_category_en

class ProductEntity extends Entity<int> {
final String title;
final String subTitle;
final String? subTitle;
final List<String> images;
final String thumb;
final double price;
final double discountPercent;
final List<ProductCategoryEntity> categories;
final List<HashTagEntity> hashTags;
final List<HashTagEntity>? hashTags;
final int amount;
final String description;
final bool isFavourite;
Expand All @@ -22,21 +22,17 @@ class ProductEntity extends Entity<int> {
final int rating3Count;
final int rating4Count;
final int rating5Count;
final List<ProductAttribute> selectableAttributes;
final List<ProductAttribute>? selectableAttributes;

ProductEntity(
{required int id,
required this.title,
required this.subTitle,
required this.title, this.subTitle,
required this.images,
required this.thumb,
required double price,
required double discountPercent,
required List<ProductCategoryEntity> categories,
required List<HashTagEntity> hashTags,
required double discountPercent, List<ProductCategoryEntity>? categories, List<HashTagEntity>? hashTags,
required this.amount,
required this.description,
required this.selectableAttributes,
required this.description, this.selectableAttributes,
required bool isFavourite,
rating,
rating1Count,
Expand Down
7 changes: 3 additions & 4 deletions lib/domain/entities/promo/promo_code_entity.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class PromoCodeEntity extends Entity<int> {
final double discountPercent;
final bool belongsToUser;
final bool wasUsed;
final DateTime dateExpires;
final DateTime? dateExpires;

PromoCodeEntity(
{required int id,
Expand All @@ -16,8 +16,7 @@ class PromoCodeEntity extends Entity<int> {
required this.promoCode,
required this.discountPercent,
required this.belongsToUser,
required this.wasUsed,
required this.dateExpires}) : super(id);
required this.wasUsed, this.dateExpires}) : super(id);

@override
Map<String, dynamic> toMap() {
Expand All @@ -42,6 +41,6 @@ class PromoCodeEntity extends Entity<int> {
discountPercent,
belongsToUser,
wasUsed,
dateExpires
dateExpires!
];
}
7 changes: 3 additions & 4 deletions lib/domain/entities/user/shipping_address_entity.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@ class ShippingAddressEntity extends Entity<int> {
final String city;
final String country;
final String postal;
final bool isDefault;
final bool? isDefault;

ShippingAddressEntity(
{required int id,
required this.title,
required this.address,
required this.city,
required this.country,
required this.postal,
required this.isDefault}) : super(id);
required this.postal, this.isDefault}) : super(id);

@override
Map<String, dynamic> toMap() {
Expand All @@ -38,6 +37,6 @@ class ShippingAddressEntity extends Entity<int> {
city,
country,
postal,
isDefault
isDefault!
];
}
7 changes: 3 additions & 4 deletions lib/domain/entities/user/user_entity.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class UserEntity extends Entity<int> {
final String email;
final String password;
final String birthDate;
final String token;
final String? token;
final bool salesNotification;
final bool newArrivalsNotification;
final bool deliveryStatusChanges;
Expand All @@ -17,8 +17,7 @@ class UserEntity extends Entity<int> {
required this.avatar,
required this.email,
required this.password,
required this.birthDate,
required this.token,
required this.birthDate, this.token,
required this.salesNotification,
required this.newArrivalsNotification,
required this.deliveryStatusChanges}) : super(id);
Expand Down Expand Up @@ -47,7 +46,7 @@ class UserEntity extends Entity<int> {
email,
password,
birthDate,
token,
token!,
salesNotification,
newArrivalsNotification,
deliveryStatusChanges
Expand Down
4 changes: 2 additions & 2 deletions lib/domain/usecases/cart/get_cart_products_use_case.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ class GetCartProductsUseCaseImpl implements GetCartProductsUseCase {
}

class GetCartProductParams {
final Promo appliedPromo;
final Promo? appliedPromo;

GetCartProductParams({required this.appliedPromo});
GetCartProductParams({this.appliedPromo});
}

class GetCartProductsException implements Exception {}
Expand Down
Loading

0 comments on commit c9bfde3

Please sign in to comment.