Skip to content

Commit

Permalink
Merge pull request #84 from praveenkrishna0512/sharecredits
Browse files Browse the repository at this point in the history
 share credits for lending listings
  • Loading branch information
summerthia02 authored Jul 20, 2022
2 parents 23378e9 + 40ca676 commit 19c00e1
Show file tree
Hide file tree
Showing 11 changed files with 109 additions and 15 deletions.
Binary file added images/sharecredits.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions lib/firebase/firestore_methods.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class FireStoreMethods {
String profImageUrl,
bool forRent,
String price,
String shareCredits,
double longitude,
double latitude,
String location,
Expand Down Expand Up @@ -56,6 +57,7 @@ class FireStoreMethods {
uid: listingId,
available: true,
price: price,
shareCredits: shareCredits,
forRent: forRent,
createdByEmail: createdByEmail,
usersLiked: [],
Expand Down
2 changes: 2 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
import 'package:justsharelah_v1/firebase/auth_service.dart';
import 'package:justsharelah_v1/pages/favourites.dart';
import 'package:justsharelah_v1/pages/review_page.dart';
import 'package:justsharelah_v1/pages/sharecredits.dart';
import 'package:justsharelah_v1/utils/apptheme.dart';
import 'package:justsharelah_v1/pages/activity.dart';
import 'package:justsharelah_v1/pages/addListing.dart';
Expand Down Expand Up @@ -53,6 +54,7 @@ class MyApp extends StatelessWidget {
),
'/favourites': (_) => Favourites(),
'/reviews': (_) => const MakeReviewPage(),
'/sharecredits': (_) => const ShareCreditsScreen(),
},
),
);
Expand Down
16 changes: 10 additions & 6 deletions lib/models/ListingCard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ import '../pages/profile_page.dart';
import '../utils/const_templates.dart';

class ListingCard extends StatefulWidget {
const ListingCard({Key? key, this.snap, required this.press})
: super(key: key);
ListingCard({
Key? key,
this.snap,
required this.press,
}) : super(key: key);

final snap;

Expand Down Expand Up @@ -236,13 +239,14 @@ class _ListingCardState extends State<ListingCard> {
SizedBox(
width: 20,
),
widget.snap["forRent"] == true ? Text("\$") : Container(),
Text(
'\$' + widget.snap['price'].toString(),
widget.snap["forRent"] == true
? widget.snap['price'].toString()
: widget.snap["shareCredits"],
style: TextStyle(fontWeight: FontWeight.bold),
),
// Text(snap['usersLiked'] == null
// ? '${snap['usersLiked'].length!} likes'
// : "0 Likes"),
widget.snap["forRent"] == false ? Text(" SC") : Container(),
]),
Row(
children: [
Expand Down
8 changes: 6 additions & 2 deletions lib/models/enlarged_listing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +328,14 @@ class ListingCardDetails extends StatelessWidget {
style: kHeadingText,
),
),
snap["forRent"] == true ? Text("\$") : Container(),
Text(
"\$${snap["price"]}",
style: Theme.of(context).textTheme.headline6,
snap["forRent"] == true
? snap['price'].toString()
: snap["shareCredits"],
style: TextStyle(fontWeight: FontWeight.bold),
),
snap["forRent"] == false ? Text(" SC") : Container(),
],
),
Text(
Expand Down
3 changes: 3 additions & 0 deletions lib/models/listings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class Listing {
final String imageUrl;
final String title;
final String price;
final String shareCredits;
final bool forRent;
final String description;
final bool available;
Expand All @@ -26,6 +27,7 @@ class Listing {
required this.imageUrl,
required this.title,
required this.price,
required this.shareCredits,
required this.forRent,
required this.description,
required this.available,
Expand Down Expand Up @@ -57,6 +59,7 @@ class Listing {
'imageUrl': imageUrl,
'title': title,
'price': price,
'shareCredits': shareCredits,
'forRent': forRent,
'description': description,
'available': available,
Expand Down
16 changes: 15 additions & 1 deletion lib/pages/addListing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class _AddListingPageState extends State<AddListingPage> {
final TextEditingController _brandController = TextEditingController();
final TextEditingController _descriptionController = TextEditingController();
final TextEditingController _locationController = TextEditingController();
final TextEditingController _shareCreditsController = TextEditingController();

//listing image
Uint8List? _image;
Expand Down Expand Up @@ -268,6 +269,7 @@ class _AddListingPageState extends State<AddListingPage> {
userData.imageUrl!,
forRent,
_priceController.text,
_shareCreditsController.text,
longitude,
latitude,
_currentAddress,
Expand Down Expand Up @@ -486,7 +488,19 @@ class _AddListingPageState extends State<AddListingPage> {
child: SizedBox(
width: 5,
)),
buildFormField("Enter Price of Listing ", _priceController),
buildFormField("Price (renting) ", _priceController),
]),
const SizedBox(height: 10.0),
Row(children: <Widget>[
buildFormTitle("ShareCredits"),
const Expanded(
child: SizedBox(
width: 5,
)),
Container(
child: buildFormField(
"ShareCredits (lending) ", _shareCreditsController),
),
]),
const SizedBox(height: 10.0),
Row(children: <Widget>[
Expand Down
4 changes: 1 addition & 3 deletions lib/pages/favourites.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,7 @@ class _FavouritesState extends State<Favourites> {
child: ListingCard(
// collect the data for each indiviudal document at the index
snap: snapshot.data!.docs[index].data(),
// image: listingData[index].imageUrl,
// title: listingData[index].title,
// price: listingData[index].price,

press: () {
Navigator.push(
context,
Expand Down
12 changes: 9 additions & 3 deletions lib/pages/profile_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import 'package:justsharelah_v1/models/user_data.dart';
import 'package:justsharelah_v1/utils/const_templates.dart';
import 'package:justsharelah_v1/utils/image_picker.dart';
import 'package:justsharelah_v1/utils/profile_image.dart';
import 'sharecredits.dart';

class ProfilePage extends StatefulWidget {
ProfilePage({Key? key, required this.email}) : super(key: key);
Expand Down Expand Up @@ -178,9 +179,14 @@ class _ProfilePageState extends State<ProfilePage> {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"ShareCredits: ",
style: kBodyTextSmall.copyWith(fontWeight: FontWeight.bold),
TextButton(
onPressed: () {
Navigator.pushReplacementNamed(context, "/sharecredits");
},
child: Text(
"ShareCredits: ",
style: kBodyTextSmall.copyWith(fontWeight: FontWeight.bold),
),
),
Text(
numShareCreds.toString(),
Expand Down
60 changes: 60 additions & 0 deletions lib/pages/sharecredits.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// share credits rewards page
// only for lending / borrowing listings

import 'package:flutter/material.dart';
import 'package:flutter/src/foundation/key.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:justsharelah_v1/utils/appbar.dart';
import 'package:justsharelah_v1/utils/const_templates.dart';

class ShareCreditsScreen extends StatefulWidget {
const ShareCreditsScreen({Key? key}) : super(key: key);

@override
State<ShareCreditsScreen> createState() => ShareCreditsScreenState();
}

class ShareCreditsScreenState extends State<ShareCreditsScreen> {
ElevatedButton buildButtonField(
String text, Color color, double length, void Function()? onPressed) {
return ElevatedButton(
onPressed: onPressed,
style: ElevatedButton.styleFrom(
padding: EdgeInsets.symmetric(horizontal: length),
primary: color,
shape:
RoundedRectangleBorder(borderRadius: BorderRadius.circular(30))),
child: Text(
text,
style: const TextStyle(
fontSize: 15, letterSpacing: 2.5, color: Colors.black),
),
);
}

@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset("images/sharecredits.png"),
Container(
alignment: Alignment.center,
padding: const EdgeInsets.only(left: 15, right: 20, top: 15),
child: Text(
"Congratulations! You have earned 20 ShareCredits !",
style: kHeadingText.copyWith(backgroundColor: Colors.greenAccent),
textAlign: TextAlign.center,
),
),
const SizedBox(
height: 50,
),
buildButtonField("Yay, Thanks!", Colors.green, 20, () {
Navigator.pushReplacementNamed(context, "/profile");
})
],
));
}
}
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ flutter:
- images/gallery.png
- images/def_dp.png
- images/wallpaper.png
- images/sharecredits.png

# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware
Expand Down

0 comments on commit 19c00e1

Please sign in to comment.