Skip to content

Commit

Permalink
NotificationSheet update, bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jumpiniasty committed Jul 23, 2023
1 parent 1b06e5d commit e8c06b7
Show file tree
Hide file tree
Showing 55 changed files with 935 additions and 281 deletions.
2 changes: 1 addition & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<application
android:label="Drinkify"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
android:icon="@mipmap/launcher_icon">
<activity
android:name=".MainActivity"
android:exported="true"
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/drinkify-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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/controllers/auth_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import '../models/create_user.dart';

///Used for logging in and signing up a user
class AuthController {
AuthController._();

///Handles logging in
static Future<bool> loginUser(
String email,
Expand Down
2 changes: 2 additions & 0 deletions lib/controllers/party_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import '../utils/ext.dart' show LatLngConvert;

///Used by the regular user to join, leave, accept party requests and more
class PartyController {
PartyController._();

///Sends a join request to the [party]
static Future<bool> sendJoinRequest(Party party) async {
const storage = FlutterSecureStorage();
Expand Down
49 changes: 48 additions & 1 deletion lib/controllers/party_creator_controller.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'dart:convert';
import 'dart:io';
import 'package:drinkify/models/friend.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:http/http.dart' as http;
import 'package:http_parser/http_parser.dart';
Expand All @@ -9,9 +8,12 @@ import '../utils/consts.dart' show mainUrl;
import '../models/party.dart';
import '../models/party_request.dart';
import '../utils/ext.dart' show LatLngConvert;
import '../models/friend.dart';

/// Used by the party creator to control owned parties
class PartyCreatorController {
PartyCreatorController._();

/// Returns a list of all parties created by the user
static Future<List<Party>> ownedParties() async {
const storage = FlutterSecureStorage();
Expand Down Expand Up @@ -69,6 +71,30 @@ class PartyCreatorController {
return Party.fromMap(jsonDecode(await res.stream.bytesToString()));
}

static Future<bool> updateParty(Party p) async {
const storage = FlutterSecureStorage();
final token = await storage.read(key: "access");
final url = "$mainUrl/parties/${p.publicId}/";
final res = await http.patch(
Uri.parse(url),
body: jsonEncode({
"owner": {},
"name": p.name,
"privacy_status": p.privacyStatus,
"description": p.description,
"location": p.location!.toPOINT(),
"start_time": p.startTime.toIso8601String(),
"stop_time": p.stopTime.toIso8601String(),
}),
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer $token",
},
);

return res.statusCode == 200;
}

/// Deletes party with the provided [id]
static Future<bool> deleteParty(String id) async {
const storage = FlutterSecureStorage();
Expand All @@ -84,6 +110,27 @@ class PartyCreatorController {
return res.statusCode == 204;
}

/// Retrieves all join requests for the party
static Future<List<PartyRequest>> partyJoinRequests(Party p) async {
const storage = FlutterSecureStorage();
final token = await storage.read(key: "access");
final url = "$mainUrl/parties/requests/${p.publicId}/";
final res = await http.get(
Uri.parse(url),
headers: {
"Authorization": "Bearer $token",
},
);
if (res.statusCode == 200) {
final requests = <PartyRequest>[];
for (final pr in jsonDecode(res.body)["results"]) {
requests.add(PartyRequest.fromMap(pr));
}
return requests;
}
return [];
}

/// Accepts incoming party join request
static Future<bool> acceptPartyRequest(PartyRequest req) async {
const storage = FlutterSecureStorage();
Expand Down
2 changes: 2 additions & 0 deletions lib/controllers/search_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import '../utils/ext.dart';

///Used for searching parties and users
class SearchController {
SearchController._();

///Retrieves user's data based on provided [username]
static Future<List<Friend>> searchUserByUsername(String username) async {
const storage = FlutterSecureStorage();
Expand Down
11 changes: 3 additions & 8 deletions lib/controllers/user_controller.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'dart:convert';
import 'dart:io';
import 'package:drinkify/models/friend.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:http/http.dart' as http;
import 'package:http_parser/http_parser.dart';
Expand All @@ -11,9 +10,12 @@ import '../models/user.dart';
import '../models/friend_invitiation.dart';
import '../models/party_invitation.dart';
import '../models/party_request.dart';
import '../models/friend.dart';

/// Used for getting information about the user, updating, deleting and searching
class UserController {
UserController._();

/// Returns information about you
static Future<User> me() async {
const storage = FlutterSecureStorage();
Expand Down Expand Up @@ -141,14 +143,7 @@ class UserController {
final url = "$mainUrl/friends/invitations/${inv.id}/";
final res = await http.post(
Uri.parse(url),
body: jsonEncode({
"sender": {},
"receiver": {},
"receiver_public_id": inv.receiverPublicId,
"sender_public_id": inv.senderPublicId,
}),
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer $token",
},
);
Expand Down
3 changes: 3 additions & 0 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"acceptedNotif": "Accepted",
"rejectedNotif": "Rejected",
"acceptRejectError": "An error occurred",
"notificationSent": "Sent",

"settings": "Settings",
"editProfile": "Edit profile",
Expand Down Expand Up @@ -139,6 +140,8 @@
"createdSuccessfully": "Party created successfully",
"creationFailed": "Party creation failed",
"pickAnImage": "Pick an image",
"updatedPartySuccess": "Party updated successfully",
"updatedPartyFailure": "Could not update party",

"requiredField": "Field required",
"wrongDate": "Start date can't be set after end date"
Expand Down
4 changes: 4 additions & 0 deletions lib/l10n/app_pl.arb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
"acceptedNotif": "Zaakceptowano",
"rejectedNotif": "Odrzucono",
"acceptRejectError": "Wystąpił błąd",
"notificationSent": "Wysłano",


"settings": "Ustawienia",
"editProfile": "Edytuj profil",
Expand Down Expand Up @@ -138,6 +140,8 @@
"createdSuccessfully": "Utworzono imprezę",
"creationFailed": "Nie utworzono imprezy",
"pickAnImage": "Wybierz zdjęcie",
"updatedPartySuccess": "Zaaktualizowano imprezę",
"updatedPartyFailure": "Nie zaaktualizowano imprezy",

"requiredField": "Pole wymagane",
"wrongDate": "Data rozpoczęcia ustawiona po końcu imprezy"
Expand Down
1 change: 0 additions & 1 deletion lib/models/party.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class Party {
});

factory Party.fromMap(Map<String, dynamic> m) {
// print(m["participants"]);
return Party(
publicId: m["public_id"],
owner: Friend.fromMap(m["owner"]),
Expand Down
95 changes: 57 additions & 38 deletions lib/routes/create_party_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import '../widgets/dialogs/success_sheet.dart';
class CreatePartyPage extends StatefulWidget {
final bool isEdit;
final Party? pageToEdit;

const CreatePartyPage({
this.isEdit = false,
this.pageToEdit,
Expand Down Expand Up @@ -119,15 +120,16 @@ class _CreatePartyPageState extends State<CreatePartyPage> with MapUtils {
invitedUsers = [];
errorFields = [];
if (widget.isEdit) {
WidgetsBinding.instance.addPostFrameCallback((_) {
//FIXME fix loading parameters
partyTitle = widget.pageToEdit!.name;
startTime = widget.pageToEdit!.startTime;
endTime = widget.pageToEdit!.stopTime;
partyStatus = widget.pageToEdit!.privacyStatus!;
WidgetsBinding.instance.addPostFrameCallback((_) async {
final address = await latLngToAdress(widget.pageToEdit!.location!);
setState(() {
partyTitle = widget.pageToEdit!.name;
descriptionCtrl.text = widget.pageToEdit!.description;
startTime = widget.pageToEdit!.startTime;
endTime = widget.pageToEdit!.stopTime;
partyStatus = widget.pageToEdit!.privacyStatus!;
selPoint = widget.pageToEdit!.location!;
descriptionCtrl.text = widget.pageToEdit!.description;
selLocation = address;
});
});
}
Expand All @@ -146,7 +148,7 @@ class _CreatePartyPageState extends State<CreatePartyPage> with MapUtils {
}

void _createParty() async {
errorFields = [];
errorFields.clear();
final allFields = <dynamic>[
selPoint,
thumbnail,
Expand Down Expand Up @@ -195,7 +197,47 @@ class _CreatePartyPageState extends State<CreatePartyPage> with MapUtils {
}

void _editParty() async {
//TODO implement
errorFields.clear();
final allFields = <dynamic>[
selPoint,
"Placeholder (do not leave this field empty)",
partyTitle,
startTime,
endTime,
descriptionCtrl.text,
];
final tempErrorList = <int>[];
for (int i = 0; i < allFields.length; i++) {
if (allFields[i] == null) {
tempErrorList.add(i);
} else if (allFields[i] is String && allFields[i].isEmpty) {
tempErrorList.add(i);
}
}
setState(() => errorFields = tempErrorList);
if (errorFields.isNotEmpty && !_wrongDate) return;
final isUpdated = await PartyCreatorController.updateParty(
Party(
publicId: widget.pageToEdit!.publicId,
ownerPublicId: widget.pageToEdit!.ownerPublicId,
privacyStatus: partyStatus,
name: partyTitle,
description: descriptionCtrl.text,
location: selPoint,
startTime: startTime!,
stopTime: endTime!,
),
);
if (!mounted) return;
showModalBottomSheet(
context: context,
backgroundColor: Theming.bgColor,
builder: (ctx) => SuccessSheet(
success: isUpdated,
successMsg: AppLocalizations.of(context)!.updatedPartySuccess,
failureMsg: AppLocalizations.of(context)!.updatedPartyFailure,
),
);
}

@override
Expand Down Expand Up @@ -228,37 +270,10 @@ class _CreatePartyPageState extends State<CreatePartyPage> with MapUtils {
InteractiveFlag.doubleTapZoom -
InteractiveFlag.rotate,
onTap: (_, pos) async {
var loc = <Placemark>[];
try {
loc = await placemarkFromCoordinates(
pos.latitude,
pos.longitude,
);
} catch (_) {
return;
}

final cityFields = <String>[
loc[0].locality!,
loc[0].administrativeArea!,
loc[0].subAdministrativeArea!,
loc[0].subLocality!,
];
String locArea = "";

for (final i in cityFields) {
if (i != "") {
locArea = i;
break;
}
}

bool addComma = locArea != "";

final address = await latLngToAdress(pos);
setState(() {
selPoint = pos;
selLocation =
"${loc[0].country}${addComma ? ", $locArea" : ""}, ${loc[0].street}";
selLocation = address;
});
},
),
Expand Down Expand Up @@ -569,6 +584,7 @@ class _CreatePartyPageState extends State<CreatePartyPage> with MapUtils {
errorFields: errorFields,
selectedFieldIndex: selectedFieldIndex,
onType: (val) => partyTitle = val,
value: partyTitle,
onSelect: (idx) {
setState(() => selectedFieldIndex = idx);
},
Expand All @@ -585,6 +601,7 @@ class _CreatePartyPageState extends State<CreatePartyPage> with MapUtils {
isStart: true,
errorFields: errorFields,
wrongDate: _wrongDate,
initialValue: startTime,
onFinish: (start) {
startTime = start;
},
Expand All @@ -603,6 +620,7 @@ class _CreatePartyPageState extends State<CreatePartyPage> with MapUtils {
isStart: false,
errorFields: errorFields,
wrongDate: _wrongDate,
initialValue: endTime,
onFinish: (end) {
endTime = end;
},
Expand Down Expand Up @@ -660,6 +678,7 @@ class _CreatePartyPageState extends State<CreatePartyPage> with MapUtils {
),
),
PartyStatus(
initialValue: partyStatus,
onSelect: (statusNumber) {
partyStatus = statusNumber;
},
Expand Down
Loading

0 comments on commit e8c06b7

Please sign in to comment.