-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Firebase Query for Team Screen * Model Code Fix * Event Screen Firebase Query * Code Updated * Removed Commented Code * Minor Changes
- Loading branch information
1 parent
2f8247a
commit d3e6586
Showing
9 changed files
with
167 additions
and
131 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,48 @@ | ||
class EventsImagesModel { | ||
String image; | ||
String title; | ||
String subTitle; | ||
String about; | ||
class EventsModel { | ||
String? image; | ||
String? title; | ||
String? subTitle; | ||
String? about; | ||
String? startDate; | ||
String? endDate; | ||
List? winners; | ||
List? organizers; | ||
List? sponsors; | ||
|
||
EventsImagesModel({ | ||
EventsModel({ | ||
required this.image, | ||
required this.title, | ||
required this.subTitle, | ||
required this.about, | ||
required this.winners, | ||
required this.organizers, | ||
required this.sponsors, | ||
required this.startDate, | ||
required this.endDate, | ||
}); | ||
} | ||
Map toMap(EventsModel event) { | ||
Map<String, dynamic> teamMap = Map<String, dynamic>(); | ||
teamMap['title'] = event.title; | ||
teamMap['subtitle'] = event.subTitle; | ||
teamMap['about'] = event.about; | ||
teamMap['image'] = event.image; | ||
teamMap['winners'] = event.winners; | ||
teamMap['organizers'] = event.organizers; | ||
teamMap['sponsors'] = event.sponsors; | ||
teamMap['startDate'] = event.startDate; | ||
teamMap['endDate'] = event.endDate; | ||
return teamMap; | ||
} | ||
|
||
const String staticAbout = | ||
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. "; | ||
List<EventsImagesModel> eventsImages = [ | ||
EventsImagesModel( | ||
image: "hackathon.png", | ||
title: "AMU Battlegrounds", | ||
subTitle: "Global Hackathon", | ||
about: staticAbout, | ||
), | ||
EventsImagesModel( | ||
image: "hacktober.png", | ||
title: "Hacktoberfest 2021", | ||
subTitle: "One contribution at a time", | ||
about: staticAbout, | ||
), | ||
EventsImagesModel( | ||
image: "opensource.png", | ||
title: "Introduction to Open Source", | ||
subTitle: "How to make your first contribution?", | ||
about: staticAbout, | ||
), | ||
]; | ||
EventsModel.fromMap(doc) { | ||
title = doc['title']; | ||
subTitle = doc['subtitle']; | ||
about = doc['about']; | ||
image = doc['image']; | ||
winners = doc['winners']; | ||
organizers = doc['organizers']; | ||
sponsors = doc['sponsors']; | ||
startDate = doc['startDate']; | ||
endDate = doc['endDate']; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import 'package:cloud_firestore/cloud_firestore.dart'; | ||
import 'package:mlsa_amu/models/events.dart'; | ||
|
||
class EventService { | ||
Future fetchEventDetails() async { | ||
QuerySnapshot query; | ||
List<EventsModel> eventsList = []; | ||
query = await FirebaseFirestore.instance.collection('event').orderBy('createdAt').get(); | ||
query.docs.forEach((element) { | ||
EventsModel event = EventsModel.fromMap(element.data()); | ||
eventsList.add(event); | ||
}); | ||
|
||
return eventsList; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.