Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions android/build/.last_build_id
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1bb2a21ff13ffb469b0dfcac2f14d315
7 changes: 5 additions & 2 deletions android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
org.gradle.jvmargs=-Xmx1536M
org.gradle.jvmargs=-Xmx8192m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
android.useAndroidX=true
android.enableJetifier=true
android.enableJetifier=true
org.gradle.parallel=true
org.gradle.caching=true
org.gradle.daemon=true
1 change: 1 addition & 0 deletions android/untranslated.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
88 changes: 48 additions & 40 deletions lib/controllers/auth_state_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AuthStateController extends GetxController {
Client client = AppwriteService.getClient();
final Databases databases = AppwriteService.getDatabases();
var isInitializing = false.obs;
// FirebaseMessaging messaging = FirebaseMessaging.instance;
FirebaseMessaging messaging = FirebaseMessaging.instance;
late final Account account = AppwriteService.getAccount();
late String? uid;
late String? profileImageID;
Expand All @@ -35,6 +35,14 @@ class AuthStateController extends GetxController {

FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
FlutterLocalNotificationsPlugin();
static AndroidNotificationDetails androidNotificationDetails =
AndroidNotificationDetails('your channel id', 'your channel name',
channelDescription: 'your channel description',
importance: Importance.max,
priority: Priority.high,
ticker: 'ticker');
static NotificationDetails notificationDetails =
NotificationDetails(android: androidNotificationDetails);

Future<void> initializeLocalNotifications() async {
const AndroidInitializationSettings initializationSettingsAndroid =
Expand Down Expand Up @@ -71,43 +79,43 @@ class AuthStateController extends GetxController {
await setUserProfileData();

// ask for settings permissions
// NotificationSettings settings = await messaging.requestPermission(
// alert: true,
// announcement: false,
// badge: true,
// carPlay: false,
// criticalAlert: false,
// provisional: false,
// sound: true,
// );
NotificationSettings settings = await messaging.requestPermission(
alert: true,
announcement: false,
badge: true,
carPlay: false,
criticalAlert: false,
provisional: false,
sound: true,
);

await initializeLocalNotifications();

const AndroidNotificationDetails androidNotificationDetails =
AndroidNotificationDetails('your channel id', 'your channel name',
channelDescription: 'your channel description',
importance: Importance.max,
priority: Priority.high,
ticker: 'ticker');
const NotificationDetails notificationDetails =
NotificationDetails(android: androidNotificationDetails);

// Listen to notitifcations in foreground
// FirebaseMessaging.onMessage.listen((RemoteMessage message) async {
// if (message.notification != null) {
// RegExp exp = RegExp(r'The room (\w+) will Start Soon');
// RegExpMatch? matches = exp.firstMatch(message.notification!.body!);
// String discussionName = matches!.group(1)!;
FirebaseMessaging.onMessage.listen((RemoteMessage message) async {
if (message.notification != null) {
RegExp exp = RegExp(r'The room (\w+) will Start Soon');
RegExpMatch? matches = exp.firstMatch(message.notification!.body!);
if (matches != null) {
String discussionName = matches.group(1)!;

// // send local notification
// await flutterLocalNotificationsPlugin.show(
// 0,
// message.notification!.title,
// message.notification!.body,
// notificationDetails,
// payload: discussionName);
// }
// });
// send local notification
await flutterLocalNotificationsPlugin.show(
0,
message.notification!.title,
message.notification!.body,
notificationDetails,
payload: discussionName);
} else {
await flutterLocalNotificationsPlugin.show(
0,
message.notification!.title,
message.notification!.body,
notificationDetails,
);
}
}
});
}

Future<bool> get getLoginState async {
Expand Down Expand Up @@ -141,7 +149,7 @@ class AuthStateController extends GetxController {

update();
} catch (e) {
log("Error originating from setUserProfileData" + e.toString());
log("Error originating from setUserProfileData$e");
} finally {
isInitializing.value = false;
}
Expand Down Expand Up @@ -176,7 +184,7 @@ class AuthStateController extends GetxController {
}

Future<void> addRegistrationTokentoSubscribedandCreatedUpcomingRooms() async {
// final fcmToken = await messaging.getToken();
final fcmToken = await messaging.getToken();

//subscribed Upcoming Rooms
List<Document> subscribedUpcomingRooms = await databases.listDocuments(
Expand All @@ -188,7 +196,7 @@ class AuthStateController extends GetxController {
for (var subscription in subscribedUpcomingRooms) {
List<dynamic> registrationTokens =
subscription.data['registrationTokens'];
// registrationTokens.add(fcmToken!);
registrationTokens.add(fcmToken!);
databases.updateDocument(
databaseId: upcomingRoomsDatabaseId,
collectionId: subscribedUserCollectionId,
Expand All @@ -205,7 +213,7 @@ class AuthStateController extends GetxController {
]).then((value) => value.documents);
for (var upcomingRoom in createdUpcomingRooms) {
List<dynamic> creatorFcmTokens = upcomingRoom.data['creator_fcm_tokens'];
// creatorFcmTokens.add(fcmToken!);
creatorFcmTokens.add(fcmToken!);
databases.updateDocument(
databaseId: upcomingRoomsDatabaseId,
collectionId: upcomingRoomsCollectionId,
Expand All @@ -215,7 +223,7 @@ class AuthStateController extends GetxController {
}

Future<void> removeRegistrationTokenFromSubscribedUpcomingRooms() async {
// final fcmToken = await messaging.getToken();
final fcmToken = await messaging.getToken();

//subscribed Upcoming Rooms
List<Document> subscribedUpcomingRooms = await databases.listDocuments(
Expand All @@ -227,7 +235,7 @@ class AuthStateController extends GetxController {
for (var subscription in subscribedUpcomingRooms) {
List<dynamic> registrationTokens =
subscription.data['registrationTokens'];
// registrationTokens.remove(fcmToken!);
registrationTokens.remove(fcmToken!);
databases.updateDocument(
databaseId: upcomingRoomsDatabaseId,
collectionId: subscribedUserCollectionId,
Expand All @@ -244,7 +252,7 @@ class AuthStateController extends GetxController {
]).then((value) => value.documents);
for (var upcomingRoom in createdUpcomingRooms) {
List<dynamic> creatorFcmTokens = upcomingRoom.data['creator_fcm_tokens'];
// creatorFcmTokens.remove(fcmToken!);
creatorFcmTokens.remove(fcmToken!);
databases.updateDocument(
databaseId: upcomingRoomsDatabaseId,
collectionId: upcomingRoomsCollectionId,
Expand Down
1 change: 0 additions & 1 deletion lib/controllers/edit_profile_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class EditProfileController extends GetxController {

final ThemeController themeController = Get.find<ThemeController>();

// final ThemeController themeController = Get.find<ThemeController>();
late final Storage storage;
late final Databases databases;

Expand Down
16 changes: 6 additions & 10 deletions lib/controllers/explore_story_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import 'dart:io' as io;
import 'package:appwrite/appwrite.dart';
import 'package:appwrite/models.dart';
import 'package:audio_metadata_reader/audio_metadata_reader.dart';
// import 'package:audiotags/audiotags.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:palette_generator/palette_generator.dart';
import 'package:resonate/controllers/auth_state_controller.dart';
import 'package:resonate/models/chapter.dart';
import 'package:resonate/models/story.dart';
Expand Down Expand Up @@ -198,11 +196,10 @@ class ExploreStoryController extends GetxController {
Color primaryColor;

if (!coverImgPath.contains('http')) {
PaletteGenerator paletteGenerator =
await PaletteGenerator.fromImageProvider(
FileImage(io.File(coverImgPath)));
ColorScheme imageColorScheme = await ColorScheme.fromImageProvider(
provider: FileImage(io.File(coverImgPath)));

primaryColor = paletteGenerator.dominantColor!.color;
primaryColor = imageColorScheme.primary;
} else {
primaryColor = const Color(0xffcbc6c6);
}
Expand Down Expand Up @@ -231,10 +228,9 @@ class ExploreStoryController extends GetxController {
Color primaryColor;

if (!coverImgUrl.contains("http")) {
PaletteGenerator paletteGenerator =
await PaletteGenerator.fromImageProvider(
FileImage(io.File(coverImgUrl)));
primaryColor = paletteGenerator.dominantColor!.color;
ColorScheme imageColorScheme = await ColorScheme.fromImageProvider(
provider: FileImage(io.File(coverImgUrl)));
primaryColor = imageColorScheme.primary;
coverImgUrl = await uploadFileToAppwriteGetUrl(
storyBucketId, storyId, coverImgRef, "story cover");
} else {
Expand Down
Loading