Skip to content

Commit

Permalink
fixed all issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Kunalpal215 committed Jun 28, 2023
1 parent a056e01 commit 090b12b
Show file tree
Hide file tree
Showing 17 changed files with 131 additions and 176 deletions.
8 changes: 3 additions & 5 deletions lib/models/contacts/contact_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,21 @@ part 'contact_model.g.dart';
@JsonSerializable(explicitToJson: true)
class ContactModel {
@JsonKey(defaultValue: "Untitled")
late String name;
late String sectionName;
@JsonKey(defaultValue: [])
late List<ContactDetailsModel> contacts;
@JsonKey(defaultValue: "")
late String group;

//Constructor
ContactModel(
{required this.name, required this.contacts, required this.group});
{required this.sectionName, required this.contacts});

factory ContactModel.fromJson(Map<String, dynamic> json) =>
_$ContactModelFromJson(json);

Map<String, dynamic> toJson() => _$ContactModelToJson(this);
//This constructor also does the work of initialising the variables
// ContactModel.fromJson(Map<String, dynamic> json) {
// name = json['name'];
// sectionName = json['sectionName'];
// parent = 'Campus';
// contacts = [];
// List<dynamic>.from(json['contacts']).forEach((element) {
Expand Down
6 changes: 2 additions & 4 deletions lib/models/contacts/contact_model.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 5 additions & 27 deletions lib/models/food/dish_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,15 @@ part 'dish_model.g.dart';
@JsonSerializable()
class DishModel {
@JsonKey(defaultValue: "Unnamed")
late String name;
@JsonKey(defaultValue: false)
late bool veg;
@JsonKey(
defaultValue: " ",
fromJson: ingredientsFromJson,
toJson: ingredientsToJson)
late String ingredients;
late String itemName;
@JsonKey(defaultValue: 2)
late int waiting_time;
@JsonKey(defaultValue: 150)
late int price;

String image;
String imageURL;

DishModel(
{required this.name,
required this.veg,
required this.ingredients,
required this.waiting_time,
{required this.itemName,
required this.price,
this.image =
this.imageURL =
"https://d4t7t8y8xqo0t.cloudfront.net/resized/750X436/eazytrendz%2F3070%2Ftrend20210218124824.jpg"});

factory DishModel.fromJson(Map<String, dynamic> json) =>
Expand All @@ -42,13 +29,4 @@ class DishModel {
// waiting_time = json['waiting_time'] ?? "Not Known";
// price = json['price'] ?? "Not Known";
// }
}

String ingredientsFromJson(List<dynamic> ing) {
return ing.toString();
}

List<String> ingredientsToJson(String ing) {
ing = ing.substring(1, ing.length - 1);
return ing.split(',').toList();
}
}
18 changes: 5 additions & 13 deletions lib/models/food/dish_model.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 12 additions & 16 deletions lib/models/food/restaurant_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,49 +8,45 @@ part 'restaurant_model.g.dart';
@JsonSerializable(explicitToJson: true)
class RestaurantModel {
@JsonKey(defaultValue: "Untitled Restaurant")
late String name;
late String outletName;

@JsonKey(defaultValue: " ")
late String caption;

@JsonKey(defaultValue: "10:00 PM")
late String closing_time;
late String closingTime;

@JsonKey(defaultValue: "2 hrs")
late String waiting_time;
@JsonKey(defaultValue: "IIT Guwahati")
late String location;

@JsonKey(defaultValue: " ", fromJson: fromJsonPhone, toJson: toJsonPhone)
late String phone_number;
late String phoneNumber;

@JsonKey(defaultValue: 26.19247153449412)
late double latitude;

@JsonKey(defaultValue: 91.6993500129393)
late double longitude;

@JsonKey(defaultValue: " ")
late String address;

@JsonKey(defaultValue: [])
late List<String> tags;

@JsonKey(defaultValue: [])
late List<DishModel> menu;

@JsonKey(name: "imageURL")
late String image;
@JsonKey(defaultValue: "https://dw7n6pv5zdng0.cloudfront.net/modules/0001/04/thumb_3251_modules_big.jpeg")
late String imageURL;

RestaurantModel(
{required this.name,
{required this.outletName,
required this.caption,
required this.closing_time,
required this.waiting_time,
required this.phone_number,
required this.closingTime,
required this.phoneNumber,
required this.latitude,
required this.longitude,
required this.address,
required this.location,
required this.tags,
required this.image});
required this.imageURL});

// RestaurantModel.fromJson(Map<String, dynamic> json) {
// name = json['name'] ?? "Unnamed";= "https://live.staticflickr.com/3281/5813689894_a558bb341f_b.jpg"
Expand Down
25 changes: 12 additions & 13 deletions lib/models/food/restaurant_model.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/models/travel/day_type_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ part 'day_type_model.g.dart';
class DayType {
final List<DateTime> fromCampus;
final List<DateTime> toCampus;
DayType(
const DayType(
{
required this.fromCampus,
required this.toCampus,
Expand Down
2 changes: 0 additions & 2 deletions lib/models/travel/travel_timing_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ class TravelTiming {
final String type;
@JsonKey(defaultValue: '')
final String stop;
@JsonKey(defaultValue: [])
final DayType weekend;
@JsonKey(defaultValue: [])
final DayType weekdays;


Expand Down
18 changes: 9 additions & 9 deletions lib/models/travel/travel_timing_model.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/pages/contact/contact.dart
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class _ContactPageState extends State<ContactPage> {
});
for (var e in alphabets) {
people["$e ADONOTUSE"] = ContactModel(
name: "Random", contacts: [], group: "");
sectionName: "Random", contacts: []);
}
return AlphabetScrollView(
list: people.keys.map((e) => AlphaModel(e)).toList(),
Expand Down
18 changes: 9 additions & 9 deletions lib/pages/contact/contact_detail.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,18 @@ class _ContactDetailsPageState extends State<ContactDetailsPage> {
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Text(
widget.contact!.name,
widget.contact!.sectionName,
style: MyFonts.w600.size(16).setColor(kWhite),
),
),
const Expanded(child: SizedBox()),
Padding(
padding: const EdgeInsets.only(right: 8.0),
child: Text(
widget.contact!.group,
style: MyFonts.w400.size(14).setColor(kGrey2),
),
)
// const Expanded(child: SizedBox()),
// Padding(
// padding: const EdgeInsets.only(right: 8.0),
// child: Text(
// widget.contact!.group,
// style: MyFonts.w400.size(14).setColor(kGrey2),
// ),
// )
],
),
Row(
Expand Down
23 changes: 13 additions & 10 deletions lib/services/data_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ class DataProvider {
var cachedData = await LocalStorage.instance.getRecord(DatabaseRecords.restaurant);

if (cachedData == null) {
print("INSIDE RESTRAURENTS GET");
List<Map<String, dynamic>> restaurantData =
await APIService().getRestaurantData();

print(restaurantData);
List<RestaurantModel> restaurants =
restaurantData.map((e) => RestaurantModel.fromJson(e)).toList();

await LocalStorage.instance.storeData(restaurantData, DatabaseRecords.restaurant);

return restaurants;
}

return cachedData
.map((e) => RestaurantModel.fromJson(e as Map<String, dynamic>))
.toList();
Expand Down Expand Up @@ -85,21 +85,24 @@ class DataProvider {
static Future<SplayTreeMap<String, ContactModel>> getContacts() async {
var cachedData = await LocalStorage.instance.getRecord(DatabaseRecords.contacts);
SplayTreeMap<String, ContactModel> people = SplayTreeMap();

if (cachedData == null) {
List<Map<String, dynamic>> contactData =
await APIService().getContactData();
List<Map<String, dynamic>> contactData = await APIService().getContactData();
print("GET CONTACT DATA");
print(contactData);
for (var element in contactData) {
people[element['name']] = ContactModel.fromJson(element);
people[element['sectionName']] = ContactModel.fromJson(element);
print("HERE NFJ");
}
await LocalStorage.instance.storeData(contactData, DatabaseRecords.contacts);
return people;
}
for (var element in cachedData) {
var x = element as Map<String, dynamic>;
people[x['name']] = ContactModel.fromJson(x);
else {
for (var element in cachedData) {
var x = element as Map<String, dynamic>;
people[x['name']] = ContactModel.fromJson(x);
}
return people;
}
return people;
}


Expand Down
Loading

0 comments on commit 090b12b

Please sign in to comment.