Skip to content

Commit 47c6741

Browse files
author
Abhinav Marwaha
authored
Merge pull request #7 from trendmate/abhinav
Abhinav
2 parents 16acdb8 + 2b7bf14 commit 47c6741

13 files changed

Lines changed: 520 additions & 267 deletions

File tree

analysis_options.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
metrics:
1010
cyclomatic-complexity: 20
1111
maximum-nesting-level: 5
12-
number-of-parameters: 4
12+
# number-of-parameters: 6
1313
source-lines-of-code: 50
1414
metrics-exclude:
1515
- test/**

android/app/build.gradle

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,17 @@ android {
5151
versionName flutterVersionName
5252
multiDexEnabled true
5353
}
54-
54+
// signingConfigs {
55+
// release {
56+
// keyAlias keystoreProperties['keyAlias']
57+
// keyPassword keystoreProperties['keyPassword']
58+
// storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
59+
// storePassword keystoreProperties['storePassword']
60+
// }
61+
// }
5562
buildTypes {
5663
release {
57-
// TODO: Add your own signing config for the release build.
58-
// Signing with the debug keys for now, so `flutter run --release` works.
64+
// signingConfig signingConfigs.release
5965
signingConfig signingConfigs.debug
6066
}
6167
}

android/app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
22
package="com.trendmate.app">
33
<application
4-
android:label="app"
4+
android:label="TrendMate"
55
android:icon="@mipmap/ic_launcher">
66
<activity
77
android:name=".MainActivity"

lib/main.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import 'package:app/providers/products_provider.dart';
1+
import 'package:trendmate/providers/products_provider.dart';
22
import 'package:firebase_core/firebase_core.dart';
33
import 'package:flutter/material.dart';
44
import 'package:provider/provider.dart';
55

6-
import 'package:app/pages/home_page.dart';
7-
import 'package:app/pages/filters_screen.dart';
6+
import 'package:trendmate/pages/home_page.dart';
7+
import 'package:trendmate/pages/filters_screen.dart';
88

99
void main() async {
1010
WidgetsFlutterBinding.ensureInitialized();

lib/models/filter.dart

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import 'dart:convert';
2+
3+
import 'package:flutter/foundation.dart';
4+
5+
class Filter {
6+
double priceStart;
7+
double priceEnd;
8+
List<String> cats;
9+
List<String> sites;
10+
List<String> brands;
11+
List<String> gender;
12+
13+
Filter({
14+
required this.priceStart,
15+
required this.priceEnd,
16+
required this.cats,
17+
required this.sites,
18+
required this.brands,
19+
required this.gender,
20+
});
21+
22+
Map<String, dynamic> toMap() {
23+
return {
24+
'priceStart': priceStart,
25+
'priceEnd': priceEnd,
26+
'cats': cats,
27+
'sites': sites,
28+
'brands': brands,
29+
'gender': gender,
30+
};
31+
}
32+
33+
factory Filter.fromMap(Map<String, dynamic> map) {
34+
return Filter(
35+
priceStart: map['priceStart'],
36+
priceEnd: map['priceEnd'],
37+
cats: List<String>.from(map['cats']),
38+
sites: List<String>.from(map['sites']),
39+
brands: List<String>.from(map['brands']),
40+
gender: List<String>.from(map['gender']),
41+
);
42+
}
43+
44+
String toJson() => json.encode(toMap());
45+
46+
factory Filter.fromJson(String source) => Filter.fromMap(json.decode(source));
47+
48+
@override
49+
String toString() {
50+
return 'Filter(priceStart: $priceStart, priceEnd: $priceEnd, cats: $cats, sites: $sites, brands: $brands, gender: $gender)';
51+
}
52+
53+
@override
54+
bool operator ==(Object other) {
55+
if (identical(this, other)) return true;
56+
57+
return other is Filter &&
58+
other.priceStart == priceStart &&
59+
other.priceEnd == priceEnd &&
60+
listEquals(other.cats, cats) &&
61+
listEquals(other.sites, sites) &&
62+
listEquals(other.brands, brands) &&
63+
listEquals(other.gender, gender);
64+
}
65+
66+
@override
67+
int get hashCode {
68+
return priceStart.hashCode ^
69+
priceEnd.hashCode ^
70+
cats.hashCode ^
71+
sites.hashCode ^
72+
brands.hashCode ^
73+
gender.hashCode;
74+
}
75+
}

lib/models/product.dart

Lines changed: 111 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import 'dart:convert';
2+
13
class Product {
24
final String brand;
35
final String category;
@@ -10,15 +12,113 @@ class Product {
1012
final double trendiness;
1113
final String productUrl;
1214

13-
Product(
14-
{required this.brand,
15-
required this.category,
16-
required this.desc,
17-
required this.imageUrl,
18-
required this.name,
19-
required this.price,
20-
required this.productUrl,
21-
required this.rating,
22-
required this.reviews,
23-
required this.trendiness});
15+
Product({
16+
required this.brand,
17+
required this.category,
18+
required this.desc,
19+
required this.imageUrl,
20+
required this.name,
21+
required this.price,
22+
required this.rating,
23+
required this.reviews,
24+
required this.trendiness,
25+
required this.productUrl,
26+
});
27+
28+
Product copyWith({
29+
String? brand,
30+
String? category,
31+
String? desc,
32+
String? imageUrl,
33+
String? name,
34+
int? price,
35+
double? rating,
36+
int? reviews,
37+
double? trendiness,
38+
String? productUrl,
39+
}) {
40+
return Product(
41+
brand: brand ?? this.brand,
42+
category: category ?? this.category,
43+
desc: desc ?? this.desc,
44+
imageUrl: imageUrl ?? this.imageUrl,
45+
name: name ?? this.name,
46+
price: price ?? this.price,
47+
rating: rating ?? this.rating,
48+
reviews: reviews ?? this.reviews,
49+
trendiness: trendiness ?? this.trendiness,
50+
productUrl: productUrl ?? this.productUrl,
51+
);
52+
}
53+
54+
Map<String, dynamic> toMap() {
55+
return {
56+
'brand': brand,
57+
'category': category,
58+
'desc': desc,
59+
'imageUrl': imageUrl,
60+
'name': name,
61+
'price': price,
62+
'rating': rating,
63+
'reviews': reviews,
64+
'trendiness': trendiness,
65+
'productUrl': productUrl,
66+
};
67+
}
68+
69+
factory Product.fromMap(Map<String, dynamic> map) {
70+
return Product(
71+
brand: map['brand'],
72+
category: map['category'],
73+
desc: map['desc'],
74+
imageUrl: map['imageUrl'],
75+
name: map['name'],
76+
price: map['price'],
77+
rating: map['rating'],
78+
reviews: map['reviews'],
79+
trendiness: map['trendiness'],
80+
productUrl: map['productUrl'],
81+
);
82+
}
83+
84+
String toJson() => json.encode(toMap());
85+
86+
factory Product.fromJson(String source) =>
87+
Product.fromMap(json.decode(source));
88+
89+
@override
90+
String toString() {
91+
return 'Product(brand: $brand, category: $category, desc: $desc, imageUrl: $imageUrl, name: $name, price: $price, rating: $rating, reviews: $reviews, trendiness: $trendiness, productUrl: $productUrl)';
92+
}
93+
94+
@override
95+
bool operator ==(Object other) {
96+
if (identical(this, other)) return true;
97+
98+
return other is Product &&
99+
other.brand == brand &&
100+
other.category == category &&
101+
other.desc == desc &&
102+
other.imageUrl == imageUrl &&
103+
other.name == name &&
104+
other.price == price &&
105+
other.rating == rating &&
106+
other.reviews == reviews &&
107+
other.trendiness == trendiness &&
108+
other.productUrl == productUrl;
109+
}
110+
111+
@override
112+
int get hashCode {
113+
return brand.hashCode ^
114+
category.hashCode ^
115+
desc.hashCode ^
116+
imageUrl.hashCode ^
117+
name.hashCode ^
118+
price.hashCode ^
119+
rating.hashCode ^
120+
reviews.hashCode ^
121+
trendiness.hashCode ^
122+
productUrl.hashCode;
123+
}
24124
}

0 commit comments

Comments
 (0)