-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from FEUP-LEIC-ES-2022-23/clean-the-code
Clean the code
- Loading branch information
Showing
11 changed files
with
465 additions
and
62 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -68,4 +68,4 @@ flutter { | |
|
||
dependencies { | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" | ||
} | ||
} |
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,8 @@ | ||
## This file must *NOT* be checked into Version Control Systems, | ||
# as it contains information specific to your local configuration. | ||
# | ||
# Location of the SDK. This is only used by Gradle. | ||
# For customization when using a Version Control System, please read the | ||
# header note. | ||
#Sat Mar 25 17:32:41 GMT 2023 | ||
sdk.dir=C\:\\Users\\jmigu\\AppData\\Local\\Android\\Sdk |
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,39 @@ | ||
{ | ||
"project_info": { | ||
"project_number": "334262529386", | ||
"project_id": "rateit-9097c", | ||
"storage_bucket": "rateit-9097c.appspot.com" | ||
}, | ||
"client": [ | ||
{ | ||
"client_info": { | ||
"mobilesdk_app_id": "1:334262529386:android:fff4dd6a225bd656ca0913", | ||
"android_client_info": { | ||
"package_name": "com.example.my_app" | ||
} | ||
}, | ||
"oauth_client": [ | ||
{ | ||
"client_id": "334262529386-jsub15sr8eou4jmipr7n5sjs6gf650j9.apps.googleusercontent.com", | ||
"client_type": 3 | ||
} | ||
], | ||
"api_key": [ | ||
{ | ||
"current_key": "AIzaSyCbHyARFUxe_FIyRvKlNL4Oqe2SeLGG0dQ" | ||
} | ||
], | ||
"services": { | ||
"appinvite_service": { | ||
"other_platform_oauth_client": [ | ||
{ | ||
"client_id": "334262529386-jsub15sr8eou4jmipr7n5sjs6gf650j9.apps.googleusercontent.com", | ||
"client_type": 3 | ||
} | ||
] | ||
} | ||
} | ||
} | ||
], | ||
"configuration_version": "1" | ||
} |
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,27 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:my_app/model/review.dart'; | ||
|
||
|
||
class Company{ | ||
final String name; | ||
double averageRating; | ||
List<Review> reviews; | ||
|
||
Company({ | ||
required this.name, | ||
this.averageRating = 0, | ||
required this.reviews, | ||
}); | ||
|
||
void addReview(Review review){ | ||
|
||
double temp = averageRating; | ||
|
||
reviews.add(review); | ||
|
||
averageRating = (temp * (reviews.length - 1) + review.rating)/reviews.length ; | ||
|
||
} | ||
} | ||
|
||
|
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,25 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class Review { | ||
final String title; | ||
final String review; | ||
final String author; | ||
final int rating; | ||
int? votes; | ||
|
||
Review({ | ||
required this.title, | ||
required this.review, | ||
required this.author, | ||
required this.rating, | ||
this.votes, | ||
}); | ||
|
||
void upvote() { | ||
votes = (votes ?? 0) + 1; | ||
} | ||
|
||
void downvote() { | ||
votes = (votes ?? 0) - 1; | ||
} | ||
} |
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,13 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class CreditsPage extends StatelessWidget { | ||
@override | ||
Widget build(BuildContext context) { | ||
return Center( | ||
child: Text( | ||
'Credits:\n\nFrancisco Campos\nDiogo Silva\nJoão Figueiredo\nTiago Simões\nPedro Plácido', | ||
style: TextStyle(fontSize: 24), | ||
), | ||
); | ||
} | ||
} |
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,141 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:my_app/screens/credits_page.dart'; | ||
import 'package:my_app/screens/rating_page.dart'; | ||
import 'package:my_app/model/review.dart'; | ||
import 'package:my_app/screens/reviews_page.dart'; | ||
import 'package:my_app/model/company.dart'; | ||
|
||
import '../model/company.dart'; | ||
|
||
class MyHomePage extends StatefulWidget { | ||
MyHomePage({Key? key}) : super(key: key); | ||
|
||
|
||
|
||
@override | ||
_MyHomePageState createState() => _MyHomePageState(); | ||
} | ||
|
||
|
||
|
||
|
||
class _MyHomePageState extends State<MyHomePage> { | ||
int _selectedIndex = 0; | ||
final List<Widget> _pages = [ HomePage(), CreditsPage()]; | ||
|
||
void _onItemTapped(int index) { | ||
setState(() { | ||
_selectedIndex = index; | ||
}); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
title: Text('Rate IT'), | ||
), | ||
body: _pages[_selectedIndex], | ||
bottomNavigationBar: BottomNavigationBar( | ||
items: const <BottomNavigationBarItem>[ | ||
BottomNavigationBarItem( | ||
icon: Icon(Icons.home), | ||
label: 'Home', | ||
), | ||
BottomNavigationBarItem( | ||
icon: Icon(Icons.people), | ||
label: 'Credits', | ||
), | ||
], | ||
currentIndex: _selectedIndex, | ||
onTap: _onItemTapped, | ||
), | ||
); | ||
} | ||
} | ||
|
||
class HomePage extends StatelessWidget { | ||
|
||
Company company = Company(name: 'Mockup ITeration 1', reviews:[ | ||
] | ||
); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Center( | ||
child: Column( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: [ | ||
Row( | ||
mainAxisAlignment: MainAxisAlignment.spaceEvenly, | ||
children: [ | ||
ElevatedButton( | ||
onPressed: () { | ||
Navigator.push( | ||
context, | ||
MaterialPageRoute(builder: (context) => EventRatingPage(company: company)), | ||
); | ||
}, | ||
child: Text('Rate Event 1'), | ||
), | ||
ElevatedButton( | ||
onPressed: () { | ||
|
||
Navigator.push( | ||
context, | ||
MaterialPageRoute( | ||
builder: (context) => ReviewsPage(company: company,), | ||
), | ||
); | ||
}, | ||
child: Text('See Reviews'), | ||
), | ||
], | ||
), | ||
SizedBox(height: 16), | ||
Row( | ||
mainAxisAlignment: MainAxisAlignment.spaceEvenly, | ||
children: [ | ||
ElevatedButton( | ||
onPressed: () { | ||
Navigator.push( | ||
context, | ||
MaterialPageRoute(builder: (context) => EventRatingPage(company: company)), | ||
); | ||
}, | ||
child: Text('Rate Event 2'), | ||
), | ||
ElevatedButton( | ||
onPressed: () { | ||
// TODO: Implement see reviews functionality | ||
}, | ||
child: Text('See Reviews'), | ||
), | ||
], | ||
), | ||
SizedBox(height: 16), | ||
Row( | ||
mainAxisAlignment: MainAxisAlignment.spaceEvenly, | ||
children: [ | ||
ElevatedButton( | ||
onPressed: () { | ||
Navigator.push( | ||
context, | ||
MaterialPageRoute(builder: (context) => EventRatingPage(company:company)), | ||
); | ||
}, | ||
child: Text('Rate Event 3'), | ||
), | ||
ElevatedButton( | ||
onPressed: () { | ||
// TODO: Implement see reviews functionality | ||
}, | ||
child: Text('See Reviews'), | ||
), | ||
], | ||
), | ||
], | ||
), | ||
); | ||
} | ||
} |
Oops, something went wrong.