diff --git a/assets/images/ref.jpg b/assets/images/ref.jpg new file mode 100644 index 00000000..2462210e Binary files /dev/null and b/assets/images/ref.jpg differ diff --git a/lib/auth/badgeModel.dart b/lib/auth/badgeModel.dart index 7930f6e8..1794df14 100644 --- a/lib/auth/badgeModel.dart +++ b/lib/auth/badgeModel.dart @@ -1,3 +1,4 @@ +import 'package:Prism/logger/logger.dart'; import 'package:flutter/material.dart'; import 'package:hive/hive.dart'; import 'package:json_annotation/json_annotation.dart'; @@ -33,7 +34,7 @@ class Badge { required this.color, required this.url, }) { - debugPrint("Default constructor !!!!"); + logger.d("Default constructor !!!!"); } factory Badge.fromJson(Map json) => _$BadgeFromJson(json); diff --git a/lib/auth/google_auth.dart b/lib/auth/google_auth.dart index 556b1f75..74596eb1 100644 --- a/lib/auth/google_auth.dart +++ b/lib/auth/google_auth.dart @@ -1,5 +1,6 @@ import 'package:Prism/analytics/analytics_service.dart'; import 'package:Prism/auth/userModel.dart'; +import 'package:Prism/logger/logger.dart'; import 'package:Prism/payments/upgrade.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:firebase_auth/firebase_auth.dart'; @@ -50,8 +51,8 @@ class GoogleAuth { if (user != null) { final List usersData = await getUsersData(user); // User exists in both. Therefore go ahead with the new collection, and forget the old one. - print("USERDATA0 ${usersData[0]}"); - print("USERDATA1 ${usersData[1]}"); + logger.d("USERDATA0 ${usersData[0]}"); + logger.d("USERDATA1 ${usersData[1]}"); if (usersData[0] != null && usersData[1] != null) { final doc = usersData[1]!; globals.prismUser = PrismUsersV2.fromDocumentSnapshot(doc, user); @@ -62,7 +63,7 @@ class GoogleAuth { 'lastLoginAt': DateTime.now().toUtc().toIso8601String(), 'loggedIn': true, }); - print("USERDATA CASE1 ${globals.prismUser.toJson()}"); + logger.d("USERDATA CASE1 ${globals.prismUser.toJson()}"); } // User exists in old database. Copy/create him in the new db. else if (usersData[0] != null && usersData[1] == null) { @@ -72,7 +73,7 @@ class GoogleAuth { .collection(USER_NEW_COLLECTION) .doc(globals.prismUser.id) .set(globals.prismUser.toJson()); - print("USERDATA CASE2 ${globals.prismUser.toJson()}"); + logger.d("USERDATA CASE2 ${globals.prismUser.toJson()}"); } // User exists in new database. Simply sign him in. else if (usersData[0] == null && usersData[1] != null) { @@ -85,7 +86,7 @@ class GoogleAuth { 'lastLoginAt': DateTime.now().toUtc().toIso8601String(), 'loggedIn': true, }); - print("USERDATA CASE3 ${globals.prismUser.toJson()}"); + logger.d("USERDATA CASE3 ${globals.prismUser.toJson()}"); } // User exists in none. Create new data in new db and sign him in. else { @@ -107,12 +108,13 @@ class GoogleAuth { coins: 0, subPrisms: [], transactions: [], + coverPhoto: "", ); FirebaseFirestore.instance .collection(USER_NEW_COLLECTION) .doc(globals.prismUser.id) .set(globals.prismUser.toJson()); - print("USERDATA CASE4 ${globals.prismUser.toJson()}"); + logger.d("USERDATA CASE4 ${globals.prismUser.toJson()}"); } await prefs.put('prismUserV2', globals.prismUser); @@ -154,18 +156,19 @@ class GoogleAuth { coins: 0, subPrisms: [], transactions: [], + coverPhoto: "", ); Hive.openBox('prefs').then((value) { value.put('prismUserV2', globals.prismUser); }); await Purchases.reset(); - debugPrint("User Sign Out"); + logger.d("User Sign Out"); return true; } Future isSignedIn() async { await googleSignIn.isSignedIn().then((value) { - debugPrint(value.toString()); + logger.d(value.toString()); return value; }); return false; diff --git a/lib/auth/transactionModel.dart b/lib/auth/transactionModel.dart index 9136d271..943c467d 100644 --- a/lib/auth/transactionModel.dart +++ b/lib/auth/transactionModel.dart @@ -1,3 +1,4 @@ +import 'package:Prism/logger/logger.dart'; import 'package:flutter/material.dart'; import 'package:hive/hive.dart'; import 'package:json_annotation/json_annotation.dart'; @@ -33,7 +34,7 @@ class PrismTransaction { required this.by, required this.processedAt, }) { - debugPrint("Default constructor !!!!"); + logger.d("Default constructor !!!!"); } factory PrismTransaction.fromJson(Map json) => diff --git a/lib/auth/userModel.dart b/lib/auth/userModel.dart index df2fdb5e..222399eb 100644 --- a/lib/auth/userModel.dart +++ b/lib/auth/userModel.dart @@ -1,5 +1,6 @@ import 'package:Prism/auth/badgeModel.dart'; import 'package:Prism/auth/transactionModel.dart'; +import 'package:Prism/logger/logger.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; @@ -47,6 +48,8 @@ class PrismUsersV2 { List transactions; @HiveField(16) String name; + @HiveField(17) + String? coverPhoto; PrismUsersV2({ required this.username, @@ -66,8 +69,9 @@ class PrismUsersV2 { required this.coins, required this.transactions, required this.name, + this.coverPhoto, }) { - debugPrint("Default constructor !!!!"); + logger.d("Default constructor !!!!"); } factory PrismUsersV2.fromJson(Map json) => @@ -98,6 +102,39 @@ class PrismUsersV2 { transactions: (doc.data()!['transactions'] as List ?? []) .map((e) => PrismTransaction.fromJson(e as Map)) .toList(), + coverPhoto: doc.data()!["coverPhoto"]?.toString(), ); + + // factory PrismUsersV2.fromDocumentSnapshotWithoutUser(DocumentSnapshot doc) => + // PrismUsersV2( + // name: (doc.data()!["name"] ?? "").toString(), + // username: (doc.data()!["username"] ?? "") + // .toString() + // .replaceAll(RegExp(r"(?: |[^\w\s])+"), ""), + // email: (doc.data()!["email"] ?? "").toString(), + // id: doc.data()!["id"].toString(), + // createdAt: DateTime.fromMillisecondsSinceEpoch( + // (doc.data()!["createdAt"] as Timestamp).millisecondsSinceEpoch) + // .toUtc() + // .toIso8601String(), + // premium: doc.data()!["premium"] as bool, + // lastLoginAt: doc.data()!["lastLoginAt"]?.toString() ?? + // DateTime.now().toUtc().toIso8601String(), + // links: doc.data()!["links"] as Map ?? {}, + // followers: doc.data()!["followers"] as List ?? [], + // following: doc.data()!["following"] as List ?? [], + // profilePhoto: (doc.data()!["profilePhoto"] ?? "").toString(), + // bio: (doc.data()!["bio"] ?? "").toString(), + // loggedIn: true, + // badges: (doc.data()!['badges'] as List ?? []) + // .map((e) => Badge.fromJson(e as Map)) + // .toList(), + // subPrisms: doc.data()!['subPrisms'] as List ?? [], + // coins: doc.data()!['coins'] as int ?? 0, + // transactions: (doc.data()!['transactions'] as List ?? []) + // .map((e) => PrismTransaction.fromJson(e as Map)) + // .toList(), + // coverPhoto: doc.data()!["coverPhoto"]?.toString(), + // ); Map toJson() => _$PrismUsersV2ToJson(this); } diff --git a/lib/auth/userModel.g.dart b/lib/auth/userModel.g.dart index 1b58ebf9..71734109 100644 --- a/lib/auth/userModel.g.dart +++ b/lib/auth/userModel.g.dart @@ -34,13 +34,14 @@ class PrismUsersV2Adapter extends TypeAdapter { coins: fields[14] as int, transactions: (fields[15] as List).cast(), name: fields[16] as String, + coverPhoto: fields[17] as String?, ); } @override void write(BinaryWriter writer, PrismUsersV2 obj) { writer - ..writeByte(17) + ..writeByte(18) ..writeByte(0) ..write(obj.username) ..writeByte(1) @@ -74,7 +75,9 @@ class PrismUsersV2Adapter extends TypeAdapter { ..writeByte(15) ..write(obj.transactions) ..writeByte(16) - ..write(obj.name); + ..write(obj.name) + ..writeByte(17) + ..write(obj.coverPhoto); } @override @@ -115,6 +118,7 @@ PrismUsersV2 _$PrismUsersV2FromJson(Map json) { .map((e) => PrismTransaction.fromJson(e as Map)) .toList(), name: json['name'] as String, + coverPhoto: json['coverPhoto'] as String?, ); } @@ -137,4 +141,5 @@ Map _$PrismUsersV2ToJson(PrismUsersV2 instance) => 'coins': instance.coins, 'transactions': instance.transactions.map((e) => e.toJson()).toList(), 'name': instance.name, + 'coverPhoto': instance.coverPhoto, }; diff --git a/lib/auth/userOldModel.dart b/lib/auth/userOldModel.dart index b91b0594..aade2678 100644 --- a/lib/auth/userOldModel.dart +++ b/lib/auth/userOldModel.dart @@ -1,4 +1,5 @@ import 'package:Prism/auth/google_auth.dart'; +import 'package:Prism/logger/logger.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/material.dart'; import 'package:hive/hive.dart'; @@ -47,7 +48,7 @@ class PrismUsers { required this.bio, required this.loggedIn, }) { - debugPrint("Default constructor !!!!"); + logger.d("Default constructor !!!!"); } PrismUsers.withSave({ @@ -64,7 +65,7 @@ class PrismUsers { required this.bio, required this.loggedIn, }) { - debugPrint("With Save constructor !!!!"); + logger.d("With Save constructor !!!!"); FirebaseFirestore.instance.collection(USER_NEW_COLLECTION).doc(id).update({ 'bio': bio, 'username': username, @@ -93,7 +94,7 @@ class PrismUsers { this.profilePhoto = "", this.loggedIn = false, }) { - debugPrint("initial constructor !!!!"); + logger.d("initial constructor !!!!"); } PrismUsers.withoutSave({ @@ -110,7 +111,7 @@ class PrismUsers { required this.bio, required this.loggedIn, }) { - debugPrint("Without save constructor !!!!"); + logger.d("Without save constructor !!!!"); FirebaseFirestore.instance.collection(USER_NEW_COLLECTION).doc(id).update({ 'bio': bio, 'username': username, diff --git a/lib/auth/wallpaperModel.dart b/lib/auth/wallpaperModel.dart new file mode 100644 index 00000000..2b3d2441 --- /dev/null +++ b/lib/auth/wallpaperModel.dart @@ -0,0 +1,111 @@ +// import 'package:Prism/auth/badgeModel.dart'; +// import 'package:Prism/auth/transactionModel.dart'; +// import 'package:cloud_firestore/cloud_firestore.dart'; +// import 'package:firebase_auth/firebase_auth.dart'; +// import 'package:flutter/material.dart'; +// import 'package:hive/hive.dart'; +// import 'package:json_annotation/json_annotation.dart'; + +// part 'wallpaperModel.g.dart'; + +// enum WallpaperProvider { Prism, Wallhaven, Pexels } + +// extension WallExtension on WallpaperProvider { +// String get name { +// return this.toString().split('.').last; +// } +// } + +// @HiveType(typeId: 16) +// @JsonSerializable( +// explicitToJson: true, +// ) +// class WallpaperV2 { +// @HiveField(0) +// String username; +// @HiveField(1) +// List collections; +// @HiveField(2) +// String id; +// @HiveField(3) +// DateTime createdAt; +// @HiveField(4) +// String description; +// @HiveField(5) +// String resolution; +// @HiveField(6) +// bool review; +// @HiveField(7) +// String size; +// @HiveField(8) +// String profilePhoto; +// @HiveField(9) +// String wallpaper_provider; +// @HiveField(10) +// String wallpaper_url; +// @HiveField(11) +// String wallpaper_thumb; +// @HiveField(12) +// List subPrisms; +// @HiveField(13) +// bool free; +// @HiveField(14) +// int coins; +// @HiveField(15) +// String link; + +// WallpaperV2({ +// required this.username, +// required this.email, +// required this.id, +// required this.createdAt, +// required this.premium, +// required this.lastLoginAt, +// required this.links, +// required this.followers, +// required this.following, +// required this.profilePhoto, +// required this.bio, +// required this.loggedIn, +// required this.badges, +// required this.subPrisms, +// required this.coins, +// required this.transactions, +// required this.name, +// this.coverPhoto, +// }) { +// logger.d("Default constructor !!!!"); +// } + +// factory PrismUsersV2.fromJson(Map json) => +// _$PrismUsersV2FromJson(json); +// factory PrismUsersV2.fromDocumentSnapshot(DocumentSnapshot doc, User user) => +// PrismUsersV2( +// name: (doc.data()!["name"] ?? user.displayName).toString(), +// username: (doc.data()!["username"] ?? user.displayName) +// .toString() +// .replaceAll(RegExp(r"(?: |[^\w\s])+"), ""), +// email: (doc.data()!["email"] ?? user.email).toString(), +// id: doc.data()!["id"].toString(), +// createdAt: doc.data()!["createdAt"].toString(), +// premium: doc.data()!["premium"] as bool, +// lastLoginAt: doc.data()!["lastLoginAt"]?.toString() ?? +// DateTime.now().toUtc().toIso8601String(), +// links: doc.data()!["links"] as Map ?? {}, +// followers: doc.data()!["followers"] as List ?? [], +// following: doc.data()!["following"] as List ?? [], +// profilePhoto: (doc.data()!["profilePhoto"] ?? user.photoURL).toString(), +// bio: (doc.data()!["bio"] ?? "").toString(), +// loggedIn: true, +// badges: (doc.data()!['badges'] as List ?? []) +// .map((e) => Badge.fromJson(e as Map)) +// .toList(), +// subPrisms: doc.data()!['subPrisms'] as List ?? [], +// coins: doc.data()!['coins'] as int ?? 0, +// transactions: (doc.data()!['transactions'] as List ?? []) +// .map((e) => PrismTransaction.fromJson(e as Map)) +// .toList(), +// coverPhoto: doc.data()!["coverPhoto"]?.toString(), +// ); +// Map toJson() => _$PrismUsersV2ToJson(this); +// } diff --git a/lib/data/collections/provider/collectionsWithoutProvider.dart b/lib/data/collections/provider/collectionsWithoutProvider.dart index fcbb06a7..143668f3 100644 --- a/lib/data/collections/provider/collectionsWithoutProvider.dart +++ b/lib/data/collections/provider/collectionsWithoutProvider.dart @@ -1,3 +1,4 @@ +import 'package:Prism/logger/logger.dart'; import 'package:Prism/routes/router.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/foundation.dart'; @@ -9,7 +10,7 @@ String? currentCollectionName; Future getCollections() async { if (navStack.last == "Home") { - debugPrint("Fetching collections!"); + logger.d("Fetching collections!"); collections = []; await databaseReference .collection("collections") @@ -20,17 +21,17 @@ Future getCollections() async { collections!.add(doc.data()); } }).catchError((e) { - debugPrint(e.toString()); - debugPrint("data done with error"); + logger.d(e.toString()); + logger.d("data done with error"); }); } else { - debugPrint("Refresh blocked"); + logger.d("Refresh blocked"); } return collections; } Future getCollectionWithName(String name) async { - debugPrint("Fetching $name collection's first 24 walls"); + logger.d("Fetching $name collection's first 24 walls"); currentCollectionName = name; anyCollectionWalls = []; await databaseReference @@ -47,7 +48,7 @@ Future getCollectionWithName(String name) async { } Future seeMoreCollectionWithName() async { - debugPrint("Fetching $currentCollectionName collection's more walls"); + logger.d("Fetching $currentCollectionName collection's more walls"); await databaseReference .collection("walls") .where('review', isEqualTo: true) diff --git a/lib/data/favourites/provider/favouriteProvider.dart b/lib/data/favourites/provider/favouriteProvider.dart index bb918c2a..b70a3687 100644 --- a/lib/data/favourites/provider/favouriteProvider.dart +++ b/lib/data/favourites/provider/favouriteProvider.dart @@ -1,6 +1,7 @@ import 'package:Prism/auth/google_auth.dart'; import 'package:Prism/data/pexels/model/wallpaperp.dart'; import 'package:Prism/data/wallhaven/model/wallpaper.dart'; +import 'package:Prism/logger/logger.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/material.dart'; import 'package:Prism/global/globals.dart' as globals; @@ -34,7 +35,7 @@ class FavouriteProvider extends ChangeNotifier { liked = liked!.reversed.toList(); // }); // .catchError((e) { - // debugPrint("data done with error"); + // logger.d("data done with error"); }); return liked; @@ -50,7 +51,7 @@ class FavouriteProvider extends ChangeNotifier { .doc(id) .delete(); } catch (e) { - debugPrint(e.toString()); + logger.d(e.toString()); } await getDataBase(); return true; @@ -131,7 +132,7 @@ class FavouriteProvider extends ChangeNotifier { } } if (index == null) { - debugPrint("Fav"); + logger.d("Fav"); createDataByWall(provider, wallhaven, pexels, prism); localFavSave(provider, wallhaven, pexels, prism); } else { @@ -169,9 +170,9 @@ class FavouriteProvider extends ChangeNotifier { Future countFav() async { int favs = 0; - debugPrint("in countfav"); + logger.d("in countfav"); await getDataBase().then((value) { - debugPrint(value!.length.toString()); + logger.d(value!.length.toString()); favs = value.length; }); return favs; @@ -191,7 +192,7 @@ class FavouriteProvider extends ChangeNotifier { } }); } catch (e) { - debugPrint(e.toString()); + logger.d(e.toString()); } await getDataBase(); return true; diff --git a/lib/data/favourites/provider/favouriteSetupProvider.dart b/lib/data/favourites/provider/favouriteSetupProvider.dart index ed8cb97a..d846b4fb 100644 --- a/lib/data/favourites/provider/favouriteSetupProvider.dart +++ b/lib/data/favourites/provider/favouriteSetupProvider.dart @@ -1,4 +1,5 @@ import 'package:Prism/auth/google_auth.dart'; +import 'package:Prism/logger/logger.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/material.dart'; import 'package:Prism/global/globals.dart' as globals; @@ -21,7 +22,7 @@ class FavouriteSetupProvider extends ChangeNotifier { liked!.add(f.data()); } }).catchError((e) { - debugPrint("data done with error"); + logger.d("data done with error"); }); return liked; @@ -37,7 +38,7 @@ class FavouriteSetupProvider extends ChangeNotifier { .doc(id) .delete(); } catch (e) { - debugPrint(e.toString()); + logger.d(e.toString()); } await getDataBase(); return true; @@ -84,7 +85,7 @@ class FavouriteSetupProvider extends ChangeNotifier { } } if (index == null) { - debugPrint("Fav"); + logger.d("Fav"); createFavSetup(setup!); localFavSave(id); } else { @@ -110,9 +111,9 @@ class FavouriteSetupProvider extends ChangeNotifier { Future countFavSetups() async { int favs = 0; - debugPrint("in countfavsetup"); + logger.d("in countfavsetup"); await getDataBase().then((value) { - debugPrint(value!.length.toString()); + logger.d(value!.length.toString()); favs = value.length; }); return favs; @@ -132,7 +133,7 @@ class FavouriteSetupProvider extends ChangeNotifier { } }); } catch (e) { - debugPrint(e.toString()); + logger.d(e.toString()); } await getDataBase(); return true; diff --git a/lib/data/notifications/notifications.dart b/lib/data/notifications/notifications.dart index a9b1abe4..2cc98dc5 100644 --- a/lib/data/notifications/notifications.dart +++ b/lib/data/notifications/notifications.dart @@ -1,4 +1,5 @@ import 'package:Prism/data/notifications/model/inAppNotifModel.dart'; +import 'package:Prism/logger/logger.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:hive/hive.dart'; import 'package:Prism/global/globals.dart' as globals; @@ -28,10 +29,10 @@ Future getLatestNotifs(String modifier) async { } Future getNotifs() async { - debugPrint("Fetching notifs"); + logger.d("Fetching notifs"); final Box box = Hive.box('inAppNotifs'); if (main.prefs.get('lastFetchTime') != null) { - debugPrint("Last fetch time ${main.prefs.get('lastFetchTime')}"); + logger.d("Last fetch time ${main.prefs.get('lastFetchTime')}"); if (globals.prismUser.premium == false) { getLatestNotifs('free').then((snap) { for (final doc in snap.docs) { @@ -63,7 +64,7 @@ Future getNotifs() async { }); main.prefs.put('lastFetchTime', DateTime.now()); } else { - debugPrint("Fetching for first time"); + logger.d("Fetching for first time"); box.clear(); if (globals.prismUser.premium == false) { getLastMonthNotifs('free').then((snap) { diff --git a/lib/data/pexels/provider/pexelsWithoutProvider.dart b/lib/data/pexels/provider/pexelsWithoutProvider.dart index 911236da..b247b953 100644 --- a/lib/data/pexels/provider/pexelsWithoutProvider.dart +++ b/lib/data/pexels/provider/pexelsWithoutProvider.dart @@ -2,6 +2,7 @@ import 'dart:convert'; import 'package:Prism/data/categories/categories.dart'; import 'package:Prism/data/pexels/model/wallpaperp.dart'; import 'package:Prism/gitkey.dart'; +import 'package:Prism/logger/logger.dart'; import 'package:Prism/routes/router.dart'; import 'package:flutter/foundation.dart'; import 'package:http/http.dart' as http; @@ -30,7 +31,7 @@ Future> categoryDataFetcherP( pageNumbersP[index] = {categoryName: origPageNumber + 1}; } if (navStack.last == "Home") { - debugPrint( + logger.d( "https://api.pexels.com/v1/search?query=$categoryName&per_page=80&page=${pageNumbersP[index][categoryName]}"); http.get( Uri.parse( @@ -51,12 +52,12 @@ Future> categoryDataFetcherP( ); } pageNumbersP[index][categoryName] = (resp["page"] as int) + 1; - debugPrint("data done"); + logger.d("data done"); return wallsP; }, ); } else { - debugPrint("Refresh Blocked"); + logger.d("Refresh Blocked"); } return wallsP; } @@ -89,18 +90,18 @@ Future> getDataP(String mode) async { ); } pageGetDataP = (resp["page"] as int) + 1; - debugPrint("data done"); + logger.d("data done"); return wallsP; }, ); } else { - debugPrint("Refresh Blocked"); + logger.d("Refresh Blocked"); } return wallsP; } Future getWallbyIDP(String? id) async { - debugPrint("https://api.pexels.com/v1/photos/$id"); + logger.d("https://api.pexels.com/v1/photos/$id"); wall = null; http.get(Uri.parse("https://api.pexels.com/v1/photos/$id"), headers: {"Authorization": pexelApiKey}).then( @@ -138,7 +139,7 @@ Future> getWallsPbyQuery(String query) async { ); } pageGetQueryP = (resp["page"] as int) + 1; - debugPrint("data done"); + logger.d("data done"); return wallsPS; }, ); @@ -165,7 +166,7 @@ Future> getWallsPbyQueryPage(String query) async { ); } pageGetQueryP = (resp["page"] as int) + 1; - debugPrint("data done"); + logger.d("data done"); return wallsPS; }, ); @@ -173,8 +174,7 @@ Future> getWallsPbyQueryPage(String query) async { } Future> getWallsPbyColor(String query) async { - debugPrint( - "https://api.pexels.com/v1/search?query=$query&per_page=24&page=1"); + logger.d("https://api.pexels.com/v1/search?query=$query&per_page=24&page=1"); http.get( Uri.parse( "https://api.pexels.com/v1/search?query=$query&per_page=24&page=1"), @@ -194,7 +194,7 @@ Future> getWallsPbyColor(String query) async { ); } pageColorsP = (resp["page"] as int) + 1; - debugPrint("data done"); + logger.d("data done"); return wallsC; }, ); @@ -202,7 +202,7 @@ Future> getWallsPbyColor(String query) async { } Future> getWallsPbyColorPage(String query) async { - debugPrint( + logger.d( "https://api.pexels.com/v1/search?query=$query&per_page=24&page=$pageColorsP"); http.get( Uri.parse( @@ -223,7 +223,7 @@ Future> getWallsPbyColorPage(String query) async { ); } pageColorsP = (resp["page"] as int) + 1; - debugPrint("data done"); + logger.d("data done"); return wallsC; }, ); diff --git a/lib/data/prism/provider/prismWithoutProvider.dart b/lib/data/prism/provider/prismWithoutProvider.dart index 069f9e56..674fc18c 100644 --- a/lib/data/prism/provider/prismWithoutProvider.dart +++ b/lib/data/prism/provider/prismWithoutProvider.dart @@ -1,5 +1,6 @@ import 'dart:async'; +import 'package:Prism/logger/logger.dart'; import 'package:Prism/routes/router.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/foundation.dart'; @@ -14,7 +15,7 @@ late List wallsDataL; Map wall = {}; Future getPrismWalls() async { if (navStack.last == "Home") { - debugPrint("Fetching first 24 walls!"); + logger.d("Fetching first 24 walls!"); prismWalls = []; subPrismWalls = []; await databaseReference @@ -33,24 +34,24 @@ Future getPrismWalls() async { prismWalls!.add(map); } if (prismWalls != []) { - debugPrint("${prismWalls!.length} walls fetched!"); + logger.d("${prismWalls!.length} walls fetched!"); subPrismWalls = prismWalls; } else { - debugPrint("Not connected to Internet"); + logger.d("Not connected to Internet"); subPrismWalls = []; } }).catchError((e) { - debugPrint(e.toString()); - debugPrint("data done with error"); + logger.d(e.toString()); + logger.d("data done with error"); }); } else { - debugPrint("Refresh blocked"); + logger.d("Refresh blocked"); } return subPrismWalls; } Future seeMorePrism() async { - debugPrint("Fetching more walls!"); + logger.d("Fetching more walls!"); await databaseReference .collection("walls") .where('review', isEqualTo: true) @@ -71,12 +72,12 @@ Future seeMorePrism() async { if (prismWalls != []) { final int len = prismWalls!.length; final double pageNumber = len / 24; - debugPrint("${value.docs.length} walls fetched!"); - debugPrint("$len total walls fetched!"); - debugPrint("PageNumber: $pageNumber"); + logger.d("${value.docs.length} walls fetched!"); + logger.d("$len total walls fetched!"); + logger.d("PageNumber: $pageNumber"); subPrismWalls!.addAll(prismWalls!.sublist(subPrismWalls!.length)); } else { - debugPrint("Not connected to Internet"); + logger.d("Not connected to Internet"); } }); return subPrismWalls; diff --git a/lib/data/profile/wallpaper/getUserProfile.dart b/lib/data/profile/wallpaper/getUserProfile.dart index bb60e7b0..237f6b5b 100644 --- a/lib/data/profile/wallpaper/getUserProfile.dart +++ b/lib/data/profile/wallpaper/getUserProfile.dart @@ -1,6 +1,10 @@ import 'package:Prism/auth/google_auth.dart'; +import 'package:Prism/auth/userModel.dart'; +import 'package:Prism/auth/userOldModel.dart'; import 'package:Prism/data/links/model/linksModel.dart'; +import 'package:Prism/logger/logger.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; import 'package:Prism/global/globals.dart' as globals; @@ -10,7 +14,7 @@ class UserProfileProvider extends ChangeNotifier { List? userProfileSetups; Future getuserProfileWalls(String? email) async { - debugPrint("Fetching first 12 profile walls"); + logger.d("Fetching first 12 profile walls"); userProfileWalls = []; await databaseReference .collection("walls") @@ -22,14 +26,14 @@ class UserProfileProvider extends ChangeNotifier { .then((value) { userProfileWalls = value.docs; }).catchError((e) { - debugPrint(e.toString()); - debugPrint("data done with error"); + logger.d(e.toString()); + logger.d("data done with error"); }); notifyListeners(); } Future seeMoreUserProfileWalls(String? email) async { - debugPrint("Fetching more profile walls"); + logger.d("Fetching more profile walls"); await databaseReference .collection("walls") .where('review', isEqualTo: true) @@ -47,7 +51,7 @@ class UserProfileProvider extends ChangeNotifier { } Future getUserProfileSetups(String? email) async { - debugPrint("Fetching first 8 profile setups"); + logger.d("Fetching first 8 profile setups"); userProfileSetups = []; await databaseReference .collection("setups") @@ -59,14 +63,14 @@ class UserProfileProvider extends ChangeNotifier { .then((value) { userProfileSetups = value.docs; }).catchError((e) { - debugPrint(e.toString()); - debugPrint("data done with error"); + logger.d(e.toString()); + logger.d("data done with error"); }); notifyListeners(); } Future seeMoreUserProfileSetups(String? email) async { - debugPrint("Fetching more profile walls"); + logger.d("Fetching more profile walls"); await databaseReference .collection("setups") .where('review', isEqualTo: true) @@ -126,6 +130,20 @@ Future unfollow(String email, String id) async { }); } +// Future copyUser() async { +// await databaseReference +// .collection(USER_OLD_COLLECTION) +// .doc("3KVCKlBiY7m6dDfyhRCj") +// .get() +// .then((value) async { +// final user = PrismUsersV2.fromDocumentSnapshotWithoutUser(value); +// await FirebaseFirestore.instance +// .collection(USER_NEW_COLLECTION) +// .doc("3KVCKlBiY7m6dDfyhRCj") +// .set(user.toJson()); +// }); +// } + Future setUserLinks(List linklist, String id) async { final Map updateLink = {}; linklist.forEach((element) { diff --git a/lib/data/profile/wallpaper/profileSetupProvider.dart b/lib/data/profile/wallpaper/profileSetupProvider.dart index 09f31742..85c9c721 100644 --- a/lib/data/profile/wallpaper/profileSetupProvider.dart +++ b/lib/data/profile/wallpaper/profileSetupProvider.dart @@ -1,3 +1,4 @@ +import 'package:Prism/logger/logger.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/material.dart'; import 'package:Prism/global/globals.dart' as globals; @@ -7,7 +8,7 @@ class ProfileSetupProvider extends ChangeNotifier { List? profileSetups; Future getProfileSetups() async { - debugPrint("Fetching first 8 profile setups"); + logger.d("Fetching first 8 profile setups"); profileSetups = []; await databaseReference .collection("setups") @@ -23,7 +24,7 @@ class ProfileSetupProvider extends ChangeNotifier { } Future seeMoreProfileSetups() async { - debugPrint("Fetching more profile setups"); + logger.d("Fetching more profile setups"); await databaseReference .collection("setups") .where('review', isEqualTo: true) diff --git a/lib/data/profile/wallpaper/profileWallProvider.dart b/lib/data/profile/wallpaper/profileWallProvider.dart index 1f95162b..42bfbf52 100644 --- a/lib/data/profile/wallpaper/profileWallProvider.dart +++ b/lib/data/profile/wallpaper/profileWallProvider.dart @@ -1,3 +1,4 @@ +import 'package:Prism/logger/logger.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/material.dart'; import 'package:Prism/global/globals.dart' as globals; @@ -7,7 +8,7 @@ class ProfileWallProvider extends ChangeNotifier { List? profileWalls; Future getProfileWalls() async { - debugPrint("Fetching first 12 profile walls"); + logger.d("Fetching first 12 profile walls"); profileWalls = []; await databaseReference .collection("walls") @@ -23,7 +24,7 @@ class ProfileWallProvider extends ChangeNotifier { } Future seeMoreProfileWalls() async { - debugPrint("Fetching more profile walls"); + logger.d("Fetching more profile walls"); await databaseReference .collection("walls") .where('review', isEqualTo: true) diff --git a/lib/data/setups/provider/setupProvider.dart b/lib/data/setups/provider/setupProvider.dart index 0a1d5c4e..8864ab1c 100644 --- a/lib/data/setups/provider/setupProvider.dart +++ b/lib/data/setups/provider/setupProvider.dart @@ -1,3 +1,4 @@ +import 'package:Prism/logger/logger.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/material.dart'; @@ -5,7 +6,7 @@ class SetupProvider extends ChangeNotifier { final FirebaseFirestore databaseReference = FirebaseFirestore.instance; List? setups; Future getSetups() async { - debugPrint("Fetching first 10 setups"); + logger.d("Fetching first 10 setups"); setups = []; await databaseReference .collection("setups") @@ -20,7 +21,7 @@ class SetupProvider extends ChangeNotifier { } Future seeMoreSetups() async { - debugPrint("Fetching more setups"); + logger.d("Fetching more setups"); await databaseReference .collection("setups") .where("review", isEqualTo: true) @@ -47,9 +48,9 @@ Future getSetupFromName(String? name) async { .get() .then((value) { value.docs.forEach((f) => setup = f.data()); - debugPrint(setup.toString()); + logger.d(setup.toString()); }).catchError((e) { - debugPrint("data done with error"); + logger.d("data done with error"); }); return setup; } diff --git a/lib/data/share/createDynamicLink.dart b/lib/data/share/createDynamicLink.dart index 897a9d87..14eab568 100644 --- a/lib/data/share/createDynamicLink.dart +++ b/lib/data/share/createDynamicLink.dart @@ -3,6 +3,7 @@ import 'package:Prism/ui/widgets/popup/copyrightPopUp.dart'; import 'package:animations/animations.dart'; import 'package:firebase_dynamic_links/firebase_dynamic_links.dart'; import 'package:flutter/foundation.dart'; +import 'package:Prism/logger/logger.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:Prism/theme/toasts.dart' as toasts; @@ -35,22 +36,22 @@ Future createDynamicLink( ClipboardData(text: "Hey check this out ➜ ${shortUrl.toString()}")); analytics.logShare(contentType: 'focussedMenu', itemId: id, method: 'link'); toasts.codeSend("Sharing link copied!"); - debugPrint(shortUrl.toString()); + logger.d(shortUrl.toString()); return shortUrl.toString(); } -Future createUserDynamicLink( - String name, String email, String userPhoto) async { +Future createUserDynamicLink(String name, String username, String email, + String bio, String userPhoto) async { final DynamicLinkParameters parameters = DynamicLinkParameters( socialMetaTagParameters: SocialMetaTagParameters( - title: "$name - Prism", + title: "$name (@$username)", imageUrl: Uri.parse(userPhoto), - description: "Check out my walls & setups on Prism."), + description: + bio != "" ? bio : "Check out my walls & setups on Prism."), dynamicLinkParametersOptions: DynamicLinkParametersOptions( shortDynamicLinkPathLength: ShortDynamicLinkPathLength.short), uriPrefix: 'https://prismwallpapers.page.link', - link: Uri.parse( - 'http://prism.hash.com/user?name=$name&email=$email&userPhoto=$userPhoto'), + link: Uri.parse('http://prism.hash.com/user?email=$email'), androidParameters: AndroidParameters( packageName: 'com.hash.prism', minimumVersion: 1, @@ -60,12 +61,14 @@ Future createUserDynamicLink( minimumVersion: '1.0.1', appStoreId: '1405860595', )); + // final Uri shortUrl = await parameters.buildUrl(); final ShortDynamicLink shortDynamicLink = await parameters.buildShortLink(); final Uri shortUrl = shortDynamicLink.shortUrl; Clipboard.setData(ClipboardData(text: shortUrl.toString())); Share.share("Hey check out my profile on Prism ➜ $shortUrl"); - analytics.logShare(contentType: 'userShare', itemId: email, method: 'link'); - debugPrint(shortUrl.toString()); + analytics.logShare( + contentType: 'userShare', itemId: username, method: 'link'); + logger.d(shortUrl.toString()); } Future createSetupDynamicLink( @@ -94,7 +97,7 @@ Future createSetupDynamicLink( Clipboard.setData(ClipboardData(text: shortUrl.toString())); Share.share("Hey check this out ➜ $shortUrl"); analytics.logShare(contentType: 'setupShare', itemId: name, method: 'link'); - debugPrint(shortUrl.toString()); + logger.d(shortUrl.toString()); } Future createSharingPrismLink(String userID) async { @@ -121,7 +124,7 @@ Future createSharingPrismLink(String userID) async { final ShortDynamicLink shortDynamicLink = await parameters.buildShortLink(); final Uri shortUrl = shortDynamicLink.shortUrl; analytics.logShare(contentType: 'prismShare', itemId: userID, method: 'link'); - debugPrint(shortUrl.toString()); + logger.d(shortUrl.toString()); return shortUrl.toString(); } @@ -156,7 +159,7 @@ Future createCopyrightLink(bool setup, BuildContext context, final ShortDynamicLink shortDynamicLink = await parameters.buildShortLink(); shortUrl = shortDynamicLink.shortUrl; analytics.logEvent(name: 'reportSetup'); - debugPrint(shortUrl.toString()); + logger.d(shortUrl.toString()); } else { final DynamicLinkParameters parameters = DynamicLinkParameters( socialMetaTagParameters: SocialMetaTagParameters( @@ -180,7 +183,7 @@ Future createCopyrightLink(bool setup, BuildContext context, final ShortDynamicLink shortDynamicLink = await parameters.buildShortLink(); shortUrl = shortDynamicLink.shortUrl; analytics.logEvent(name: 'reportWall'); - debugPrint(shortUrl.toString()); + logger.d(shortUrl.toString()); } showModal( context: context, diff --git a/lib/data/wallhaven/provider/wallhavenWithoutProvider.dart b/lib/data/wallhaven/provider/wallhavenWithoutProvider.dart index 3d10ab0c..2c72b871 100644 --- a/lib/data/wallhaven/provider/wallhavenWithoutProvider.dart +++ b/lib/data/wallhaven/provider/wallhavenWithoutProvider.dart @@ -5,6 +5,7 @@ import 'package:Prism/data/wallhaven/model/wallpaper.dart'; import 'package:Prism/routes/router.dart'; import 'package:flutter/foundation.dart'; import 'package:http/http.dart' as http; +import 'package:Prism/logger/logger.dart'; List walls = []; List wallsS = []; @@ -39,7 +40,7 @@ Future> categoryDataFetcher( .then( (http.Response response) { final resp = json.decode(response.body); - debugPrint(resp.toString()); + logger.d(resp.toString()); for (int i = 0; i < (resp["data"].length as int); i++) { walls.add( WallPaper( @@ -61,12 +62,12 @@ Future> categoryDataFetcher( } pageNumbers[index][categoryName] = (resp["meta"]["current_page"] as int) + 1; - debugPrint("data done"); + logger.d("data done"); return walls; }, ); } else { - debugPrint("Refresh Blocked"); + logger.d("Refresh Blocked"); } return walls; } @@ -108,22 +109,22 @@ Future> getData( ); } pageGetData = (resp["meta"]["current_page"] as int) + 1; - debugPrint("data done"); + logger.d("data done"); return walls; }, ).catchError((e) { - debugPrint("data done with error"); + logger.d("data done with error"); return walls; }); } else { - debugPrint("Refresh Blocked"); + logger.d("Refresh Blocked"); } return walls; } Future getWallbyID(String idU) async { final String id = idU.toLowerCase(); - debugPrint("https://wallhaven.cc/api/v1/w/$id"); + logger.d("https://wallhaven.cc/api/v1/w/$id"); wall = WallPaper(); http .get( @@ -157,7 +158,7 @@ Future getWallbyID(String idU) async { ), ), ); - debugPrint("id data done"); + logger.d("id data done"); return wall; }, ); @@ -166,7 +167,7 @@ Future getWallbyID(String idU) async { Future> getWallsbyQuery( String query, int? categories, int? purity) async { - debugPrint( + logger.d( "https://wallhaven.cc/api/v1/search?q=$query&page=1&categories=$categories&purity=$purity"); http .get( @@ -176,8 +177,8 @@ Future> getWallsbyQuery( .then( (http.Response response) { final resp = json.decode(response.body); - debugPrint(resp["data"].length.toString()); - debugPrint(wallsS.length.toString()); + logger.d(resp["data"].length.toString()); + logger.d(wallsS.length.toString()); for (int i = 0; i < (resp["data"].length as int); i++) { wallsS.add( WallPaper( @@ -206,7 +207,7 @@ Future> getWallsbyQuery( Future> getWallsbyQueryPage( String query, int? categories, int? purity) async { - debugPrint( + logger.d( "https://wallhaven.cc/api/v1/search?q=$query&page=$pageGetQuery&categories=$categories&purity=$purity"); http .get( diff --git a/lib/global/globals.dart b/lib/global/globals.dart index cc488819..e492a978 100644 --- a/lib/global/globals.dart +++ b/lib/global/globals.dart @@ -24,11 +24,12 @@ PrismUsersV2 prismUser = main.prefs.get( coins: 0, subPrisms: [], transactions: [], + coverPhoto: "", ), ) as PrismUsersV2; -String currentAppVersion = '2.6.7'; +String currentAppVersion = '2.6.8'; String obsoleteAppVersion = '2.6.0'; -String currentAppVersionCode = '69'; +String currentAppVersionCode = '70'; bool updateChecked = false; bool updateAvailable = false; Map versionInfo = {}; @@ -77,3 +78,13 @@ bool isPremiumWall(List premiumCollections, List wallCollections) { }); return result; } + +extension CapExtension on String { + String get inCaps => + isNotEmpty ? '${this[0].toUpperCase()}${substring(1)}' : ''; + String get allInCaps => toUpperCase(); + String get capitalizeFirstofEach => replaceAll(RegExp(' +'), ' ') + .split(" ") + .map((str) => str.inCaps) + .join(" "); +} diff --git a/lib/global/svgAssets.dart b/lib/global/svgAssets.dart index bede7ecf..528bb285 100644 --- a/lib/global/svgAssets.dart +++ b/lib/global/svgAssets.dart @@ -783,3 +783,26 @@ String verifiedIcon = """ """; + +String defaultHeader = """ + + + + + + + + + + + + + + + + + + + + +"""; diff --git a/lib/main.dart b/lib/main.dart index dcc19421..17b5eeec 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -51,7 +51,7 @@ int? purity; LocalNotification localNotification = LocalNotification(); void main() { debugPrint = (String? message, {int? wrapWidth}) { - if (message!.contains("[Home,")) { + if (message!.contains("[Home")) { logger.i(message); } else { logger.d(message); @@ -71,14 +71,15 @@ void main() { await Hive.openBox('setups'); await Hive.openBox('localFav'); // await Hive.deleteFromDisk(); - Hive.registerAdapter(InAppNotifAdapter()); + Hive.ignoreTypeId(33); + Hive.registerAdapter(InAppNotifAdapter()); await Hive.openBox('inAppNotifs'); // Hive.registerAdapter(PrismUsersAdapter()); Hive.registerAdapter(PrismUsersV2Adapter()); Hive.registerAdapter(BadgeAdapter()); Hive.registerAdapter(PrismTransactionAdapter()); prefs = await Hive.openBox('prefs'); - debugPrint("Box Opened"); + logger.d("Box Opened"); if (prefs.get("systemOverlayColor") == null) { prefs.put("systemOverlayColor", 0xFFE57697); } diff --git a/lib/payments/upgrade.dart b/lib/payments/upgrade.dart index 0c66ce48..e1e58b20 100644 --- a/lib/payments/upgrade.dart +++ b/lib/payments/upgrade.dart @@ -12,6 +12,7 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:purchases_flutter/object_wrappers.dart'; import 'package:Prism/payments/components.dart'; import 'package:Prism/global/globals.dart' as globals; +import 'package:Prism/logger/logger.dart'; PurchaserInfo? _purchaserInfo; @@ -29,12 +30,12 @@ Future checkPremium() async { appData.isPro = false; } } on PlatformException catch (e) { - debugPrint(e.toString()); + logger.d(e.toString()); } globals.prismUser.premium = appData.isPro!; main.prefs.put("prismUserV2", globals.prismUser); - debugPrint('#### is user pro? ${appData.isPro}'); + logger.d('#### is user pro? ${appData.isPro}'); } class UpgradeScreen extends StatefulWidget { @@ -61,7 +62,7 @@ class _UpgradeScreenState extends State { PurchaserInfo purchaserInfo; try { purchaserInfo = await Purchases.getPurchaserInfo(); - debugPrint(purchaserInfo.toString()); + logger.d(purchaserInfo.toString()); if (purchaserInfo.entitlements.all['prism_premium'] != null) { appData.isPro = purchaserInfo.entitlements.all['prism_premium']!.isActive; @@ -69,10 +70,10 @@ class _UpgradeScreenState extends State { appData.isPro = false; } } on PlatformException catch (e) { - debugPrint(e.toString()); + logger.d(e.toString()); } - debugPrint('#### is user pro? ${appData.isPro}'); + logger.d('#### is user pro? ${appData.isPro}'); setState(() {}); } @@ -81,14 +82,14 @@ class _UpgradeScreenState extends State { try { purchaserInfo = await Purchases.getPurchaserInfo(); } on PlatformException catch (e) { - debugPrint(e.toString()); + logger.d(e.toString()); } Offerings? offerings; try { offerings = await Purchases.getOfferings(); } on PlatformException catch (e) { - debugPrint(e.toString()); + logger.d(e.toString()); } if (!mounted) return; @@ -140,7 +141,7 @@ class UpsellScreen extends StatefulWidget { Future onWillPop() async { if (navStack.length > 1) navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); return true; } @@ -374,20 +375,20 @@ class _UpsellScreenState extends State { // ignore: void_checks onTap: () async { try { - debugPrint('now trying to restore'); + logger.d('now trying to restore'); final PurchaserInfo restoredInfo = await Purchases .restoreTransactions(); - debugPrint('restore completed'); - debugPrint(restoredInfo.toString()); + logger.d('restore completed'); + logger.d(restoredInfo.toString()); appData.isPro = restoredInfo .entitlements .all["prism_premium"]! .isActive; - debugPrint( - 'is user pro? ${appData.isPro}'); + logger + .d('is user pro? ${appData.isPro}'); if (appData.isPro!) { globals.prismUser.premium = @@ -403,7 +404,7 @@ class _UpsellScreenState extends State { "There was an error. Please try again later."); } } on PlatformException catch (e) { - debugPrint('----xx-----'); + logger.d('----xx-----'); final errorCode = PurchasesErrorHelper.getErrorCode( e); @@ -518,15 +519,15 @@ class _PurchaseButtonState extends State { // ignore: void_checks onTap: () async { try { - debugPrint('now trying to purchase'); + logger.d('now trying to purchase'); _purchaserInfo = await Purchases.purchasePackage(widget.package); - debugPrint('purchase completed'); + logger.d('purchase completed'); appData.isPro = _purchaserInfo!.entitlements.all["prism_premium"]!.isActive; globals.prismUser.premium = appData.isPro!; main.prefs.put("prismUserV2", globals.prismUser); - debugPrint('is user pro? ${appData.isPro}'); + logger.d('is user pro? ${appData.isPro}'); if (appData.isPro!) { toasts.codeSend("You are now a premium member."); @@ -535,7 +536,7 @@ class _PurchaseButtonState extends State { toasts.error("There was an error, please try again later."); } } on PlatformException catch (e) { - debugPrint('----xx-----'); + logger.d('----xx-----'); final errorCode = PurchasesErrorHelper.getErrorCode(e); if (errorCode == PurchasesErrorCode.purchaseCancelledError) { toasts.error("User cancelled purchase."); diff --git a/lib/routes/router.dart b/lib/routes/router.dart index 7b295773..bab0bd94 100644 --- a/lib/routes/router.dart +++ b/lib/routes/router.dart @@ -40,9 +40,11 @@ import 'package:Prism/ui/pages/upload/setupGuidelines.dart'; import 'package:Prism/ui/pages/upload/uploadSetupScreen.dart'; import 'package:Prism/ui/pages/upload/uploadWallScreen.dart'; import 'package:Prism/ui/pages/profile/reviewScreen.dart'; +import 'package:Prism/ui/widgets/popup/editProfilePanel.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:image/image.dart' as imagelib; +import 'package:Prism/logger/logger.dart'; List navStack = ["Home"]; @@ -50,63 +52,72 @@ Route generateRoute(RouteSettings settings) { switch (settings.name) { case splashRoute: navStack.add("Splash"); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); analytics.setCurrentScreen(screenName: splashRoute); return CupertinoPageRoute(builder: (context) => SplashWidget()); case searchRoute: navStack.add("Search"); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); analytics.setCurrentScreen(screenName: searchRoute); return PageRouteBuilder( + transitionDuration: const Duration(), pageBuilder: (context, animation1, animation2) => SearchScreen()); case homeRoute: navStack.add("Home"); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); analytics.setCurrentScreen(screenName: homeRoute); return PageRouteBuilder( + transitionDuration: const Duration(), pageBuilder: (context, animation1, animation2) => PageManager()); case profileRoute: navStack.add("Profile"); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); analytics.setCurrentScreen(screenName: profileRoute); return PageRouteBuilder( - pageBuilder: (context, animation1, animation2) => ProfileScreen()); + transitionDuration: const Duration(), + pageBuilder: (context, animation1, animation2) => + ProfileScreen(settings.arguments as List?)); case followerProfileRoute: navStack.add("Follower Profile"); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); analytics.setCurrentScreen(screenName: followerProfileRoute); return CupertinoPageRoute( - builder: (context) => FollowerProfile(settings.arguments as List?)); + builder: (context) => ProfileScreen(settings.arguments as List?)); case downloadRoute: navStack.add("Downloads"); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); analytics.setCurrentScreen(screenName: downloadRoute); return CupertinoPageRoute(builder: (context) => DownloadScreen()); case reviewRoute: navStack.add("Review Screen"); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); analytics.setCurrentScreen(screenName: reviewRoute); return CupertinoPageRoute(builder: (context) => ReviewScreen()); case favWallRoute: navStack.add("Fav Walls"); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); analytics.setCurrentScreen(screenName: favWallRoute); return CupertinoPageRoute( builder: (context) => const FavouriteWallpaperScreen()); case favSetupRoute: navStack.add("Fav Setups"); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); analytics.setCurrentScreen(screenName: favSetupRoute); return CupertinoPageRoute( builder: (context) => const FavouriteSetupScreen()); case premiumRoute: navStack.add("Buy Premium"); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); analytics.setCurrentScreen(screenName: premiumRoute); return CupertinoPageRoute(builder: (context) => UpgradeScreen()); + case editProfileRoute: + navStack.add("Edit Profile"); + logger.d(navStack.toString()); + analytics.setCurrentScreen(screenName: editProfileRoute); + return CupertinoPageRoute(builder: (context) => const EditProfilePanel()); case notificationsRoute: navStack.add("Notifications"); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); analytics.setCurrentScreen(screenName: notificationsRoute); analytics.logEvent( name: 'notifications_checked', @@ -114,21 +125,21 @@ Route generateRoute(RouteSettings settings) { return CupertinoPageRoute(builder: (context) => NotificationScreen()); case colorRoute: navStack.add("Color"); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); analytics.setCurrentScreen(screenName: colorRoute); return CupertinoPageRoute( builder: (context) => ColorScreen(arguments: settings.arguments as List?)); case collectionViewRoute: navStack.add("CollectionsView"); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); analytics.setCurrentScreen(screenName: collectionViewRoute); return CupertinoPageRoute( builder: (context) => CollectionViewScreen(arguments: settings.arguments as List?)); case wallpaperRoute: navStack.add("Wallpaper"); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); analytics.setCurrentScreen(screenName: wallpaperRoute); return CupertinoPageRoute( builder: (context) => @@ -136,7 +147,7 @@ Route generateRoute(RouteSettings settings) { fullscreenDialog: true); case searchWallpaperRoute: navStack.add("Search Wallpaper"); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); analytics.setCurrentScreen(screenName: searchWallpaperRoute); return CupertinoPageRoute( builder: (context) => @@ -144,7 +155,7 @@ Route generateRoute(RouteSettings settings) { fullscreenDialog: true); case downloadWallpaperRoute: navStack.add("DownloadedWallpaper"); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); analytics.setCurrentScreen(screenName: downloadWallpaperRoute); return CupertinoPageRoute( builder: (context) => @@ -152,7 +163,7 @@ Route generateRoute(RouteSettings settings) { fullscreenDialog: true); case shareRoute: navStack.add("SharedWallpaper"); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); analytics.setCurrentScreen(screenName: shareRoute); return CupertinoPageRoute( builder: (context) => @@ -160,7 +171,7 @@ Route generateRoute(RouteSettings settings) { fullscreenDialog: true); case shareSetupViewRoute: navStack.add("SharedSetup"); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); analytics.setCurrentScreen(screenName: shareSetupViewRoute); return CupertinoPageRoute( builder: (context) => @@ -168,7 +179,7 @@ Route generateRoute(RouteSettings settings) { fullscreenDialog: true); case favWallViewRoute: navStack.add("FavouriteWallpaper"); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); analytics.setCurrentScreen(screenName: favWallViewRoute); return CupertinoPageRoute( builder: (context) => @@ -176,7 +187,7 @@ Route generateRoute(RouteSettings settings) { fullscreenDialog: true); case favSetupViewRoute: navStack.add("Favourite Setup View"); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); analytics.setCurrentScreen(screenName: favSetupViewRoute); return CupertinoPageRoute( builder: (context) => @@ -184,14 +195,15 @@ Route generateRoute(RouteSettings settings) { fullscreenDialog: true); case setupRoute: navStack.add("Setups"); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); analytics.setCurrentScreen(screenName: setupRoute); return PageRouteBuilder( + transitionDuration: const Duration(), pageBuilder: (context, animation1, animation2) => const SetupScreen()); case setupViewRoute: navStack.add("SetupView"); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); analytics.setCurrentScreen(screenName: setupViewRoute); return CupertinoPageRoute( builder: (context) => @@ -199,7 +211,7 @@ Route generateRoute(RouteSettings settings) { fullscreenDialog: true); case profileSetupViewRoute: navStack.add("ProfileSetupView"); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); analytics.setCurrentScreen(screenName: profileSetupViewRoute); return CupertinoPageRoute( builder: (context) => ProfileSetupViewScreen( @@ -208,7 +220,7 @@ Route generateRoute(RouteSettings settings) { fullscreenDialog: true); case profileWallViewRoute: navStack.add("ProfileWallpaper"); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); analytics.setCurrentScreen(screenName: profileWallViewRoute); return CupertinoPageRoute( builder: (context) => @@ -216,7 +228,7 @@ Route generateRoute(RouteSettings settings) { fullscreenDialog: true); case userProfileWallViewRoute: navStack.add("User ProfileWallpaper"); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); analytics.setCurrentScreen(screenName: userProfileWallViewRoute); return CupertinoPageRoute( builder: (context) => @@ -224,7 +236,7 @@ Route generateRoute(RouteSettings settings) { fullscreenDialog: true); case userProfileSetupViewRoute: navStack.add("User ProfileSetup"); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); analytics.setCurrentScreen(screenName: userProfileSetupViewRoute); return CupertinoPageRoute( builder: (context) => UserProfileSetupViewScreen( @@ -232,12 +244,12 @@ Route generateRoute(RouteSettings settings) { fullscreenDialog: true); case themeViewRoute: navStack.add("Themes"); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); analytics.setCurrentScreen(screenName: themeViewRoute); return CupertinoPageRoute(builder: (context) => ThemeView()); case editWallRoute: navStack.add("Edit Wallpaper"); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); analytics.setCurrentScreen(screenName: editWallRoute); return CupertinoPageRoute( builder: (context) => @@ -245,7 +257,7 @@ Route generateRoute(RouteSettings settings) { fullscreenDialog: true); case uploadSetupRoute: navStack.add("Upload Setup"); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); analytics.setCurrentScreen(screenName: uploadSetupRoute); return CupertinoPageRoute( builder: (context) => @@ -253,7 +265,7 @@ Route generateRoute(RouteSettings settings) { fullscreenDialog: true); case editSetupDetailsRoute: navStack.add("Edit Setup Details"); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); analytics.setCurrentScreen(screenName: editSetupDetailsRoute); return CupertinoPageRoute( builder: (context) => @@ -261,14 +273,14 @@ Route generateRoute(RouteSettings settings) { fullscreenDialog: true); case setupGuidelinesRoute: navStack.add("Setup Guidelines"); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); analytics.setCurrentScreen(screenName: setupGuidelinesRoute); return CupertinoPageRoute( builder: (context) => const SetupGuidelinesScreen(), fullscreenDialog: true); case uploadWallRoute: navStack.add("Add"); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); analytics.setCurrentScreen(screenName: uploadWallRoute); return CupertinoPageRoute( builder: (context) => @@ -276,25 +288,25 @@ Route generateRoute(RouteSettings settings) { fullscreenDialog: true); case aboutRoute: navStack.add("About Prism"); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); analytics.setCurrentScreen(screenName: aboutRoute); return CupertinoPageRoute( builder: (context) => AboutScreen(), fullscreenDialog: true); case settingsRoute: navStack.add("Settings"); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); analytics.setCurrentScreen(screenName: settingsRoute); return CupertinoPageRoute( builder: (context) => const SettingsScreen(), fullscreenDialog: true); case sharePrismRoute: navStack.add("Share Prism"); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); analytics.setCurrentScreen(screenName: sharePrismRoute); return CupertinoPageRoute( builder: (context) => SharePrismScreen(), fullscreenDialog: true); case wallpaperFilterRoute: navStack.add("Wallpaper Filter"); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); analytics.setCurrentScreen(screenName: wallpaperFilterRoute); return CupertinoPageRoute( builder: (context) => WallpaperFilterScreen( @@ -306,14 +318,14 @@ Route generateRoute(RouteSettings settings) { fullscreenDialog: true); case onboardingRoute: navStack.add("Onboarding"); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); analytics.setCurrentScreen(screenName: wallpaperFilterRoute); return CupertinoPageRoute( builder: (context) => OnboardingScreen(), ); case followersRoute: navStack.add("Followers"); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); analytics.setCurrentScreen(screenName: followersRoute); return CupertinoPageRoute( builder: (context) => FollowersScreen( @@ -321,7 +333,7 @@ Route generateRoute(RouteSettings settings) { )); default: navStack.add("undefined"); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); analytics.setCurrentScreen(screenName: "/undefined"); return CupertinoPageRoute( builder: (context) => UndefinedScreen( diff --git a/lib/routes/routing_constants.dart b/lib/routes/routing_constants.dart index c5b75584..4e6928c9 100644 --- a/lib/routes/routing_constants.dart +++ b/lib/routes/routing_constants.dart @@ -37,3 +37,4 @@ const String onboardingRoute = '/onboarding'; const String followersRoute = '/followers'; const String reviewRoute = '/review'; const String editSetupDetailsRoute = '/editSetupDetails'; +const String editProfileRoute = '/editProfile'; diff --git a/lib/theme/darkThemeModel.dart b/lib/theme/darkThemeModel.dart index 848a46ab..4342e811 100644 --- a/lib/theme/darkThemeModel.dart +++ b/lib/theme/darkThemeModel.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:Prism/theme/theme.dart'; import 'package:Prism/main.dart' as main; +import 'package:Prism/logger/logger.dart'; Map darkThemes = { "kDMaterial Dark": kDarkTheme, @@ -49,7 +50,7 @@ class DarkThemeModel extends ChangeNotifier { } void changeThemeByID(String themeID) { - debugPrint(themeID); + logger.d(themeID); currentTheme = darkThemes[themeID]; main.prefs.put("darkThemeID", themeID); main.prefs.put( diff --git a/lib/theme/themeModel.dart b/lib/theme/themeModel.dart index dba482aa..e064120a 100644 --- a/lib/theme/themeModel.dart +++ b/lib/theme/themeModel.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:Prism/theme/theme.dart'; import 'package:Prism/main.dart' as main; +import 'package:Prism/logger/logger.dart'; Map themes = { "kLFrost White": kLightTheme, @@ -45,7 +46,7 @@ class ThemeModel extends ChangeNotifier { } void changeThemeByID(String themeID) { - debugPrint(themeID); + logger.d(themeID); currentTheme = themes[themeID]; main.prefs.put("lightThemeID", themeID); main.prefs.put( diff --git a/lib/ui/pages/categories/colorScreen.dart b/lib/ui/pages/categories/colorScreen.dart index 038e42b3..74eae5ac 100644 --- a/lib/ui/pages/categories/colorScreen.dart +++ b/lib/ui/pages/categories/colorScreen.dart @@ -5,6 +5,7 @@ import 'package:Prism/ui/widgets/home/wallpapers/colorLoader.dart'; import 'package:Prism/ui/widgets/home/core/headingChipBar.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; +import 'package:Prism/logger/logger.dart'; class ColorScreen extends StatelessWidget { final List? arguments; @@ -22,8 +23,8 @@ class ColorScreen extends StatelessWidget { navStack.removeLast(); count++; } - debugPrint(navStack.toString()); - debugPrint(count.toString()); + logger.d(navStack.toString()); + logger.d(count.toString()); for (int i = 0; i < count; i++) { Navigator.pop(context); } diff --git a/lib/ui/pages/download/downloadScreen.dart b/lib/ui/pages/download/downloadScreen.dart index 05c6c778..d857a39e 100644 --- a/lib/ui/pages/download/downloadScreen.dart +++ b/lib/ui/pages/download/downloadScreen.dart @@ -9,6 +9,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:provider/provider.dart'; +import 'package:Prism/logger/logger.dart'; class DownloadScreen extends StatefulWidget { @override @@ -18,7 +19,7 @@ class DownloadScreen extends StatefulWidget { class _DownloadScreenState extends State { Future onWillPop() async { if (navStack.length > 1) navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); return true; } @@ -61,12 +62,12 @@ class _DownloadScreenState extends State { try { files = Directory(fileNew).listSync(); } catch (e) { - debugPrint(e.toString()); + logger.d(e.toString()); } try { files.addAll(Directory(file).listSync()); } catch (e) { - debugPrint(e.toString()); + logger.d(e.toString()); } if (files.isEmpty) { setState(() { diff --git a/lib/ui/pages/download/downloadWallpaperViewScreen.dart b/lib/ui/pages/download/downloadWallpaperViewScreen.dart index db53ef58..3e140deb 100644 --- a/lib/ui/pages/download/downloadWallpaperViewScreen.dart +++ b/lib/ui/pages/download/downloadWallpaperViewScreen.dart @@ -6,6 +6,7 @@ import 'package:Prism/ui/widgets/menuButton/setWallpaperButton.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:Prism/global/globals.dart' as globals; +import 'package:Prism/logger/logger.dart'; class DownloadWallpaperScreen extends StatefulWidget { final List? arguments; @@ -19,7 +20,7 @@ class _DownloadWallpaperScreenState extends State with SingleTickerProviderStateMixin { Future onWillPop() async { if (navStack.length > 1) navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); return true; } @@ -64,7 +65,7 @@ class _DownloadWallpaperScreenState extends State animation: offsetAnimation, builder: (buildContext, child) { if (offsetAnimation.value < 0.0) { - debugPrint('${offsetAnimation.value + 8.0}'); + logger.d('${offsetAnimation.value + 8.0}'); } return GestureDetector( onLongPress: () { @@ -106,7 +107,7 @@ class _DownloadWallpaperScreenState extends State child: IconButton( onPressed: () { navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); Navigator.pop(context); }, color: Theme.of(context).accentColor, diff --git a/lib/ui/pages/favourite/favouriteSetupScreen.dart b/lib/ui/pages/favourite/favouriteSetupScreen.dart index c8ac13f3..a0bdb4d2 100644 --- a/lib/ui/pages/favourite/favouriteSetupScreen.dart +++ b/lib/ui/pages/favourite/favouriteSetupScreen.dart @@ -6,6 +6,7 @@ import 'package:Prism/ui/widgets/home/core/headingChipBar.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:provider/provider.dart'; +import 'package:Prism/logger/logger.dart'; class FavouriteSetupScreen extends StatelessWidget { const FavouriteSetupScreen({ @@ -17,7 +18,7 @@ class FavouriteSetupScreen extends StatelessWidget { return WillPopScope( onWillPop: () async { if (navStack.length > 1) navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); return true; }, child: Scaffold( diff --git a/lib/ui/pages/favourite/favouriteSetupViewScreen.dart b/lib/ui/pages/favourite/favouriteSetupViewScreen.dart index f31dfb55..9143ac2e 100644 --- a/lib/ui/pages/favourite/favouriteSetupViewScreen.dart +++ b/lib/ui/pages/favourite/favouriteSetupViewScreen.dart @@ -25,6 +25,7 @@ import 'package:Prism/analytics/analytics_service.dart'; import 'package:Prism/ui/widgets/animated/showUp.dart'; import 'package:Prism/ui/widgets/popup/signInPopUp.dart'; import 'package:hive/hive.dart'; +import 'package:Prism/logger/logger.dart'; class FavSetupViewScreen extends StatefulWidget { final List? arguments; @@ -38,7 +39,7 @@ class _FavSetupViewScreenState extends State with SingleTickerProviderStateMixin { Future onWillPop() async { navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); return true; } @@ -82,7 +83,7 @@ class _FavSetupViewScreenState extends State isLoading = true; }); navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); Navigator.pop(context); Provider.of(context, listen: false) .favCheck(id, setupMap) @@ -597,7 +598,7 @@ class _FavSetupViewScreenState extends State .liked![index!] ["wall_id"] == "") { - debugPrint("Id Not Found!"); + logger.d("Id Not Found!"); launch(Provider.of< FavouriteSetupProvider>( context, @@ -643,15 +644,15 @@ class _FavSetupViewScreenState extends State .toString()); } }, - tileText: Provider.of< - FavouriteSetupProvider>( + tileText: Provider.of( context, listen: false) .liked![index!] ["wallpaper_url"] .toString()[0] != "[" - ? (Provider.of(context, + ? (Provider.of( + context, listen: false) .liked![index!] ["wall_id"] == @@ -776,7 +777,7 @@ class _FavSetupViewScreenState extends State .liked![index!] ["wall_id"] == "") { - debugPrint("Id Not Found!"); + logger.d("Id Not Found!"); launch(Provider.of< FavouriteSetupProvider>( context, @@ -824,28 +825,28 @@ class _FavSetupViewScreenState extends State .toString()); } }, - tileText: - Provider.of( - context, - listen: false) - .liked![index!] - ["wallpaper_url"] - .toString()[0] != - "[" - ? (Provider.of(context, - listen: false) - .liked![index!] - ["wall_id"] == - null || - Provider.of( - context, - listen: false) - .liked![index!] - ["wall_id"] == - "") - ? "Wall Link" - : "Prism (${Provider.of(context, listen: false).liked![index!]["wall_id"]})" - : "${Provider.of(context, listen: false).liked![index!]["wallpaper_url"][0]} - ${(Provider.of(context, listen: false).liked![index!]["wallpaper_url"] as List).length > 2 ? Provider.of(context, listen: false).liked![index!]["wallpaper_url"][2].toString() : ""}", + tileText: Provider.of( + context, + listen: false) + .liked![index!] + ["wallpaper_url"] + .toString()[0] != + "[" + ? (Provider.of( + context, + listen: false) + .liked![index!] + ["wall_id"] == + null || + Provider.of( + context, + listen: false) + .liked![index!] + ["wall_id"] == + "") + ? "Wall Link" + : "Prism (${Provider.of(context, listen: false).liked![index!]["wall_id"]})" + : "${Provider.of(context, listen: false).liked![index!]["wallpaper_url"][0]} - ${(Provider.of(context, listen: false).liked![index!]["wallpaper_url"] as List).length > 2 ? Provider.of(context, listen: false).liked![index!]["wallpaper_url"][2].toString() : ""}", tileType: "Wallpaper", panelCollapsed: panelCollapsed, delay: @@ -1028,7 +1029,7 @@ class _FavSetupViewScreenState extends State .liked![index!] ["wall_id"] == "") { - debugPrint("Id Not Found!"); + logger.d("Id Not Found!"); launch(Provider.of< FavouriteSetupProvider>( context, @@ -1076,27 +1077,27 @@ class _FavSetupViewScreenState extends State .toString()); } }, - tileText: Provider.of< - FavouriteSetupProvider>( + tileText: Provider.of( context, listen: false) .liked![index!] ["wallpaper_url"] .toString()[0] != "[" - ? (Provider.of(context, - listen: false) - .liked![index!] - ["wall_id"] == - null || - Provider.of( - context, - listen: false) - .liked![index!] - ["wall_id"] == - "") - ? "Wall Link" - : "Prism (${Provider.of(context, listen: false).liked![index!]["wall_id"]})" + ? (Provider.of( + context, + listen: + false) + .liked![index!] + ["wall_id"] == + null || + Provider.of( + context, + listen: false) + .liked![index!]["wall_id"] == + "") + ? "Wall Link" + : "Prism (${Provider.of(context, listen: false).liked![index!]["wall_id"]})" : "${Provider.of(context, listen: false).liked![index!]["wallpaper_url"][0]} - ${(Provider.of(context, listen: false).liked![index!]["wallpaper_url"] as List).length > 2 ? Provider.of(context, listen: false).liked![index!]["wallpaper_url"][2].toString() : ""}", tileType: "Wallpaper", panelCollapsed: panelCollapsed, @@ -1364,24 +1365,28 @@ class _FavSetupViewScreenState extends State Provider.of( context, listen: false) - .liked![index!].data()["id"] + .liked![index!] + .data()["id"] .toString(), Provider.of( context, listen: false) - .liked![index!].data() as Map); + .liked![index!] + .data() as Map); }); } else { onFavSetup( Provider.of( context, listen: false) - .liked![index!].data()["id"] + .liked![index!] + .data()["id"] .toString(), Provider.of( context, listen: false) - .liked![index!].data() as Map); + .liked![index!] + .data() as Map); } }, iconColor: Theme.of(context).accentColor, @@ -1441,7 +1446,7 @@ class _FavSetupViewScreenState extends State animation: offsetAnimation, builder: (buildContext, child) { if (offsetAnimation.value < 0.0) { - debugPrint('${offsetAnimation.value + 8.0}'); + logger.d('${offsetAnimation.value + 8.0}'); } return GestureDetector( onPanUpdate: (details) { @@ -1509,7 +1514,7 @@ class _FavSetupViewScreenState extends State child: IconButton( onPressed: () { navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); Navigator.pop(context); }, color: Theme.of(context).accentColor, diff --git a/lib/ui/pages/favourite/favouriteWallScreen.dart b/lib/ui/pages/favourite/favouriteWallScreen.dart index 8aff8360..5dae15c6 100644 --- a/lib/ui/pages/favourite/favouriteWallScreen.dart +++ b/lib/ui/pages/favourite/favouriteWallScreen.dart @@ -6,6 +6,7 @@ import 'package:Prism/ui/widgets/home/core/headingChipBar.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:provider/provider.dart'; +import 'package:Prism/logger/logger.dart'; class FavouriteWallpaperScreen extends StatelessWidget { const FavouriteWallpaperScreen({ @@ -17,7 +18,7 @@ class FavouriteWallpaperScreen extends StatelessWidget { return WillPopScope( onWillPop: () async { if (navStack.length > 1) navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); return true; }, child: Scaffold( diff --git a/lib/ui/pages/favourite/favouriteWallViewScreen.dart b/lib/ui/pages/favourite/favouriteWallViewScreen.dart index eef43838..b4634458 100644 --- a/lib/ui/pages/favourite/favouriteWallViewScreen.dart +++ b/lib/ui/pages/favourite/favouriteWallViewScreen.dart @@ -22,6 +22,7 @@ import 'package:screenshot/screenshot.dart'; import 'package:sliding_up_panel/sliding_up_panel.dart'; import 'package:Prism/main.dart' as main; import 'package:Prism/global/globals.dart' as globals; +import 'package:Prism/logger/logger.dart'; class FavWallpaperViewScreen extends StatefulWidget { final List? arguments; @@ -35,7 +36,7 @@ class _FavWallpaperViewScreenState extends State with SingleTickerProviderStateMixin { Future onWillPop() async { if (navStack.length > 1) navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); return true; } @@ -166,7 +167,7 @@ class _FavWallpaperViewScreenState extends State panelCollapsed = false; }); if (panelClosed) { - debugPrint('Screenshot Starting'); + logger.d('Screenshot Starting'); if (colorChanged) { screenshotController .capture( @@ -179,9 +180,9 @@ class _FavWallpaperViewScreenState extends State screenshotTaken = true; panelClosed = false; }); - debugPrint('Screenshot Taken'); + logger.d('Screenshot Taken'); }).catchError((onError) { - debugPrint(onError.toString()); + logger.d(onError.toString()); }); } else { (main.prefs.get('optimisedWallpapers') ?? true) == true @@ -196,11 +197,11 @@ class _FavWallpaperViewScreenState extends State screenshotTaken = true; panelClosed = false; }); - debugPrint('Screenshot Taken'); + logger.d('Screenshot Taken'); }).catchError((onError) { - debugPrint(onError.toString()); + logger.d(onError.toString()); }) - : debugPrint("Wallpaper Optimisation is disabled!"); + : logger.d("Wallpaper Optimisation is disabled!"); } } }, @@ -1006,7 +1007,7 @@ class _FavWallpaperViewScreenState extends State animation: offsetAnimation, builder: (buildContext, child) { if (offsetAnimation.value < 0.0) { - debugPrint('${offsetAnimation.value + 8.0}'); + logger.d('${offsetAnimation.value + 8.0}'); } return GestureDetector( onPanUpdate: (details) { @@ -1024,7 +1025,7 @@ class _FavWallpaperViewScreenState extends State }, onTap: () { HapticFeedback.vibrate(); - !isLoading ? updateAccent() : debugPrint(""); + !isLoading ? updateAccent() : logger.d(""); shakeController.forward(from: 0.0); }, child: CachedNetworkImage( @@ -1087,7 +1088,7 @@ class _FavWallpaperViewScreenState extends State child: IconButton( onPressed: () { navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); Navigator.pop(context); }, color: isLoading @@ -1157,7 +1158,7 @@ class _FavWallpaperViewScreenState extends State panelCollapsed = false; }); if (panelClosed) { - debugPrint('Screenshot Starting'); + logger.d('Screenshot Starting'); if (colorChanged) { screenshotController .capture( @@ -1170,9 +1171,9 @@ class _FavWallpaperViewScreenState extends State screenshotTaken = true; panelClosed = false; }); - debugPrint('Screenshot Taken'); + logger.d('Screenshot Taken'); }).catchError((onError) { - debugPrint(onError.toString()); + logger.d(onError.toString()); }); } else { (main.prefs.get('optimisedWallpapers') ?? true) == true @@ -1187,11 +1188,11 @@ class _FavWallpaperViewScreenState extends State screenshotTaken = true; panelClosed = false; }); - debugPrint('Screenshot Taken'); + logger.d('Screenshot Taken'); }).catchError((onError) { - debugPrint(onError.toString()); + logger.d(onError.toString()); }) - : debugPrint("Wallpaper Optimisation is disabled!"); + : logger.d("Wallpaper Optimisation is disabled!"); } } }, @@ -1612,7 +1613,7 @@ class _FavWallpaperViewScreenState extends State animation: offsetAnimation, builder: (buildContext, child) { if (offsetAnimation.value < 0.0) { - debugPrint('${offsetAnimation.value + 8.0}'); + logger.d('${offsetAnimation.value + 8.0}'); } return GestureDetector( onPanUpdate: (details) { @@ -1630,7 +1631,7 @@ class _FavWallpaperViewScreenState extends State }, onTap: () { HapticFeedback.vibrate(); - !isLoading ? updateAccent() : debugPrint(""); + !isLoading ? updateAccent() : logger.d(""); shakeController.forward(from: 0.0); }, child: CachedNetworkImage( @@ -1733,7 +1734,7 @@ class _FavWallpaperViewScreenState extends State child: IconButton( onPressed: () { navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); Navigator.pop(context); }, color: isLoading diff --git a/lib/ui/pages/home/collections/collectionScreen.dart b/lib/ui/pages/home/collections/collectionScreen.dart index 0a30da36..0a690937 100644 --- a/lib/ui/pages/home/collections/collectionScreen.dart +++ b/lib/ui/pages/home/collections/collectionScreen.dart @@ -4,6 +4,7 @@ import 'package:Prism/ui/widgets/animated/loader.dart'; import 'package:Prism/ui/widgets/home/collections/collectionsGrid.dart'; import 'package:flutter/material.dart'; import 'package:Prism/analytics/analytics_service.dart'; +import 'package:Prism/logger/logger.dart'; class CollectionScreen extends StatefulWidget { const CollectionScreen({ @@ -17,7 +18,7 @@ class CollectionScreen extends StatefulWidget { class _CollectionScreenState extends State { Future onWillPop() async { if (navStack.length > 1) navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); return true; } diff --git a/lib/ui/pages/home/collections/collectionViewScreen.dart b/lib/ui/pages/home/collections/collectionViewScreen.dart index e0791d29..4792cc2d 100644 --- a/lib/ui/pages/home/collections/collectionViewScreen.dart +++ b/lib/ui/pages/home/collections/collectionViewScreen.dart @@ -5,6 +5,7 @@ import 'package:Prism/ui/widgets/home/collections/collectionsViewGrid.dart'; import 'package:Prism/ui/widgets/home/core/headingChipBar.dart'; import 'package:Prism/ui/widgets/home/wallpapers/loading.dart'; import 'package:flutter/material.dart'; +import 'package:Prism/logger/logger.dart'; class CollectionViewScreen extends StatelessWidget { final List? arguments; @@ -17,7 +18,7 @@ class CollectionViewScreen extends StatelessWidget { return WillPopScope( onWillPop: () async { if (navStack.length > 1) navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); return true; }, child: Scaffold( diff --git a/lib/ui/pages/home/core/notificationScreen.dart b/lib/ui/pages/home/core/notificationScreen.dart index 4090ad5b..423f7b21 100644 --- a/lib/ui/pages/home/core/notificationScreen.dart +++ b/lib/ui/pages/home/core/notificationScreen.dart @@ -14,6 +14,7 @@ import 'package:Prism/theme/toasts.dart' as toasts; import 'package:Prism/main.dart' as main; import 'package:intl/intl.dart'; import 'package:Prism/global/globals.dart' as globals; +import 'package:Prism/logger/logger.dart'; class NotificationScreen extends StatefulWidget { @override @@ -31,7 +32,7 @@ class _NotificationScreenState extends State { Future onWillPop() async { if (navStack.length > 1) navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); return true; } @@ -48,7 +49,7 @@ class _NotificationScreenState extends State { icon: const Icon(JamIcons.close), onPressed: () { if (navStack.length > 1) navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); Navigator.pop(context); }, ), diff --git a/lib/ui/pages/home/core/pageManager.dart b/lib/ui/pages/home/core/pageManager.dart index eadd91da..b186d835 100644 --- a/lib/ui/pages/home/core/pageManager.dart +++ b/lib/ui/pages/home/core/pageManager.dart @@ -24,6 +24,7 @@ import 'package:Prism/theme/jam_icons_icons.dart'; import 'package:Prism/main.dart' as main; import 'package:quick_actions/quick_actions.dart'; import 'package:Prism/global/globals.dart' as globals; +import 'package:Prism/logger/logger.dart'; TabController? tabController; @@ -60,11 +61,11 @@ class _PageManagerChildState extends State Future checkConnection() async { result = await DataConnectionChecker().hasConnection; if (result) { - debugPrint("Internet working as expected!"); + logger.d("Internet working as expected!"); setState(() {}); // return true; } else { - debugPrint("Not connected to Internet!"); + logger.d("Not connected to Internet!"); setState(() {}); // return false; } @@ -96,26 +97,26 @@ class _PageManagerChildState extends State if (shortcutType != null) shortcut = shortcutType; }); if (shortcutType == 'Follow_Feed') { - debugPrint('Follow_Feed'); + logger.d('Follow_Feed'); if (globals.followersTab) { tabController!.animateTo(1); } } else if (shortcutType == 'Collections') { - debugPrint('Collections'); + logger.d('Collections'); if (globals.followersTab) { tabController!.animateTo(2); } else { tabController!.animateTo(1); } } else if (shortcutType == 'Setups') { - debugPrint('Setups'); + logger.d('Setups'); navStack.last == "Setups" - ? debugPrint("Currently on Setups") + ? logger.d("Currently on Setups") : navStack.last == "Home" ? Navigator.of(context).pushNamed(setupRoute) : Navigator.of(context).pushNamed(setupRoute); } else if (shortcutType == 'Downloads') { - debugPrint('Downloads'); + logger.d('Downloads'); Navigator.pushNamed(context, downloadRoute); } }); @@ -164,7 +165,7 @@ class _PageManagerChildState extends State final Uri? deepLink = data?.link; if (deepLink != null && linkOpened == 0) { - debugPrint("opened while closed altogether via deep link"); + logger.d("opened while closed altogether via deep link"); if (deepLink.pathSegments[0] == "share") { Future.delayed(const Duration()).then( (value) => Navigator.pushNamed(context, shareRoute, arguments: [ @@ -191,7 +192,7 @@ class _PageManagerChildState extends State //TODO write code to add coins in friend/user account linkOpened = 1; } else {} - debugPrint("opened while closed altogether via deep link2345"); + logger.d("opened while closed altogether via deep link2345"); } FirebaseDynamicLinks.instance.onLink( @@ -199,7 +200,7 @@ class _PageManagerChildState extends State final Uri deepLink = dynamicLink.link; if (deepLink != null) { - debugPrint("opened while bg via deep link1"); + logger.d("opened while bg via deep link1"); if (deepLink.pathSegments[0] == "share") { Future.delayed(const Duration()).then( (value) => Navigator.pushNamed(context, shareRoute, arguments: [ @@ -221,11 +222,11 @@ class _PageManagerChildState extends State ])); } else {} - debugPrint("opened while bg via deep link2345"); + logger.d("opened while bg via deep link2345"); } }, onError: (OnLinkErrorException e) async { - debugPrint('onLinkError'); - debugPrint(e.message); + logger.d('onLinkError'); + logger.d(e.message); }); return true; } @@ -430,7 +431,7 @@ class _RatePopUpState extends State { color: Theme.of(context).errorColor, onPressed: () async { Navigator.of(context).pop(); - debugPrint( + logger.d( 'Thanks for the ${rating == null ? '0' : rating.round().toString()} star(s) !'); if (rating <= 3) { if (Platform.isAndroid) { @@ -439,8 +440,8 @@ class _RatePopUpState extends State { final sdkInt = androidInfo.version.sdkInt; final manufacturer = androidInfo.manufacturer; final model = androidInfo.model; - debugPrint( - 'Android $release (SDK $sdkInt), $manufacturer $model'); + logger + .d('Android $release (SDK $sdkInt), $manufacturer $model'); launch( "mailto:hash.studios.inc@gmail.com?subject=%5BCUSTOMER%20FEEDBACK%5D&body=----x-x-x----%0D%0ADevice%20Info%20-%0D%0A%0D%0AAndroid%20Version%3A%20Android%20$release%0D%0ASDK%20Number%3A%20SDK%20$sdkInt%0D%0ADevice%20Manufacturer%3A%20$manufacturer%0D%0ADevice%20Model%3A%20$model%0D%0A----x-x-x----%0D%0A%0D%0AEnter%20your%20feedback%20below%20---"); } diff --git a/lib/ui/pages/home/core/splashScreen.dart b/lib/ui/pages/home/core/splashScreen.dart index d0ac736b..d1765687 100644 --- a/lib/ui/pages/home/core/splashScreen.dart +++ b/lib/ui/pages/home/core/splashScreen.dart @@ -11,6 +11,7 @@ import 'package:provider/provider.dart'; import 'package:Prism/global/globals.dart' as globals; import 'package:Prism/theme/config.dart' as config; import 'package:Prism/main.dart' as main; +import 'package:Prism/logger/logger.dart'; late RemoteConfig remoteConfig; @@ -37,10 +38,10 @@ class SplashWidget extends StatelessWidget { 'verifiedUsers': '["akshaymaurya3006@gmail.com","maurya.abhay30@gmail.com",]' }); - debugPrint("Started Fetching Values from rc"); + logger.d("Started Fetching Values from rc"); await remoteConfig.fetch(expiration: const Duration(hours: 6)); final rcBool = await remoteConfig.activateFetched(); - debugPrint("Fetched Values from rc"); + logger.d("Fetched Values from rc"); globals.topImageLink = remoteConfig.getString('topImageLink'); globals.bannerText = remoteConfig.getString('bannerText'); globals.bannerTextOn = remoteConfig.getString('bannerTextOn'); @@ -75,17 +76,17 @@ class SplashWidget extends StatelessWidget { categories.add(json.decode("$element}")); } categories.removeWhere((element) => element['name'] == "Trending"); - debugPrint(cList.toString()); + logger.d(cList.toString()); globals.followersTab = main.prefs.get('followersTab', defaultValue: true) as bool; await getNotifs(); - debugPrint("splash done"); - debugPrint( + logger.d("splash done"); + logger.d( "Current App Version: ${globals.currentAppVersion.replaceAll(".", "")}"); - debugPrint( + logger.d( "Obsolete App Version: ${globals.obsoleteAppVersion.replaceAll(".", "")}"); } catch (e) { - debugPrint(e.toString()); + logger.d(e.toString()); } } @@ -94,7 +95,7 @@ class SplashWidget extends StatelessWidget { globals.hasNotch = height > 24; globals.notchSize = height; notchChecked = true; - debugPrint('Notch Height = $height'); + logger.d('Notch Height = $height'); } SplashWidget({ diff --git a/lib/ui/pages/home/wallpapers/customFilters.dart b/lib/ui/pages/home/wallpapers/customFilters.dart index 2f7e5cd3..f3f0b264 100644 --- a/lib/ui/pages/home/wallpapers/customFilters.dart +++ b/lib/ui/pages/home/wallpapers/customFilters.dart @@ -32,3 +32,52 @@ class EdgeDetectionFilter extends ImageFilter { )); } } + +class EmbossFilter extends ImageFilter { + EmbossFilter() : super(name: "Emboss") { + subFilters.add(ConvolutionSubFilter.fromKernel( + embossKernel, + )); + } +} + +class BlurMaxFilter extends ImageFilter { + BlurMaxFilter() : super(name: "Blur Max") { + subFilters.add(ConvolutionSubFilter.fromKernel( + blurKernel, + )); + subFilters.add(ConvolutionSubFilter.fromKernel( + blurKernel, + )); + subFilters.add(ConvolutionSubFilter.fromKernel( + blurKernel, + )); + subFilters.add(ConvolutionSubFilter.fromKernel( + blurKernel, + )); + } +} + +class MeanFilter extends ImageFilter { + MeanFilter() : super(name: "Mean") { + subFilters.add(ConvolutionSubFilter.fromKernel( + mean5x5Kernel, + )); + } +} + +class HighPassFilter extends ImageFilter { + HighPassFilter() : super(name: "High Pass") { + subFilters.add(ConvolutionSubFilter.fromKernel( + highPass3x3Kernel, + )); + } +} + +class LowPassFilter extends ImageFilter { + LowPassFilter() : super(name: "Low Pass") { + subFilters.add(ConvolutionSubFilter.fromKernel( + lowPass5x5Kernel, + )); + } +} diff --git a/lib/ui/pages/home/wallpapers/followingScreen.dart b/lib/ui/pages/home/wallpapers/followingScreen.dart index 1ba56a66..7a384f7b 100644 --- a/lib/ui/pages/home/wallpapers/followingScreen.dart +++ b/lib/ui/pages/home/wallpapers/followingScreen.dart @@ -15,6 +15,7 @@ import 'package:Prism/global/globals.dart' as globals; import 'package:flutter_svg/flutter_svg.dart'; import 'package:Prism/global/svgAssets.dart'; import 'package:Prism/ui/widgets/premiumBanners/followingFeed.dart'; +import 'package:Prism/logger/logger.dart'; class FollowingScreen extends StatefulWidget { const FollowingScreen({ @@ -34,8 +35,8 @@ class _FollowingScreenState extends State { CollectionReference? walls; Future onWillPop() async { if (navStack.length > 1) navStack.removeLast(); - debugPrint(navStack.toString()); - debugPrint("Bye! Have a good day!"); + logger.d(navStack.toString()); + logger.d("Bye! Have a good day!"); return true; } @@ -146,7 +147,7 @@ class _FollowingTileState extends State { } void showGooglePopUp(BuildContext context, Function func) { - debugPrint(globals.prismUser.loggedIn.toString()); + logger.d(globals.prismUser.loggedIn.toString()); if (globals.prismUser.loggedIn == false) { googleSignInPopUp(context, func); } else { diff --git a/lib/ui/pages/home/wallpapers/homeScreen.dart b/lib/ui/pages/home/wallpapers/homeScreen.dart index 5815e86e..500ee014 100644 --- a/lib/ui/pages/home/wallpapers/homeScreen.dart +++ b/lib/ui/pages/home/wallpapers/homeScreen.dart @@ -1,5 +1,6 @@ import 'package:Prism/global/categoryMenu.dart'; import 'package:Prism/global/categoryProvider.dart'; +import 'package:Prism/logger/logger.dart'; import 'package:Prism/routes/router.dart'; import 'package:Prism/ui/widgets/home/wallpapers/loading.dart'; import 'package:Prism/ui/widgets/home/wallpapers/pexelsGrid.dart'; @@ -36,8 +37,8 @@ class _HomeScreenState extends State { return false; } if (navStack.length > 1) navStack.removeLast(); - debugPrint(navStack.toString()); - debugPrint("Bye! Have a good day!"); + logger.d(navStack.toString()); + logger.d("Bye! Have a good day!"); return true; } diff --git a/lib/ui/pages/home/wallpapers/wallpaperFilterScreen.dart b/lib/ui/pages/home/wallpapers/wallpaperFilterScreen.dart index f8ff527f..a79d2b45 100644 --- a/lib/ui/pages/home/wallpapers/wallpaperFilterScreen.dart +++ b/lib/ui/pages/home/wallpapers/wallpaperFilterScreen.dart @@ -3,6 +3,7 @@ import 'dart:io'; import 'dart:typed_data'; import 'package:Prism/analytics/analytics_service.dart'; +import 'package:Prism/logger/logger.dart'; import 'package:Prism/routes/router.dart'; import 'package:Prism/routes/routing_constants.dart'; import 'package:Prism/theme/darkThemeModel.dart'; @@ -16,7 +17,9 @@ import 'package:Prism/ui/widgets/popup/signInPopUp.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:gallery_saver/gallery_saver.dart'; import 'package:image/image.dart' as imagelib; +import 'package:permission_handler/permission_handler.dart'; import 'package:photo_view/photo_view.dart'; import 'package:photofilters/filters/filters.dart'; import 'package:path_provider/path_provider.dart'; @@ -24,6 +27,7 @@ import 'package:photofilters/filters/preset_filters.dart'; import 'package:Prism/theme/toasts.dart' as toasts; import 'package:provider/provider.dart'; import 'package:Prism/global/globals.dart' as globals; +import 'package:Prism/main.dart' as main; class WallpaperFilterScreen extends StatefulWidget { final imagelib.Image image; @@ -51,35 +55,58 @@ class _WallpaperFilterScreenState extends State { imagelib.Image? image; imagelib.Image? finalImage; late bool loading; + late bool isLoading; List selectedFilters = [ NoFilter(), + AddictiveBlueFilter(), + AddictiveRedFilter(), AdenFilter(), AmaroFilter(), + AshbyFilter(), BlurFilter(), + BlurMaxFilter(), BrannanFilter(), BrooklynFilter(), + CharmesFilter(), ClarendonFilter(), + CremaFilter(), DogpatchFilter(), + EarlybirdFilter(), EdgeDetectionFilter(), + EmbossFilter(), + F1977Filter(), GinghamFilter(), GinzaFilter(), HefeFilter(), HelenaFilter(), + HighPassFilter(), HudsonFilter(), InkwellFilter(), InvertFilter(), JunoFilter(), KelvinFilter(), LarkFilter(), + LoFiFilter(), + LowPassFilter(), LudwigFilter(), MavenFilter(), MayfairFilter(), + MeanFilter(), MoonFilter(), + NashvilleFilter(), + PerpetuaFilter(), ReyesFilter(), + RiseFilter(), SharpenFilter(), + SierraFilter(), SkylineFilter(), + SlumberFilter(), + StinsonFilter(), SutroFilter(), + ToasterFilter(), + ValenciaFilter(), VesperFilter(), + WaldenFilter(), WillowFilter(), XProIIFilter(), ]; @@ -88,6 +115,7 @@ class _WallpaperFilterScreenState extends State { void initState() { super.initState(); loading = false; + isLoading = false; _filter = selectedFilters[0]; filename = widget.filename; finalFilename = widget.finalFilename; @@ -102,7 +130,7 @@ class _WallpaperFilterScreenState extends State { Future onWillPop() async { if (navStack.length > 1) navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); return true; } @@ -128,19 +156,19 @@ class _WallpaperFilterScreenState extends State { }); } if (result!) { - debugPrint("Success"); + logger.d("Success"); analytics.logEvent( name: 'set_wall', parameters: {'type': 'Both', 'result': 'Success'}); toasts.codeSend("Wallpaper set successfully!"); } else { - debugPrint("Failed"); + logger.d("Failed"); toasts.error("Something went wrong!"); } } catch (e) { analytics.logEvent( name: 'set_wall', parameters: {'type': 'Both', 'result': 'Failure'}); - debugPrint(e.toString()); + logger.d(e.toString()); } Navigator.of(context).pop(); } @@ -165,17 +193,17 @@ class _WallpaperFilterScreenState extends State { }); } if (result!) { - debugPrint("Success"); + logger.d("Success"); analytics.logEvent( name: 'set_wall', parameters: {'type': 'Lock', 'result': 'Success'}); toasts.codeSend("Wallpaper set successfully!"); } else { - debugPrint("Failed"); + logger.d("Failed"); toasts.error("Something went wrong!"); } } catch (e) { - debugPrint(e.toString()); + logger.d(e.toString()); analytics.logEvent( name: 'set_wall', parameters: {'type': 'Lock', 'result': 'Failure'}); } @@ -202,17 +230,17 @@ class _WallpaperFilterScreenState extends State { }); } if (result!) { - debugPrint("Success"); + logger.d("Success"); analytics.logEvent( name: 'set_wall', parameters: {'type': 'Home', 'result': 'Success'}); toasts.codeSend("Wallpaper set successfully!"); } else { - debugPrint("Failed"); + logger.d("Failed"); toasts.error("Something went wrong!"); } } catch (e) { - debugPrint(e.toString()); + logger.d(e.toString()); analytics.logEvent( name: 'set_wall', parameters: {'type': 'Home', 'result': 'Failure'}); } @@ -245,40 +273,61 @@ class _WallpaperFilterScreenState extends State { onWillPop: onWillPop, child: Scaffold( appBar: AppBar( - title: Row( - children: [ - Text( - "Edit Wallpaper", - style: Theme.of(context).textTheme.headline3, - ), - Container( - margin: const EdgeInsets.only(left: 3, bottom: 5), - decoration: BoxDecoration( - color: Theme.of(context).errorColor, - borderRadius: BorderRadius.circular(500)), - child: Padding( - padding: - const EdgeInsets.symmetric(vertical: 1.0, horizontal: 4), - child: Text( - "BETA", - style: TextStyle( - fontSize: 9, - color: Theme.of(context).accentColor, - ), - ), - ), - ), - ], + title: Text( + "Edit Wallpaper", + style: Theme.of(context).textTheme.headline3, ), leading: IconButton( icon: const Icon(JamIcons.close), onPressed: () { navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); Navigator.pop(context); }), backgroundColor: Theme.of(context).primaryColor, actions: [ + if (loading) + Container() + else if (isLoading) + Center( + child: SizedBox( + width: 20, + height: 20, + child: CircularProgressIndicator( + color: Theme.of(context).errorColor)), + ) + else + IconButton( + icon: const Icon(JamIcons.download), + onPressed: () async { + toasts.codeSend("Processing Wallpaper"); + final imageFile = await saveFilteredImage(); + final status = await Permission.storage.status; + if (!status.isGranted) { + await Permission.storage.request(); + } + setState(() { + isLoading = true; + }); + GallerySaver.saveImage(imageFile.path, albumName: "Prism") + .then((value) { + analytics.logEvent( + name: 'download_wallpaper', + parameters: {'link': imageFile.path}); + toasts.codeSend("Wall Saved in Pictures!"); + setState(() { + isLoading = false; + }); + // main.localNotification.cancelDownloadNotification(); + }).catchError((e) { + setState(() { + isLoading = false; + }); + // TODO Cancel all + // main.localNotification.cancelDownloadNotification(); + }); + }, + ), if (loading) Container() else diff --git a/lib/ui/pages/home/wallpapers/wallpaperScreen.dart b/lib/ui/pages/home/wallpapers/wallpaperScreen.dart index 28faf663..7a383204 100644 --- a/lib/ui/pages/home/wallpapers/wallpaperScreen.dart +++ b/lib/ui/pages/home/wallpapers/wallpaperScreen.dart @@ -7,6 +7,7 @@ import 'package:Prism/data/prism/provider/prismWithoutProvider.dart' as data; import 'package:Prism/data/share/createDynamicLink.dart'; import 'package:Prism/data/wallhaven/provider/wallhavenWithoutProvider.dart' as wdata; +import 'package:Prism/logger/logger.dart'; import 'package:Prism/routes/router.dart'; import 'package:Prism/routes/routing_constants.dart'; import 'package:Prism/theme/jam_icons_icons.dart'; @@ -42,7 +43,7 @@ class _WallpaperScreenState extends State with SingleTickerProviderStateMixin { Future onWillPop() async { if (navStack.length > 1) navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); return true; } @@ -167,7 +168,7 @@ class _WallpaperScreenState extends State panelCollapsed = false; }); if (panelClosed) { - debugPrint('Screenshot Starting'); + logger.d('Screenshot Starting'); setState(() { panelClosed = false; }); @@ -182,9 +183,9 @@ class _WallpaperScreenState extends State _imageFile = File.fromRawPath(image!); screenshotTaken = true; }); - debugPrint('Screenshot Taken'); + logger.d('Screenshot Taken'); }).catchError((onError) { - debugPrint(onError as String); + logger.d(onError as String); }); } else { main.prefs.get('optimisedWallpapers', @@ -200,11 +201,11 @@ class _WallpaperScreenState extends State _imageFile = File.fromRawPath(image!); screenshotTaken = true; }); - debugPrint('Screenshot Taken'); + logger.d('Screenshot Taken'); }).catchError((onError) { - debugPrint(onError.toString()); + logger.d(onError.toString()); }) - : debugPrint("Wallpaper Optimisation is disabled!"); + : logger.d("Wallpaper Optimisation is disabled!"); } } }, @@ -501,7 +502,7 @@ class _WallpaperScreenState extends State animation: offsetAnimation, builder: (buildContext, child) { if (offsetAnimation.value < 0.0) { - debugPrint('${offsetAnimation.value + 8.0}'); + logger.d('${offsetAnimation.value + 8.0}'); } return GestureDetector( onPanUpdate: (details) { @@ -518,7 +519,7 @@ class _WallpaperScreenState extends State }, onTap: () { HapticFeedback.vibrate(); - !isLoading ? updateAccent() : debugPrint(""); + !isLoading ? updateAccent() : logger.d(""); shakeController.forward(from: 0.0); }, child: CachedNetworkImage( @@ -578,7 +579,7 @@ class _WallpaperScreenState extends State child: IconButton( onPressed: () { navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); Navigator.pop(context); }, color: isLoading @@ -647,7 +648,7 @@ class _WallpaperScreenState extends State panelCollapsed = false; }); if (panelClosed) { - debugPrint('Screenshot Starting'); + logger.d('Screenshot Starting'); setState(() { panelClosed = false; }); @@ -662,9 +663,9 @@ class _WallpaperScreenState extends State _imageFile = File.fromRawPath(image!); screenshotTaken = true; }); - debugPrint('Screenshot Taken'); + logger.d('Screenshot Taken'); }).catchError((onError) { - debugPrint(onError.toString()); + logger.d(onError.toString()); }); } else { (main.prefs.get('optimisedWallpapers') ?? true) == @@ -679,12 +680,11 @@ class _WallpaperScreenState extends State _imageFile = File.fromRawPath(image!); screenshotTaken = true; }); - debugPrint('Screenshot Taken'); + logger.d('Screenshot Taken'); }).catchError((onError) { - debugPrint(onError.toString()); + logger.d(onError.toString()); }) - : debugPrint( - "Wallpaper Optimisation is disabled!"); + : logger.d("Wallpaper Optimisation is disabled!"); } } }, @@ -1164,7 +1164,7 @@ class _WallpaperScreenState extends State animation: offsetAnimation, builder: (buildContext, child) { if (offsetAnimation.value < 0.0) { - debugPrint('${offsetAnimation.value + 8.0}'); + logger.d('${offsetAnimation.value + 8.0}'); } return GestureDetector( onPanUpdate: (details) { @@ -1181,7 +1181,7 @@ class _WallpaperScreenState extends State }, onTap: () { HapticFeedback.vibrate(); - !isLoading ? updateAccent() : debugPrint(""); + !isLoading ? updateAccent() : logger.d(""); shakeController.forward(from: 0.0); }, child: CachedNetworkImage( @@ -1245,7 +1245,7 @@ class _WallpaperScreenState extends State child: IconButton( onPressed: () { navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); Navigator.pop(context); }, color: isLoading @@ -1316,7 +1316,7 @@ class _WallpaperScreenState extends State panelCollapsed = false; }); if (panelClosed) { - debugPrint('Screenshot Starting'); + logger.d('Screenshot Starting'); setState(() { panelClosed = false; }); @@ -1331,9 +1331,9 @@ class _WallpaperScreenState extends State _imageFile = File.fromRawPath(image!); screenshotTaken = true; }); - debugPrint('Screenshot Taken'); + logger.d('Screenshot Taken'); }).catchError((onError) { - debugPrint(onError.toString()); + logger.d(onError.toString()); }); } else { (main.prefs.get('optimisedWallpapers') ?? true) == @@ -1348,12 +1348,12 @@ class _WallpaperScreenState extends State _imageFile = File.fromRawPath(image!); screenshotTaken = true; }); - debugPrint('Screenshot Taken'); + logger.d('Screenshot Taken'); }).catchError((onError) { - debugPrint(onError.toString()); + logger.d(onError.toString()); }) - : debugPrint( - "Wallpaper Optimisation is disabled!"); + : logger + .d("Wallpaper Optimisation is disabled!"); } } }, @@ -1698,8 +1698,7 @@ class _WallpaperScreenState extends State animation: offsetAnimation, builder: (buildContext, child) { if (offsetAnimation.value < 0.0) { - debugPrint( - '${offsetAnimation.value + 8.0}'); + logger.d('${offsetAnimation.value + 8.0}'); } return GestureDetector( onPanUpdate: (details) { @@ -1718,7 +1717,7 @@ class _WallpaperScreenState extends State HapticFeedback.vibrate(); !isLoading ? updateAccent() - : debugPrint(""); + : logger.d(""); shakeController.forward(from: 0.0); }, child: CachedNetworkImage( @@ -1787,7 +1786,7 @@ class _WallpaperScreenState extends State child: IconButton( onPressed: () { navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); Navigator.pop(context); }, color: isLoading @@ -1860,7 +1859,7 @@ class _WallpaperScreenState extends State panelCollapsed = false; }); if (panelClosed) { - debugPrint('Screenshot Starting'); + logger.d('Screenshot Starting'); setState(() { panelClosed = false; }); @@ -1875,9 +1874,9 @@ class _WallpaperScreenState extends State _imageFile = File.fromRawPath(image!); screenshotTaken = true; }); - debugPrint('Screenshot Taken'); + logger.d('Screenshot Taken'); }).catchError((onError) { - debugPrint(onError.toString()); + logger.d(onError.toString()); }); } else { main.prefs.get('optimisedWallpapers') @@ -1895,11 +1894,11 @@ class _WallpaperScreenState extends State File.fromRawPath(image!); screenshotTaken = true; }); - debugPrint('Screenshot Taken'); + logger.d('Screenshot Taken'); }).catchError((onError) { - debugPrint(onError.toString()); + logger.d(onError.toString()); }) - : debugPrint( + : logger.d( "Wallpaper Optimisation is disabled!"); } } @@ -2266,7 +2265,7 @@ class _WallpaperScreenState extends State animation: offsetAnimation, builder: (buildContext, child) { if (offsetAnimation.value < 0.0) { - debugPrint( + logger.d( '${offsetAnimation.value + 8.0}'); } return GestureDetector( @@ -2286,7 +2285,7 @@ class _WallpaperScreenState extends State HapticFeedback.vibrate(); !isLoading ? updateAccent() - : debugPrint(""); + : logger.d(""); shakeController.forward(from: 0.0); }, child: CachedNetworkImage( @@ -2366,7 +2365,7 @@ class _WallpaperScreenState extends State child: IconButton( onPressed: () { navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); Navigator.pop(context); }, color: isLoading @@ -2440,7 +2439,7 @@ class _WallpaperScreenState extends State panelCollapsed = false; }); if (panelClosed) { - debugPrint('Screenshot Starting'); + logger.d('Screenshot Starting'); setState(() { panelClosed = false; }); @@ -2455,9 +2454,9 @@ class _WallpaperScreenState extends State _imageFile = File.fromRawPath(image!); screenshotTaken = true; }); - debugPrint('Screenshot Taken'); + logger.d('Screenshot Taken'); }).catchError((onError) { - debugPrint(onError.toString()); + logger.d(onError.toString()); }); } else { main.prefs.get('optimisedWallpapers') @@ -2475,11 +2474,11 @@ class _WallpaperScreenState extends State File.fromRawPath(image!); screenshotTaken = true; }); - debugPrint('Screenshot Taken'); + logger.d('Screenshot Taken'); }).catchError((onError) { - debugPrint(onError.toString()); + logger.d(onError.toString()); }) - : debugPrint( + : logger.d( "Wallpaper Optimisation is disabled!"); } } @@ -2838,7 +2837,7 @@ class _WallpaperScreenState extends State animation: offsetAnimation, builder: (buildContext, child) { if (offsetAnimation.value < 0.0) { - debugPrint( + logger.d( '${offsetAnimation.value + 8.0}'); } return GestureDetector( @@ -2858,7 +2857,7 @@ class _WallpaperScreenState extends State HapticFeedback.vibrate(); !isLoading ? updateAccent() - : debugPrint(""); + : logger.d(""); shakeController.forward(from: 0.0); }, child: CachedNetworkImage( @@ -2934,7 +2933,7 @@ class _WallpaperScreenState extends State child: IconButton( onPressed: () { navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); Navigator.pop(context); }, color: isLoading diff --git a/lib/ui/pages/onboarding/onboardingScreen.dart b/lib/ui/pages/onboarding/onboardingScreen.dart index bfffb973..d9114f4b 100644 --- a/lib/ui/pages/onboarding/onboardingScreen.dart +++ b/lib/ui/pages/onboarding/onboardingScreen.dart @@ -1,3 +1,4 @@ +import 'package:Prism/logger/logger.dart'; import 'package:Prism/theme/jam_icons_icons.dart'; import 'package:Prism/theme/themeModeProvider.dart'; import 'package:Prism/ui/pages/home/core/splashScreen.dart'; @@ -629,7 +630,7 @@ class _OnboardingScreenState extends State { ); }); }).catchError((e) { - debugPrint(e.toString()); + logger.d(e.toString()); globals.prismUser.loggedIn = false; main.prefs.put( "prismUserV2", globals.prismUser); diff --git a/lib/ui/pages/profile/aboutScreen.dart b/lib/ui/pages/profile/aboutScreen.dart index 67020659..1a34c9ab 100644 --- a/lib/ui/pages/profile/aboutScreen.dart +++ b/lib/ui/pages/profile/aboutScreen.dart @@ -1,3 +1,4 @@ +import 'package:Prism/logger/logger.dart'; import 'package:Prism/routes/router.dart'; import 'package:Prism/theme/darkThemeModel.dart'; import 'package:Prism/theme/jam_icons_icons.dart'; @@ -27,7 +28,7 @@ class AboutScreen extends StatelessWidget { Future onWillPop() async { if (navStack.length > 1) navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); return true; } @@ -41,7 +42,7 @@ class AboutScreen extends StatelessWidget { icon: const Icon(JamIcons.close), onPressed: () { navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); Navigator.pop(context); }), title: Text( @@ -142,13 +143,13 @@ class AboutScreen extends StatelessWidget { future: printStream(), builder: (context, snapshot) { if (snapshot == null) { - debugPrint("snapshot null"); + logger.d("snapshot null"); return SizedBox( height: 250, child: Center(child: Loader())); } if (snapshot.connectionState == ConnectionState.waiting || snapshot.connectionState == ConnectionState.none) { - debugPrint("snapshot none, waiting"); + logger.d("snapshot none, waiting"); return SizedBox( height: 250, child: Center(child: Loader())); } else { @@ -338,7 +339,11 @@ class ActionButton extends StatelessWidget { fontWeight: FontWeight.bold), ), onPressed: () { - launch(link); + if (link.contains("@gmail.com")) { + launch("mailto:$link"); + } else { + launch(link); + } }), ); } diff --git a/lib/ui/pages/profile/editSetupDetails.dart b/lib/ui/pages/profile/editSetupDetails.dart index 2c8692fb..2775899a 100644 --- a/lib/ui/pages/profile/editSetupDetails.dart +++ b/lib/ui/pages/profile/editSetupDetails.dart @@ -2,6 +2,7 @@ import 'dart:convert'; import 'dart:io'; import 'package:Prism/analytics/analytics_service.dart'; import 'package:Prism/gitkey.dart'; +import 'package:Prism/logger/logger.dart'; import 'package:Prism/routes/routing_constants.dart'; import 'package:Prism/theme/jam_icons_icons.dart'; import 'package:cached_network_image/cached_network_image.dart'; @@ -199,22 +200,22 @@ class _EditSetupReviewScreenState extends State { .then((value) => setState(() { imageURL = value.content!.downloadUrl; })); - debugPrint('File Uploaded'); + logger.d('File Uploaded'); setState(() { isUploading = false; }); } catch (e) { - debugPrint(e.toString()); + logger.d(e.toString()); Navigator.pop(context); navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); toasts.error("Some uploading issue, please try again."); } } Future onWillPop() async { if (navStack.length > 1) navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); return true; } @@ -251,7 +252,7 @@ class _EditSetupReviewScreenState extends State { toasts.error("Please fill all required fields!"); } else { navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); Navigator.pop(context); analytics.logEvent( name: 'edit_setup', diff --git a/lib/ui/pages/profile/followerProfile.dart b/lib/ui/pages/profile/followerProfile.dart index 12dcb027..9db3bcbe 100644 --- a/lib/ui/pages/profile/followerProfile.dart +++ b/lib/ui/pages/profile/followerProfile.dart @@ -1,633 +1,633 @@ -import 'dart:async'; -import 'dart:convert'; -import 'package:Prism/gitkey.dart'; -import 'package:Prism/routes/router.dart'; -import 'package:Prism/theme/jam_icons_icons.dart'; -import 'package:Prism/ui/widgets/animated/loader.dart'; -import 'package:Prism/ui/widgets/popup/noLoadLinkPopUp.dart'; -import 'package:Prism/ui/widgets/profile/userProfileLoader.dart'; -import 'package:Prism/ui/widgets/profile/userProfileSetupLoader.dart'; -import 'package:cached_network_image/cached_network_image.dart'; -import 'package:cloud_firestore/cloud_firestore.dart'; -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; -import 'package:Prism/data/profile/wallpaper/getUserProfile.dart'; -import 'package:Prism/main.dart' as main; -import 'package:Prism/theme/toasts.dart' as toasts; -import 'package:Prism/global/globals.dart' as globals; -import 'package:flutter_svg/flutter_svg.dart'; -import 'package:Prism/global/svgAssets.dart'; -import 'package:http/http.dart' as http; -import 'package:provider/provider.dart'; -import 'package:intl/intl.dart'; +// import 'dart:async'; +// import 'dart:convert'; +// import 'package:Prism/gitkey.dart'; +// import 'package:Prism/routes/router.dart'; +// import 'package:Prism/theme/jam_icons_icons.dart'; +// import 'package:Prism/ui/widgets/animated/loader.dart'; +// import 'package:Prism/ui/widgets/popup/noLoadLinkPopUp.dart'; +// import 'package:Prism/ui/widgets/profile/userProfileLoader.dart'; +// import 'package:Prism/ui/widgets/profile/userProfileSetupLoader.dart'; +// import 'package:cached_network_image/cached_network_image.dart'; +// import 'package:cloud_firestore/cloud_firestore.dart'; +// import 'package:flutter/cupertino.dart'; +// import 'package:flutter/material.dart'; +// import 'package:Prism/data/profile/wallpaper/getUserProfile.dart'; +// import 'package:Prism/main.dart' as main; +// import 'package:Prism/theme/toasts.dart' as toasts; +// import 'package:Prism/global/globals.dart' as globals; +// import 'package:flutter_svg/flutter_svg.dart'; +// import 'package:Prism/global/svgAssets.dart'; +// import 'package:http/http.dart' as http; +// import 'package:intl/intl.dart'; -class FollowerProfile extends StatefulWidget { - final List? arguments; - const FollowerProfile(this.arguments); - @override - _FollowerProfileState createState() => _FollowerProfileState(); -} +// class FollowerProfile extends StatefulWidget { +// final List? arguments; +// const FollowerProfile(this.arguments); +// @override +// _FollowerProfileState createState() => _FollowerProfileState(); +// } -class _FollowerProfileState extends State { - String? name; - String? email; - String? userPhoto; - bool? premium; - Map? links; - String? bio; - final ScrollController scrollController = ScrollController(); - final key = GlobalKey(); - @override - void initState() { - email = widget.arguments![0].toString(); - super.initState(); - } +// class _FollowerProfileState extends State { +// String? name; +// String? email; +// String? userPhoto; +// String? coverPhoto; +// bool? premium; +// Map? links; +// String? bio; +// final ScrollController scrollController = ScrollController(); +// final key = GlobalKey(); +// @override +// void initState() { +// email = widget.arguments![0].toString(); +// super.initState(); +// } - Future onWillPop() async { - if (navStack.length > 1) { - navStack.removeLast(); - if ((navStack.last == "Wallpaper") || - (navStack.last == "Search Wallpaper") || - (navStack.last == "SharedWallpaper") || - (navStack.last == "SetupView")) {} - } - debugPrint(navStack.toString()); - return true; - } +// Future onWillPop() async { +// if (navStack.length > 1) { +// navStack.removeLast(); +// if ((navStack.last == "Wallpaper") || +// (navStack.last == "Search Wallpaper") || +// (navStack.last == "SharedWallpaper") || +// (navStack.last == "SetupView")) {} +// } +// logger.d(navStack.toString()); +// return true; +// } - @override - Widget build(BuildContext context) { - if (main.prefs.get('followTooltipShow', defaultValue: false) as bool) { - } else { - Future.delayed(const Duration(milliseconds: 500)).then((_) { - try { - final dynamic tooltip = key.currentState; - tooltip.ensureTooltipVisible(); - main.prefs.put('followTooltipShow', true); - Future.delayed(const Duration(seconds: 5)).then((_) { - tooltip.deactivate(); - }); - } catch (e) { - debugPrint(e.toString()); - } - }); - } - return WillPopScope( - onWillPop: onWillPop, - child: DefaultTabController( - length: 2, - child: Scaffold( - backgroundColor: Theme.of(context).primaryColor, - body: StreamBuilder( - stream: getUserProfile(email!), - builder: (context, snap) { - if (snap.hasData && snap.data != null) { - if (snap.data!.docs.isEmpty) { - return Center( - child: SizedBox( - width: MediaQuery.of(context).size.width * 0.8, - child: const Text( - "Sorry! This user is inactive on the latest version, and hence they are not currently viewable.", - textAlign: TextAlign.center, - ), - ), - ); - } - print("SNAP ERROR ${email}"); - name = snap.data!.docs[0].data()["username"].toString() ?? - snap.data!.docs[0].data()["name"].toString(); - userPhoto = - snap.data!.docs[0].data()["profilePhoto"].toString() ?? - snap.data!.docs[0].data()["userPhoto"].toString(); - premium = snap.data!.docs[0].data()["premium"] as bool; - links = snap.data!.docs[0].data()["links"] as Map; - bio = snap.data!.docs[0].data()["bio"] as String; - debugPrint("Name : $name"); - debugPrint("Email : $email"); - debugPrint("Profile Photo : $userPhoto"); - debugPrint("Premium : $premium"); - debugPrint("Links : $links"); - return NestedScrollView( - headerSliverBuilder: (context, innerBoxIsScrolled) => - [ - SliverAppBar( - backgroundColor: Theme.of(context).errorColor, - automaticallyImplyLeading: false, - expandedHeight: 200.0, - flexibleSpace: FlexibleSpaceBar( - background: Stack( - fit: StackFit.expand, - children: [ - Container( - color: Theme.of(context).errorColor, - ), - Padding( - padding: - const EdgeInsets.fromLTRB(16, 25, 16, 0), - child: Column( - children: [ - const Spacer(flex: 5), - Table( - columnWidths: const { - 0: FlexColumnWidth(3), - 1: FlexColumnWidth(5) - }, - children: [ - TableRow(children: [ - TableCell( - child: userPhoto == null - ? Container() - : Stack( - alignment: Alignment.center, - children: [ - Container( - padding: - const EdgeInsets - .all(0), - decoration: - BoxDecoration( - color: - Theme.of(context) - .errorColor, - borderRadius: - BorderRadius - .circular( - 5000), - boxShadow: [ - BoxShadow( - blurRadius: 16, - offset: - const Offset( - 0, 4), - color: const Color( - 0xFF000000) - .withOpacity( - 0.24)) - ], - ), - child: CircleAvatar( - backgroundColor: - Colors - .transparent, - foregroundColor: - Colors - .transparent, - radius: 50, - child: ClipOval( - child: Container( - height: 120, - margin: - const EdgeInsets - .all(0), - padding: - const EdgeInsets - .all(0), - child: - CachedNetworkImage( - fit: BoxFit - .cover, - imageUrl: userPhoto - .toString(), - errorWidget: (context, - url, - error) => - Container(), - ), - ), - ), - ), - ), - if (globals.verifiedUsers - .contains( - email.toString())) - Positioned( - top: 5, - left: 100, - child: SizedBox( - width: 30, - height: 30, - child: SvgPicture - .string(verifiedIcon - .replaceAll( - "E57697", - "FFFFFF")), - ), - ) - else - Container(), - ], - ), - ), - TableCell( - verticalAlignment: - TableCellVerticalAlignment - .middle, - child: Column( - children: [ - if (name == null) - Container() - else - premium == false - ? Text( - name - .toString() - .toUpperCase(), - textAlign: - TextAlign.center, - style: TextStyle( - fontFamily: - "Proxima Nova", - color: Theme.of( - context) - .accentColor, - fontSize: 20, - fontWeight: - FontWeight - .w600), - ) - : Row( - mainAxisAlignment: - MainAxisAlignment - .center, - crossAxisAlignment: - CrossAxisAlignment - .start, - children: [ - Text( - name - .toString() - .toUpperCase(), - style: TextStyle( - fontFamily: - "Proxima Nova", - color: Theme.of( - context) - .accentColor, - fontSize: 20, - fontWeight: - FontWeight - .w600), - ), - Padding( - padding: - const EdgeInsets - .only( - left: - 6.0), - child: Container( - padding: const EdgeInsets - .symmetric( - vertical: 2, - horizontal: - 4), - decoration: - BoxDecoration( - borderRadius: - BorderRadius - .circular( - 50), - color: Theme.of( - context) - .accentColor, - ), - child: Text( - "PRO", - style: Theme.of( - context) - .textTheme - .bodyText2! - .copyWith( - fontSize: - 9, - color: Theme.of(context) - .errorColor, - ), - ), - ), - ) - ], - ), - Text( - bio ?? "", - textAlign: TextAlign.center, - maxLines: 3, - overflow: - TextOverflow.ellipsis, - ) - ], - ), - ), - ]), - TableRow(children: [ - TableCell( - verticalAlignment: - TableCellVerticalAlignment - .middle, - child: links != null && - links!.isNotEmpty - ? IconButton( - icon: Icon( - JamIcons.link, - color: Theme.of(context) - .accentColor, - ), - onPressed: () { - showNoLoadLinksPopUp( - context, links!); - }) - : Container(), - ), - TableCell( - verticalAlignment: - TableCellVerticalAlignment - .middle, - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - const Spacer(flex: 2), - // Row( - // children: [ - // FutureBuilder( - // future: userData - // .getProfileWallsLength( - // email), - // builder: (context, - // snapshot) { - // return Text( - // snapshot.data == - // null - // ? "0 " - // : "${snapshot.data.toString()} ", - // style: TextStyle( - // fontFamily: - // "Proxima Nova", - // fontSize: 22, - // color: Theme.of( - // context) - // .accentColor, - // fontWeight: - // FontWeight - // .normal), - // ); - // }), - // Icon( - // JamIcons.picture, - // size: 20, - // color: Theme.of(context) - // .accentColor, - // ), - // ], - // ), - // const Spacer(), - // Row( - // children: [ - // FutureBuilder( - // future: userData - // .getProfileSetupsLength( - // email), - // builder: (context, - // snapshot) { - // return Text( - // snapshot.data == - // null - // ? "0 " - // : "${snapshot.data.toString()} ", - // style: TextStyle( - // fontFamily: - // "Proxima Nova", - // fontSize: 22, - // color: Theme.of( - // context) - // .accentColor, - // fontWeight: - // FontWeight - // .normal), - // ); - // }), - // Icon( - // JamIcons.instant_picture, - // size: 20, - // color: Theme.of(context) - // .accentColor, - // ), - // ], - // ), - Row( - children: [ - const SizedBox(width: 15), - Text( - (snap.data!.docs[0].data()[ - 'followers'] - as List? ?? - []) - .length > - 1000 - ? NumberFormat - .compactCurrency( - decimalDigits: 2, - symbol: '', - ) - .format((snap.data!.docs[0] - .data()['followers'] - as List? ?? - []) - .length) - .toString() - : (snap.data!.docs[0] - .data()[ - 'followers'] - as List? ?? - []) - .length - .toString(), - style: TextStyle( - fontFamily: - "Proxima Nova", - fontSize: 22, - color: - Theme.of(context) - .accentColor, - fontWeight: FontWeight - .normal), - ), - Icon( - JamIcons.users, - size: 20, - color: Theme.of(context) - .accentColor, - ), - ], - ), - const Spacer(flex: 2), - ], - ), - ), - ]), - ], - ), - ], - ), - ), - ], - ), - ), - leading: IconButton( - icon: const Icon( - JamIcons.chevron_left, - ), - onPressed: () { - Navigator.pop(context); - if (navStack.length > 1) { - navStack.removeLast(); - if ((navStack.last == "Wallpaper") || - (navStack.last == "Search Wallpaper") || - (navStack.last == "SharedWallpaper") || - (navStack.last == "SetupView")) {} - } - debugPrint(navStack.toString()); - }, - ), - actions: [ - if (globals.prismUser.loggedIn == true && - globals.prismUser.email != email) - if ((snap.data!.docs[0].data()['followers'] - as List? ?? - []) - .contains(globals.prismUser.email)) - IconButton( - icon: const Icon(JamIcons.user_remove), - onPressed: () { - unfollow(email!, snap.data!.docs[0].id); - toasts.error("Unfollowed $name!"); - }, - ) - else - Tooltip( - margin: EdgeInsets.fromLTRB( - MediaQuery.of(context).size.width * 0.4, - 0, - 16, - 0), - showDuration: const Duration(seconds: 4), - key: key, - padding: - const EdgeInsets.fromLTRB(16, 8, 16, 8), - message: - "Follow $name to get notified for new posts!", - child: IconButton( - icon: const Icon(JamIcons.user_plus), - onPressed: () { - follow(email!, snap.data!.docs[0].id); - http.post( - Uri.parse( - 'https://fcm.googleapis.com/fcm/send', - ), - headers: { - 'Content-Type': 'application/json', - 'Authorization': 'key=$fcmServerToken', - }, - body: jsonEncode( - { - 'notification': { - 'title': '🎉 New Follower!', - 'body': - '${globals.prismUser.username} is now following you.', - 'color': "#e57697", - 'tag': - '${globals.prismUser.username} Follow', - 'image': - globals.prismUser.profilePhoto, - 'android_channel_id': "followers", - 'icon': '@drawable/ic_follow' - }, - 'priority': 'high', - 'data': { - 'click_action': - 'FLUTTER_NOTIFICATION_CLICK', - 'id': '1', - 'status': 'done' - }, - 'to': - "/topics/${email!.split("@")[0]}" - }, - ), - ); - toasts.codeSend("Followed $name!"); - }, - ), - ) - else - Container(), - ], - ), - SliverAppBar( - backgroundColor: Theme.of(context).errorColor, - automaticallyImplyLeading: false, - pinned: true, - titleSpacing: 0, - expandedHeight: 50, - title: SizedBox( - width: MediaQuery.of(context).size.width, - height: 57, - child: Container( - color: Theme.of(context).errorColor, - child: SizedBox.expand( - child: TabBar( - indicatorColor: Theme.of(context).accentColor, - indicatorSize: TabBarIndicatorSize.label, - unselectedLabelColor: - const Color(0xFFFFFFFF).withOpacity(0.5), - labelColor: const Color(0xFFFFFFFF), - tabs: [ - Text( - "Wallpapers", - style: Theme.of(context) - .textTheme - .bodyText2! - .copyWith( - color: Theme.of(context) - .accentColor), - ), - Text( - "Setups", - style: Theme.of(context) - .textTheme - .bodyText2! - .copyWith( - color: Theme.of(context) - .accentColor), - ), - ]), - ), - ), - ), - ), - ], - body: TabBarView( - children: [ - Padding( - padding: const EdgeInsets.only(top: 5.0), - child: UserProfileLoader( - email: email, - ), - ), - Padding( - padding: const EdgeInsets.only(top: 5.0), - child: UserProfileSetupLoader( - email: email, - ), - ), - ], - ), - ); - } else { - return Center( - child: Loader(), - ); - } - }, - ), - ), - )); - } -} +// @override +// Widget build(BuildContext context) { +// if (main.prefs.get('followTooltipShow', defaultValue: false) as bool) { +// } else { +// Future.delayed(const Duration(milliseconds: 500)).then((_) { +// try { +// final dynamic tooltip = key.currentState; +// tooltip.ensureTooltipVisible(); +// main.prefs.put('followTooltipShow', true); +// Future.delayed(const Duration(seconds: 5)).then((_) { +// tooltip.deactivate(); +// }); +// } catch (e) { +// logger.d(e.toString()); +// } +// }); +// } +// return WillPopScope( +// onWillPop: onWillPop, +// child: DefaultTabController( +// length: 2, +// child: Scaffold( +// backgroundColor: Theme.of(context).primaryColor, +// body: StreamBuilder( +// stream: getUserProfile(email!), +// builder: (context, snap) { +// if (snap.hasData && snap.data != null) { +// if (snap.data!.docs.isEmpty) { +// return Center( +// child: SizedBox( +// width: MediaQuery.of(context).size.width * 0.8, +// child: const Text( +// "Sorry! This user is inactive on the latest version, and hence they are not currently viewable.", +// textAlign: TextAlign.center, +// ), +// ), +// ); +// } +// logger.d("SNAP ERROR ${email}"); +// name = snap.data!.docs[0].data()["username"].toString() ?? +// snap.data!.docs[0].data()["name"].toString(); +// userPhoto = +// snap.data!.docs[0].data()["profilePhoto"].toString() ?? +// snap.data!.docs[0].data()["userPhoto"].toString(); +// premium = snap.data!.docs[0].data()["premium"] as bool; +// links = snap.data!.docs[0].data()["links"] as Map; +// bio = snap.data!.docs[0].data()["bio"] as String; +// logger.d("Name : $name"); +// logger.d("Email : $email"); +// logger.d("Profile Photo : $userPhoto"); +// logger.d("Premium : $premium"); +// logger.d("Links : $links"); +// return NestedScrollView( +// headerSliverBuilder: (context, innerBoxIsScrolled) => +// [ +// SliverAppBar( +// backgroundColor: Theme.of(context).errorColor, +// automaticallyImplyLeading: false, +// expandedHeight: 200.0, +// flexibleSpace: FlexibleSpaceBar( +// background: Stack( +// fit: StackFit.expand, +// children: [ +// Container( +// color: Theme.of(context).errorColor, +// ), +// Padding( +// padding: +// const EdgeInsets.fromLTRB(16, 25, 16, 0), +// child: Column( +// children: [ +// const Spacer(flex: 5), +// Table( +// columnWidths: const { +// 0: FlexColumnWidth(3), +// 1: FlexColumnWidth(5) +// }, +// children: [ +// TableRow(children: [ +// TableCell( +// child: userPhoto == null +// ? Container() +// : Stack( +// alignment: Alignment.center, +// children: [ +// Container( +// padding: +// const EdgeInsets +// .all(0), +// decoration: +// BoxDecoration( +// color: +// Theme.of(context) +// .errorColor, +// borderRadius: +// BorderRadius +// .circular( +// 5000), +// boxShadow: [ +// BoxShadow( +// blurRadius: 16, +// offset: +// const Offset( +// 0, 4), +// color: const Color( +// 0xFF000000) +// .withOpacity( +// 0.24)) +// ], +// ), +// child: CircleAvatar( +// backgroundColor: +// Colors +// .transparent, +// foregroundColor: +// Colors +// .transparent, +// radius: 50, +// child: ClipOval( +// child: Container( +// height: 120, +// margin: +// const EdgeInsets +// .all(0), +// padding: +// const EdgeInsets +// .all(0), +// child: +// CachedNetworkImage( +// fit: BoxFit +// .cover, +// imageUrl: userPhoto +// .toString(), +// errorWidget: (context, +// url, +// error) => +// Container(), +// ), +// ), +// ), +// ), +// ), +// if (globals.verifiedUsers +// .contains( +// email.toString())) +// Positioned( +// top: 5, +// left: 100, +// child: SizedBox( +// width: 30, +// height: 30, +// child: SvgPicture +// .string(verifiedIcon +// .replaceAll( +// "E57697", +// "FFFFFF")), +// ), +// ) +// else +// Container(), +// ], +// ), +// ), +// TableCell( +// verticalAlignment: +// TableCellVerticalAlignment +// .middle, +// child: Column( +// children: [ +// if (name == null) +// Container() +// else +// premium == false +// ? Text( +// name +// .toString() +// .toUpperCase(), +// textAlign: +// TextAlign.center, +// style: TextStyle( +// fontFamily: +// "Proxima Nova", +// color: Theme.of( +// context) +// .accentColor, +// fontSize: 20, +// fontWeight: +// FontWeight +// .w600), +// ) +// : Row( +// mainAxisAlignment: +// MainAxisAlignment +// .center, +// crossAxisAlignment: +// CrossAxisAlignment +// .start, +// children: [ +// Text( +// name +// .toString() +// .toUpperCase(), +// style: TextStyle( +// fontFamily: +// "Proxima Nova", +// color: Theme.of( +// context) +// .accentColor, +// fontSize: 20, +// fontWeight: +// FontWeight +// .w600), +// ), +// Padding( +// padding: +// const EdgeInsets +// .only( +// left: +// 6.0), +// child: Container( +// padding: const EdgeInsets +// .symmetric( +// vertical: 2, +// horizontal: +// 4), +// decoration: +// BoxDecoration( +// borderRadius: +// BorderRadius +// .circular( +// 50), +// color: Theme.of( +// context) +// .accentColor, +// ), +// child: Text( +// "PRO", +// style: Theme.of( +// context) +// .textTheme +// .bodyText2! +// .copyWith( +// fontSize: +// 9, +// color: Theme.of(context) +// .errorColor, +// ), +// ), +// ), +// ) +// ], +// ), +// Text( +// bio ?? "", +// textAlign: TextAlign.center, +// maxLines: 3, +// overflow: +// TextOverflow.ellipsis, +// ) +// ], +// ), +// ), +// ]), +// TableRow(children: [ +// TableCell( +// verticalAlignment: +// TableCellVerticalAlignment +// .middle, +// child: links != null && +// links!.isNotEmpty +// ? IconButton( +// icon: Icon( +// JamIcons.link, +// color: Theme.of(context) +// .accentColor, +// ), +// onPressed: () { +// showNoLoadLinksPopUp( +// context, links!); +// }) +// : Container(), +// ), +// TableCell( +// verticalAlignment: +// TableCellVerticalAlignment +// .middle, +// child: Row( +// mainAxisSize: MainAxisSize.min, +// children: [ +// const Spacer(flex: 2), +// // Row( +// // children: [ +// // FutureBuilder( +// // future: userData +// // .getProfileWallsLength( +// // email), +// // builder: (context, +// // snapshot) { +// // return Text( +// // snapshot.data == +// // null +// // ? "0 " +// // : "${snapshot.data.toString()} ", +// // style: TextStyle( +// // fontFamily: +// // "Proxima Nova", +// // fontSize: 22, +// // color: Theme.of( +// // context) +// // .accentColor, +// // fontWeight: +// // FontWeight +// // .normal), +// // ); +// // }), +// // Icon( +// // JamIcons.picture, +// // size: 20, +// // color: Theme.of(context) +// // .accentColor, +// // ), +// // ], +// // ), +// // const Spacer(), +// // Row( +// // children: [ +// // FutureBuilder( +// // future: userData +// // .getProfileSetupsLength( +// // email), +// // builder: (context, +// // snapshot) { +// // return Text( +// // snapshot.data == +// // null +// // ? "0 " +// // : "${snapshot.data.toString()} ", +// // style: TextStyle( +// // fontFamily: +// // "Proxima Nova", +// // fontSize: 22, +// // color: Theme.of( +// // context) +// // .accentColor, +// // fontWeight: +// // FontWeight +// // .normal), +// // ); +// // }), +// // Icon( +// // JamIcons.instant_picture, +// // size: 20, +// // color: Theme.of(context) +// // .accentColor, +// // ), +// // ], +// // ), +// Row( +// children: [ +// const SizedBox(width: 15), +// Text( +// (snap.data!.docs[0].data()[ +// 'followers'] +// as List? ?? +// []) +// .length > +// 1000 +// ? NumberFormat +// .compactCurrency( +// decimalDigits: 2, +// symbol: '', +// ) +// .format((snap.data!.docs[0] +// .data()['followers'] +// as List? ?? +// []) +// .length) +// .toString() +// : (snap.data!.docs[0] +// .data()[ +// 'followers'] +// as List? ?? +// []) +// .length +// .toString(), +// style: TextStyle( +// fontFamily: +// "Proxima Nova", +// fontSize: 22, +// color: +// Theme.of(context) +// .accentColor, +// fontWeight: FontWeight +// .normal), +// ), +// Icon( +// JamIcons.users, +// size: 20, +// color: Theme.of(context) +// .accentColor, +// ), +// ], +// ), +// const Spacer(flex: 2), +// ], +// ), +// ), +// ]), +// ], +// ), +// ], +// ), +// ), +// ], +// ), +// ), +// leading: IconButton( +// icon: const Icon( +// JamIcons.chevron_left, +// ), +// onPressed: () { +// Navigator.pop(context); +// if (navStack.length > 1) { +// navStack.removeLast(); +// if ((navStack.last == "Wallpaper") || +// (navStack.last == "Search Wallpaper") || +// (navStack.last == "SharedWallpaper") || +// (navStack.last == "SetupView")) {} +// } +// logger.d(navStack.toString()); +// }, +// ), +// actions: [ +// if (globals.prismUser.loggedIn == true && +// globals.prismUser.email != email) +// if ((snap.data!.docs[0].data()['followers'] +// as List? ?? +// []) +// .contains(globals.prismUser.email)) +// IconButton( +// icon: const Icon(JamIcons.user_remove), +// onPressed: () { +// unfollow(email!, snap.data!.docs[0].id); +// toasts.error("Unfollowed $name!"); +// }, +// ) +// else +// Tooltip( +// margin: EdgeInsets.fromLTRB( +// MediaQuery.of(context).size.width * 0.4, +// 0, +// 16, +// 0), +// showDuration: const Duration(seconds: 4), +// key: key, +// padding: +// const EdgeInsets.fromLTRB(16, 8, 16, 8), +// message: +// "Follow $name to get notified for new posts!", +// child: IconButton( +// icon: const Icon(JamIcons.user_plus), +// onPressed: () { +// follow(email!, snap.data!.docs[0].id); +// http.post( +// Uri.parse( +// 'https://fcm.googleapis.com/fcm/send', +// ), +// headers: { +// 'Content-Type': 'application/json', +// 'Authorization': 'key=$fcmServerToken', +// }, +// body: jsonEncode( +// { +// 'notification': { +// 'title': '🎉 New Follower!', +// 'body': +// '${globals.prismUser.username} is now following you.', +// 'color': "#e57697", +// 'tag': +// '${globals.prismUser.username} Follow', +// 'image': +// globals.prismUser.profilePhoto, +// 'android_channel_id': "followers", +// 'icon': '@drawable/ic_follow' +// }, +// 'priority': 'high', +// 'data': { +// 'click_action': +// 'FLUTTER_NOTIFICATION_CLICK', +// 'id': '1', +// 'status': 'done' +// }, +// 'to': +// "/topics/${email!.split("@")[0]}" +// }, +// ), +// ); +// toasts.codeSend("Followed $name!"); +// }, +// ), +// ) +// else +// Container(), +// ], +// ), +// SliverAppBar( +// backgroundColor: Theme.of(context).errorColor, +// automaticallyImplyLeading: false, +// pinned: true, +// titleSpacing: 0, +// expandedHeight: 50, +// title: SizedBox( +// width: MediaQuery.of(context).size.width, +// height: 57, +// child: Container( +// color: Theme.of(context).errorColor, +// child: SizedBox.expand( +// child: TabBar( +// indicatorColor: Theme.of(context).accentColor, +// indicatorSize: TabBarIndicatorSize.label, +// unselectedLabelColor: +// const Color(0xFFFFFFFF).withOpacity(0.5), +// labelColor: const Color(0xFFFFFFFF), +// tabs: [ +// Text( +// "Wallpapers", +// style: Theme.of(context) +// .textTheme +// .bodyText2! +// .copyWith( +// color: Theme.of(context) +// .accentColor), +// ), +// Text( +// "Setups", +// style: Theme.of(context) +// .textTheme +// .bodyText2! +// .copyWith( +// color: Theme.of(context) +// .accentColor), +// ), +// ]), +// ), +// ), +// ), +// ), +// ], +// body: TabBarView( +// children: [ +// Padding( +// padding: const EdgeInsets.only(top: 5.0), +// child: UserProfileLoader( +// email: email, +// ), +// ), +// Padding( +// padding: const EdgeInsets.only(top: 5.0), +// child: UserProfileSetupLoader( +// email: email, +// ), +// ), +// ], +// ), +// ); +// } else { +// return Center( +// child: Loader(), +// ); +// } +// }, +// ), +// ), +// )); +// } +// } diff --git a/lib/ui/pages/profile/followersScreen.dart b/lib/ui/pages/profile/followersScreen.dart index 7050b8e3..4836046f 100644 --- a/lib/ui/pages/profile/followersScreen.dart +++ b/lib/ui/pages/profile/followersScreen.dart @@ -4,6 +4,7 @@ import 'package:Prism/routes/router.dart'; import 'package:Prism/routes/routing_constants.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter_svg/flutter_svg.dart'; +import 'package:Prism/logger/logger.dart'; class FollowersScreen extends StatefulWidget { final List? arguments; @@ -28,7 +29,7 @@ class _FollowersScreenState extends State { return WillPopScope( onWillPop: () async { if (navStack.length > 1) navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); return true; }, child: Scaffold( diff --git a/lib/ui/pages/profile/profileScreen.dart b/lib/ui/pages/profile/profileScreen.dart index ddb31db0..8b8ee24b 100644 --- a/lib/ui/pages/profile/profileScreen.dart +++ b/lib/ui/pages/profile/profileScreen.dart @@ -1,14 +1,20 @@ import 'dart:async'; +import 'dart:convert'; import 'package:Prism/auth/google_auth.dart'; import 'package:Prism/data/favourites/provider/favouriteProvider.dart'; import 'package:Prism/data/favourites/provider/favouriteSetupProvider.dart'; +import 'package:Prism/data/profile/wallpaper/getUserProfile.dart'; import 'package:Prism/data/profile/wallpaper/profileSetupProvider.dart'; import 'package:Prism/data/profile/wallpaper/profileWallProvider.dart'; +import 'package:Prism/gitkey.dart'; +import 'package:Prism/logger/logger.dart'; import 'package:Prism/routes/router.dart'; import 'package:Prism/theme/jam_icons_icons.dart'; import 'package:Prism/routes/routing_constants.dart'; +import 'package:Prism/ui/widgets/animated/loader.dart'; import 'package:Prism/ui/widgets/popup/editProfilePanel.dart'; import 'package:Prism/ui/widgets/popup/linkPopUp.dart'; +import 'package:Prism/ui/widgets/popup/noLoadLinkPopUp.dart'; import 'package:Prism/ui/widgets/profile/aboutList.dart'; import 'package:Prism/ui/widgets/profile/drawerWidget.dart'; import 'package:Prism/ui/widgets/profile/generalList.dart'; @@ -19,6 +25,8 @@ import 'package:Prism/ui/widgets/home/core/inheritedScrollControllerProvider.dar import 'package:Prism/ui/widgets/profile/uploadedWallsLoader.dart'; import 'package:Prism/ui/widgets/profile/uploadedSetupsLoader.dart'; import 'package:Prism/ui/widgets/profile/userList.dart'; +import 'package:Prism/ui/widgets/profile/userProfileLoader.dart'; +import 'package:Prism/ui/widgets/profile/userProfileSetupLoader.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flare_flutter/flare_actor.dart'; import 'package:flutter/cupertino.dart'; @@ -30,685 +38,1457 @@ import 'package:flutter_svg/flutter_svg.dart'; import 'package:Prism/global/svgAssets.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:intl/intl.dart'; +import 'package:Prism/theme/toasts.dart' as toasts; +import 'package:http/http.dart' as http; +import 'package:url_launcher/url_launcher.dart'; final GlobalKey scaffoldKey = GlobalKey(); class ProfileScreen extends StatefulWidget { + final List? arguments; + const ProfileScreen(this.arguments); @override _ProfileScreenState createState() => _ProfileScreenState(); } class _ProfileScreenState extends State { + String? email; + + @override + void initState() { + email = widget.arguments![0].toString(); + super.initState(); + } + + Future onWillPop() async { + if (navStack.length > 1) { + navStack.removeLast(); + if ((navStack.last == "Wallpaper") || + (navStack.last == "Search Wallpaper") || + (navStack.last == "SharedWallpaper") || + (navStack.last == "SetupView")) {} + } + logger.d(navStack.toString()); + return true; + } + @override Widget build(BuildContext context) { - return Scaffold( - key: scaffoldKey, - body: BottomBar( - child: ProfileChild(), - ), - endDrawer: globals.prismUser.loggedIn - ? SizedBox( - width: MediaQuery.of(context).size.width * 0.68, - child: ProfileDrawer()) - : null); + return WillPopScope( + onWillPop: onWillPop, + child: (email == globals.prismUser.email) + ? Scaffold( + key: scaffoldKey, + body: BottomBar( + child: ProfileChild( + ownProfile: true, + id: globals.prismUser.id, + bio: globals.prismUser.bio, + coverPhoto: globals.prismUser.coverPhoto, + email: globals.prismUser.email, + links: globals.prismUser.links, + name: globals.prismUser.name, + premium: globals.prismUser.premium, + userPhoto: globals.prismUser.profilePhoto, + username: globals.prismUser.username, + followers: globals.prismUser.followers, + following: globals.prismUser.following, + ), + ), + endDrawer: globals.prismUser.loggedIn + ? SizedBox( + width: MediaQuery.of(context).size.width * 0.68, + child: ProfileDrawer()) + : null, + ) + : Scaffold( + key: scaffoldKey, + body: StreamBuilder( + stream: getUserProfile(email!), + builder: (BuildContext context, + AsyncSnapshot snapshot) { + if (snapshot.hasData && snapshot.data != null) { + if (snapshot.data!.docs.isEmpty) { + return Container( + color: Theme.of(context).primaryColor, + child: Center( + child: SizedBox( + width: MediaQuery.of(context).size.width * 0.8, + child: const Text( + "Sorry! This user is inactive on the latest version, and hence they are not currently viewable.", + textAlign: TextAlign.center, + ), + ), + ), + ); + } + return ProfileChild( + ownProfile: false, + id: snapshot.data!.docs[0].id, + bio: snapshot.data!.docs[0].data()["bio"].toString(), + coverPhoto: + snapshot.data!.docs[0].data()["coverPhoto"] as String, + email: snapshot.data!.docs[0].data()["email"].toString(), + links: snapshot.data!.docs[0].data()["links"] as Map, + name: snapshot.data!.docs[0].data()["name"].toString(), + premium: snapshot.data!.docs[0].data()["premium"] as bool, + userPhoto: snapshot.data!.docs[0] + .data()["profilePhoto"] + .toString(), + username: + snapshot.data!.docs[0].data()["username"].toString(), + followers: + snapshot.data!.docs[0].data()["followers"] as List, + following: + snapshot.data!.docs[0].data()["following"] as List, + ); + } + return Container( + color: Theme.of(context).primaryColor, + child: Center( + child: Loader(), + ), + ); + }, + ), + ), + ); } } class ProfileChild extends StatefulWidget { + final String? name; + final String? username; + final String? id; + final String? email; + final String? userPhoto; + final String? coverPhoto; + final bool? premium; + final bool? ownProfile; + final Map? links; + final String? bio; + final List? followers; + final List? following; + const ProfileChild({ + required this.name, + required this.username, + required this.id, + required this.email, + required this.userPhoto, + required this.coverPhoto, + required this.premium, + required this.ownProfile, + required this.links, + required this.bio, + required this.followers, + required this.following, + }); @override _ProfileChildState createState() => _ProfileChildState(); } class _ProfileChildState extends State { - int favCount = main.prefs.get('userFavs') as int? ?? 0; - int profileCount = ((main.prefs.get('userPosts') as int?) ?? 0) + - ((main.prefs.get('userSetups') as int?) ?? 0); + // int favCount = main.prefs.get('userFavs') as int? ?? 0; + // int profileCount = ((main.prefs.get('userPosts') as int?) ?? 0) + + // ((main.prefs.get('userSetups') as int?) ?? 0); final ScrollController scrollController = ScrollController(); - final FirebaseFirestore firestore = FirebaseFirestore.instance; - int count = 0; + // final FirebaseFirestore firestore = FirebaseFirestore.instance; + // int count = 0; @override void initState() { - count = main.prefs.get('easterCount', defaultValue: 0) as int; - checkFav(); + // count = main.prefs.get('easterCount', defaultValue: 0) as int; + // checkFav(); super.initState(); } - Future onWillPop() async { - if (navStack.length > 1) navStack.removeLast(); - debugPrint(navStack.toString()); - return true; - } - - Future checkFav() async { - if (globals.prismUser.loggedIn) { - await Provider.of(context, listen: false) - .countFav() - .then( - (value) async { - await Provider.of(context, listen: false) - .countFavSetups() - .then((value2) { - debugPrint(value.toString()); - debugPrint(value2.toString()); - if (mounted) { - setState( - () { - favCount = value + value2; - main.prefs.put('userFavs', favCount); - }, - ); - } - }); - }, - ); - } - } - @override Widget build(BuildContext context) { - final ScrollController? controller = - InheritedDataProvider.of(context)!.scrollController; - final CollectionReference users = firestore.collection(USER_NEW_COLLECTION); + final ScrollController? controller = widget.ownProfile! + ? InheritedDataProvider.of(context)!.scrollController + : ScrollController(); - return WillPopScope( - onWillPop: onWillPop, - child: globals.prismUser.loggedIn - ? DefaultTabController( - length: 2, - child: Stack( - children: [ - Scaffold( - backgroundColor: Theme.of(context).primaryColor, - body: NestedScrollView( - controller: controller, - headerSliverBuilder: (context, innerBoxIsScrolled) => - [ - SliverAppBar( - leading: globals.prismUser.loggedIn == false - ? Container() - : Padding( + return !widget.ownProfile! || globals.prismUser.loggedIn + ? DefaultTabController( + length: 2, + child: Stack( + children: [ + Scaffold( + backgroundColor: Theme.of(context).primaryColor, + body: NestedScrollView( + controller: controller, + headerSliverBuilder: (context, innerBoxIsScrolled) => + [ + SliverAppBar( + toolbarHeight: MediaQuery.of(context).padding.top + + kToolbarHeight + + 32, + primary: false, + floating: true, + elevation: 0, + leading: !widget.ownProfile! || + globals.prismUser.loggedIn == false + ? Padding( + padding: const EdgeInsets.all(8.0), + child: IconButton( + padding: const EdgeInsets.all(2), + icon: Container( + padding: const EdgeInsets.all(6.0), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Theme.of(context) + .primaryColor + .withOpacity(0.5), + ), + child: Icon(JamIcons.chevron_left, + color: Theme.of(context).accentColor), + ), + onPressed: () async { + Navigator.pop(context); + if (navStack.length > 1) { + navStack.removeLast(); + if ((navStack.last == "Wallpaper") || + (navStack.last == + "Search Wallpaper") || + (navStack.last == + "SharedWallpaper") || + (navStack.last == "SetupView")) {} + } + logger.d(navStack.toString()); + }), + ) + : Padding( + padding: const EdgeInsets.all(8.0), + child: IconButton( + padding: const EdgeInsets.all(2), + icon: Container( + padding: const EdgeInsets.all(6.0), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Theme.of(context) + .primaryColor + .withOpacity(0.5), + ), + child: Icon(JamIcons.pencil, + color: Theme.of(context).accentColor), + ), + onPressed: () async { + Navigator.pushNamed( + context, editProfileRoute); + // await showModalBottomSheet( + // isScrollControlled: true, + // context: context, + // builder: (context) => + // const EditProfilePanel(), + // ); + }), + ), + actions: !widget.ownProfile! || + globals.prismUser.loggedIn == false + ? [ + if (globals.prismUser.loggedIn == false) + Container() + else + Padding( padding: const EdgeInsets.all(8.0), - child: IconButton( - icon: Icon(JamIcons.pencil, + child: ((widget.followers ?? []) + .contains(globals.prismUser.email)) + ? IconButton( + alignment: Alignment.centerRight, + padding: const EdgeInsets.all(2), + icon: Container( + padding: + const EdgeInsets.all(6.0), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Theme.of(context) + .primaryColor + .withOpacity(0.5), + ), + child: Icon(JamIcons.user_remove, + color: Theme.of(context) + .accentColor), + ), + onPressed: () { + unfollow( + widget.email!, widget.id!); + toasts.error( + "Unfollowed ${widget.name}!"); + }) + : IconButton( + alignment: Alignment.centerRight, + padding: const EdgeInsets.all(2), + icon: Container( + padding: + const EdgeInsets.all(6.0), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Theme.of(context) + .primaryColor + .withOpacity(0.5), + ), + child: Icon(JamIcons.user_plus, + color: Theme.of(context) + .accentColor), + ), + onPressed: () { + follow(widget.email!, widget.id!); + http.post( + Uri.parse( + 'https://fcm.googleapis.com/fcm/send', + ), + headers: { + 'Content-Type': + 'application/json', + 'Authorization': + 'key=$fcmServerToken', + }, + body: jsonEncode( + { + 'notification': + { + 'title': + '🎉 New Follower!', + 'body': + '${globals.prismUser.username} is now following you.', + 'color': "#e57697", + 'tag': + '${globals.prismUser.username} Follow', + 'image': globals.prismUser + .profilePhoto, + 'android_channel_id': + "followers", + 'icon': + '@drawable/ic_follow' + }, + 'priority': 'high', + 'data': { + 'click_action': + 'FLUTTER_NOTIFICATION_CLICK', + 'id': '1', + 'status': 'done' + }, + 'to': + "/topics/${widget.email!.split("@")[0]}" + }, + ), + ); + toasts.codeSend( + "Followed ${widget.name}!"); + }), + ) + ] + : [ + Padding( + padding: const EdgeInsets.all(8.0), + child: IconButton( + alignment: Alignment.centerRight, + padding: const EdgeInsets.all(2), + icon: Container( + padding: const EdgeInsets.all(6.0), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Theme.of(context) + .primaryColor + .withOpacity(0.5), + ), + child: Icon(JamIcons.menu, color: Theme.of(context).accentColor), - onPressed: () async { - await showModalBottomSheet( - isScrollControlled: true, - context: context, - builder: (context) => - const EditProfilePanel(), - ); - }), - ), - actions: globals.prismUser.loggedIn == false - ? [] - : [ - Padding( - padding: const EdgeInsets.all(8.0), - child: IconButton( - icon: Icon(JamIcons.menu, - color: Theme.of(context) - .accentColor), - onPressed: () { - scaffoldKey.currentState! - .openEndDrawer(); - }), - ) - ], - backgroundColor: Theme.of(context).errorColor, - automaticallyImplyLeading: false, - expandedHeight: 200.0, - flexibleSpace: FlexibleSpaceBar( + ), + onPressed: () { + scaffoldKey.currentState! + .openEndDrawer(); + }), + ) + ], + backgroundColor: Theme.of(context).primaryColor, + automaticallyImplyLeading: false, + expandedHeight: + (widget.links ?? {}).keys.toList().isEmpty + ? MediaQuery.of(context).size.height * 0.4 + : MediaQuery.of(context).size.height * 0.46, + flexibleSpace: Stack( + children: [ + FlexibleSpaceBar( background: Stack( - fit: StackFit.expand, children: [ - Container( - color: Theme.of(context).errorColor, - ), - Padding( - padding: const EdgeInsets.fromLTRB( - 16, 25, 16, 0), - child: Column( - children: [ - const Spacer(flex: 5), - Table( - columnWidths: const { - 0: FlexColumnWidth(3), - 1: FlexColumnWidth(5) - }, - children: [ - TableRow(children: [ - TableCell( - child: Stack( - alignment: Alignment.center, - children: [ - Container( - padding: - const EdgeInsets.all( - 0), - decoration: BoxDecoration( - color: Theme.of(context) - .errorColor, - borderRadius: - BorderRadius - .circular(5000), - boxShadow: [ - BoxShadow( - blurRadius: 16, - offset: - const Offset( - 0, 4), - color: const Color( - 0xFF000000) - .withOpacity( - 0.24)) - ], - ), - child: CircleAvatar( - backgroundColor: - Colors.transparent, - foregroundColor: - Colors.transparent, - radius: 50, - child: ClipOval( - child: Container( - height: 120, - margin: - const EdgeInsets - .all(0), - padding: - const EdgeInsets - .all(0), - child: - CachedNetworkImage( - fit: BoxFit.cover, - imageUrl: globals - .prismUser - .profilePhoto - .toString(), - errorWidget: (context, - url, - error) => - Container(), - ), - ), - ), - ), + Column(children: [ + if (widget.coverPhoto == null) + SvgPicture.string( + defaultHeader + .replaceAll( + "#181818", + "#${Theme.of(context).primaryColor.value.toRadixString(16).toString().substring(2)}", + ) + .replaceAll( + "#E77597", + "#${Theme.of(context).errorColor.value.toRadixString(16).toString().substring(2)}", + ), + fit: BoxFit.cover, + width: + MediaQuery.of(context).size.width, + height: + MediaQuery.of(context).size.height * + 0.19, + ) + else + CachedNetworkImage( + imageUrl: widget.coverPhoto ?? + "https://firebasestorage.googleapis.com/v0/b/prism-wallpapers.appspot.com/o/Headers%2FheaderDefault.png?alt=media&token=1a10b128-c355-45d8-af96-678c13c05b3c", + fit: BoxFit.cover, + width: + MediaQuery.of(context).size.width, + height: + MediaQuery.of(context).size.height * + 0.19, + ), + const SizedBox( + width: double.maxFinite, + height: 37, + ), + Container( + padding: const EdgeInsets.fromLTRB( + 12, 4, 12, 0), + width: double.maxFinite, + height: (widget.links ?? {}) + .keys + .toList() + .isEmpty + ? MediaQuery.of(context).size.height * + 0.21 - + 37 + : MediaQuery.of(context).size.height * + 0.27 - + 37, + child: Column( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: [ + SizedBox( + width: MediaQuery.of(context) + .size + .width * + 0.7, + child: Text( + widget.name!, + textAlign: TextAlign.center, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontFamily: "Proxima Nova", + color: Theme.of(context) + .accentColor, + fontSize: 22, + fontWeight: FontWeight.w500, + ), + ), + ), + const SizedBox( + height: 2, + ), + SizedBox( + width: MediaQuery.of(context) + .size + .width * + 0.7, + child: Text( + "@${widget.username}", + textAlign: TextAlign.center, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontFamily: "Proxima Nova", + color: Theme.of(context) + .accentColor + .withOpacity(0.6), + fontSize: 16, + fontWeight: FontWeight.normal, + ), + ), + ), + const SizedBox( + height: 15, + ), + SizedBox( + width: MediaQuery.of(context) + .size + .width * + 0.7, + child: Text( + widget.bio ?? "", + textAlign: TextAlign.center, + maxLines: 2, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontFamily: "Proxima Nova", + color: Theme.of(context) + .accentColor + .withOpacity(0.6), + fontSize: 14, + fontWeight: FontWeight.normal, + ), + ), + ), + const SizedBox( + height: 15, + ), + SizedBox( + width: MediaQuery.of(context) + .size + .width * + 0.7, + child: Row( + mainAxisAlignment: + MainAxisAlignment.center, + children: [ + RichText( + text: TextSpan( + text: + "${(widget.following ?? []).length}", + style: TextStyle( + fontFamily: + "Proxima Nova", + color: Theme.of(context) + .accentColor + .withOpacity(1), + fontSize: 16, + fontWeight: + FontWeight.bold, ), - if (globals.verifiedUsers - .contains(globals - .prismUser.email)) - Positioned( - top: 5, - left: 100, - child: SizedBox( - width: 30, - height: 30, - child: SvgPicture - .string(verifiedIcon - .replaceAll( - "E57697", - "FFFFFF")), + children: [ + TextSpan( + text: " Following", + style: TextStyle( + color: Theme.of( + context) + .accentColor + .withOpacity(0.6), + fontWeight: + FontWeight.normal, ), - ) - else - Container(), - ], + ), + ], + ), + textAlign: TextAlign.center, + maxLines: 1, + overflow: + TextOverflow.ellipsis, ), - ), - TableCell( - verticalAlignment: - TableCellVerticalAlignment - .bottom, - child: Column( - children: [ - Padding( - padding: - const EdgeInsets.only( - bottom: 5), - child: globals.prismUser - .premium == - false - ? Text( - globals.prismUser - .username - .toUpperCase(), - textAlign: - TextAlign - .center, - style: TextStyle( - fontFamily: - "Proxima Nova", - color: Theme.of( - context) - .accentColor, - fontSize: 18, - fontWeight: - FontWeight - .w600), - ) - : Row( - mainAxisAlignment: - MainAxisAlignment - .center, - crossAxisAlignment: - CrossAxisAlignment - .start, - children: < - Widget>[ - Text( - globals - .prismUser - .username - .toUpperCase(), - style: TextStyle( - fontFamily: - "Proxima Nova", - color: Theme.of( - context) - .accentColor, - fontSize: - 18, - fontWeight: - FontWeight - .w600), - ), - Padding( - padding: const EdgeInsets - .only( - left: - 6.0), - child: - Container( - padding: const EdgeInsets - .symmetric( - vertical: - 2, - horizontal: - 4), - decoration: - BoxDecoration( - borderRadius: - BorderRadius.circular( - 50), - color: Theme.of( - context) - .accentColor, - ), - child: Text( - "PRO", - style: Theme.of( - context) - .textTheme - .bodyText2! - .copyWith( - fontSize: - 9, - color: - Theme.of(context).errorColor, - ), - ), - ), - ) - ], - ), + const SizedBox(width: 24), + RichText( + text: TextSpan( + text: + "${(widget.followers ?? []).length}", + style: TextStyle( + fontFamily: + "Proxima Nova", + color: Theme.of(context) + .accentColor + .withOpacity(1), + fontSize: 16, + fontWeight: + FontWeight.bold, ), - Padding( - padding: - const EdgeInsets.only( - bottom: 15), - child: Text( - globals.prismUser.bio, - textAlign: - TextAlign.center, - maxLines: 3, - overflow: TextOverflow - .ellipsis, + children: [ + TextSpan( + text: " Followers", + style: TextStyle( + color: Theme.of( + context) + .accentColor + .withOpacity(0.6), + fontWeight: + FontWeight.normal, + ), ), - ) - ], - ), - ), - ]), - TableRow(children: [ - TableCell( - verticalAlignment: - TableCellVerticalAlignment - .middle, - child: Container() - //ToDo Add link button in profile - // IconButton( - // icon: Icon( - // JamIcons.link, - // color: Theme.of(context) - // .accentColor, - // ), - // onPressed: () { - // showLinksPopUp(context, - // globals.prismUser.id); - // }), + ], ), - TableCell( - verticalAlignment: - TableCellVerticalAlignment - .middle, - child: Row( + textAlign: TextAlign.center, + maxLines: 1, + overflow: + TextOverflow.ellipsis, + ), + ], + ), + ), + if ((widget.links ?? {}) + .keys + .toList() + .isNotEmpty) + const SizedBox( + height: 8, + ), + if ((widget.links ?? {}) + .keys + .toList() + .isNotEmpty) + SizedBox( + width: MediaQuery.of(context) + .size + .width, + height: 48, + child: Row( mainAxisAlignment: - MainAxisAlignment - .spaceEvenly, - children: [ - GestureDetector( - onTap: () { - Navigator.pushNamed( - context, - favWallRoute); - }, - child: Row( - children: [ - Text( - "${favCount.toString()} ", - style: TextStyle( - fontFamily: - "Proxima Nova", - fontSize: 22, + MainAxisAlignment.center, + children: [ + ...(widget.links ?? {}) + .keys + .toList() + .map((e) => IconButton( + padding: + const EdgeInsets + .all(2), + icon: Container( + padding: + const EdgeInsets + .all(6.0), + decoration: + BoxDecoration( + shape: BoxShape + .circle, color: Theme.of( context) - .accentColor, - fontWeight: - FontWeight - .normal), - ), - Icon( - JamIcons.heart_f, - size: 20, - color: Theme.of( - context) - .accentColor, + .accentColor + .withOpacity( + 0.1), + ), + child: Icon( + linksData[e]![ + "icon"] + as IconData, + size: 20, + color: Theme.of( + context) + .accentColor + .withOpacity( + 0.8), + ), + ), + onPressed: () { + if (widget + .links![e] + .toString() + .contains( + "@gmail.com")) { + launch( + "mailto:${widget.links![e].toString()}"); + } else { + launch(widget + .links![e] + .toString()); + } + })) + .toList() + .sublist( + 0, + (widget.links ?? {}) + .keys + .toList() + .length > + 3 + ? 3 + : (widget.links ?? + {}) + .keys + .toList() + .length, + ), + if ((widget.links ?? {}) + .keys + .toList() + .length > + 3) + IconButton( + padding: + const EdgeInsets + .all(2), + icon: Container( + padding: + const EdgeInsets + .all(6.0), + decoration: + BoxDecoration( + shape: BoxShape + .circle, + color: Theme.of( + context) + .accentColor + .withOpacity( + 0.1), + ), + child: Icon( + JamIcons + .more_horizontal, + size: 20, + color: Theme.of( + context) + .accentColor + .withOpacity( + 0.8), + ), ), - ], - ), - ), - // Row( - // children: [ - // FutureBuilder( - // future: Provider.of< - // ProfileWallProvider>( - // context, - // listen: - // false) - // .getProfileWallsLength(), - // builder: (context, - // snapshot) { - // return Text( - // snapshot.data == - // null - // ? "${profileCount.toString()} " - // : "${snapshot.data.toString()} ", - // style: TextStyle( - // fontFamily: - // "Proxima Nova", - // fontSize: - // 22, - // color: Theme.of( - // context) - // .accentColor, - // fontWeight: - // FontWeight - // .normal), - // ); - // }), - // Icon( - // JamIcons.upload, - // size: 20, - // color: - // Theme.of(context) - // .accentColor, - // ), - // ], - // ), - StreamBuilder< - QuerySnapshot>( - stream: users - .where("email", - isEqualTo: globals - .prismUser - .email) - .snapshots(), - builder: (BuildContext + onPressed: () { + showNoLoadLinksPopUp( context, - AsyncSnapshot< - QuerySnapshot> - snapshot) { - if (!snapshot - .hasData) { - return Row( - children: [ - Text( - "0", - style: TextStyle( - fontFamily: - "Proxima Nova", - fontSize: - 22, - color: Theme.of( - context) - .accentColor, - fontWeight: - FontWeight - .normal), - ), - Icon( - JamIcons - .users, - size: 20, - color: Theme.of( - context) - .accentColor, - ), - ], - ); - } else { - List followers = []; - if (snapshot.data! - .docs != - null && - snapshot - .data! - .docs - .isNotEmpty) { - followers = snapshot - .data! - .docs[0] - .data()['followers'] - as List? ?? - []; - } - return GestureDetector( - onTap: () { - // Navigator.pushNamed( - // context, - // followersRoute, - // arguments: [ - // followers - // ]); - }, - child: Row( - children: [ - Text( - followers.length > - 1000 - ? NumberFormat - .compactCurrency( - decimalDigits: - 2, - symbol: - '', - ) - .format(followers - .length) - .toString() - : followers - .length - .toString(), - style: TextStyle( - fontFamily: - "Proxima Nova", - fontSize: - 22, - color: Theme.of(context) - .accentColor, - fontWeight: - FontWeight.normal), - ), - Icon( - JamIcons - .users, - size: 20, - color: Theme.of( - context) - .accentColor, - ), - ], - ), - ); - } - }), - ], - ), - ), - ]), - ], + widget.links ?? + {}); + }), + ]), + ) + ], + ), + ) + ]), + Positioned( + top: MediaQuery.of(context).size.height * + 0.19 - + 56, + child: SizedBox( + width: MediaQuery.of(context).size.width, + child: Center( + child: Container( + decoration: BoxDecoration( + shape: BoxShape.circle, + border: Border.all( + color: + Theme.of(context).errorColor, + width: 4, + ), + color: + Theme.of(context).accentColor, + ), + child: ClipOval( + child: CachedNetworkImage( + imageUrl: widget.userPhoto ?? + "".toString(), + width: 78, + height: 78, + fit: BoxFit.cover, + ), + ), ), - ], + ), ), ), ], ), + // Stack( + // fit: StackFit.expand, + // children: [ + // Container( + // color: Theme.of(context).errorColor, + // ), + // Padding( + // padding: const EdgeInsets.fromLTRB( + // 16, 25, 16, 0), + // child: Column( + // children: [ + // const Spacer(flex: 5), + // Table( + // columnWidths: const { + // 0: FlexColumnWidth(3), + // 1: FlexColumnWidth(5) + // }, + // children: [ + // TableRow(children: [ + // TableCell( + // child: Stack( + // alignment: Alignment.center, + // children: [ + // Container( + // padding: + // const EdgeInsets.all( + // 0), + // decoration: BoxDecoration( + // color: Theme.of(context) + // .errorColor, + // borderRadius: + // BorderRadius + // .circular(5000), + // boxShadow: [ + // BoxShadow( + // blurRadius: 16, + // offset: + // const Offset( + // 0, 4), + // color: const Color( + // 0xFF000000) + // .withOpacity( + // 0.24)) + // ], + // ), + // child: CircleAvatar( + // backgroundColor: + // Colors.transparent, + // foregroundColor: + // Colors.transparent, + // radius: 50, + // child: ClipOval( + // child: Container( + // height: 120, + // margin: + // const EdgeInsets + // .all(0), + // padding: + // const EdgeInsets + // .all(0), + // child: + // CachedNetworkImage( + // fit: BoxFit.cover, + // imageUrl: globals + // .prismUser + // .profilePhoto + // .toString(), + // errorWidget: (context, + // url, + // error) => + // Container(), + // ), + // ), + // ), + // ), + // ), + // if (globals.verifiedUsers + // .contains(globals + // .prismUser.email)) + // Positioned( + // top: 5, + // left: 100, + // child: SizedBox( + // width: 30, + // height: 30, + // child: SvgPicture + // .string(verifiedIcon + // .replaceAll( + // "E57697", + // "FFFFFF")), + // ), + // ) + // else + // Container(), + // ], + // ), + // ), + // TableCell( + // verticalAlignment: + // TableCellVerticalAlignment + // .bottom, + // child: Column( + // children: [ + // Padding( + // padding: + // const EdgeInsets.only( + // bottom: 5), + // child: globals.prismUser + // .premium == + // false + // ? Text( + // globals.prismUser + // .username + // .toUpperCase(), + // textAlign: + // TextAlign + // .center, + // style: TextStyle( + // fontFamily: + // "Proxima Nova", + // color: Theme.of( + // context) + // .accentColor, + // fontSize: 18, + // fontWeight: + // FontWeight + // .w600), + // ) + // : Row( + // mainAxisAlignment: + // MainAxisAlignment + // .center, + // crossAxisAlignment: + // CrossAxisAlignment + // .start, + // children: < + // Widget>[ + // Text( + // globals + // .prismUser + // .username + // .toUpperCase(), + // style: TextStyle( + // fontFamily: + // "Proxima Nova", + // color: Theme.of( + // context) + // .accentColor, + // fontSize: + // 18, + // fontWeight: + // FontWeight + // .w600), + // ), + // Padding( + // padding: const EdgeInsets + // .only( + // left: + // 6.0), + // child: + // Container( + // padding: const EdgeInsets + // .symmetric( + // vertical: + // 2, + // horizontal: + // 4), + // decoration: + // BoxDecoration( + // borderRadius: + // BorderRadius.circular( + // 50), + // color: Theme.of( + // context) + // .accentColor, + // ), + // child: Text( + // "PRO", + // style: Theme.of( + // context) + // .textTheme + // .bodyText2! + // .copyWith( + // fontSize: + // 9, + // color: + // Theme.of(context).errorColor, + // ), + // ), + // ), + // ) + // ], + // ), + // ), + // Padding( + // padding: + // const EdgeInsets.only( + // bottom: 15), + // child: Text( + // globals.prismUser.bio, + // textAlign: + // TextAlign.center, + // maxLines: 3, + // overflow: TextOverflow + // .ellipsis, + // ), + // ) + // ], + // ), + // ), + // ]), + // TableRow(children: [ + // TableCell( + // verticalAlignment: + // TableCellVerticalAlignment + // .middle, + // child: Container() + // //ToDo Add link button in profile + // // IconButton( + // // icon: Icon( + // // JamIcons.link, + // // color: Theme.of(context) + // // .accentColor, + // // ), + // // onPressed: () { + // // showLinksPopUp(context, + // // globals.prismUser.id); + // // }), + // ), + // TableCell( + // verticalAlignment: + // TableCellVerticalAlignment + // .middle, + // child: Row( + // mainAxisAlignment: + // MainAxisAlignment + // .spaceEvenly, + // children: [ + // GestureDetector( + // onTap: () { + // Navigator.pushNamed( + // context, + // favWallRoute); + // }, + // child: Row( + // children: [ + // Text( + // "${favCount.toString()} ", + // style: TextStyle( + // fontFamily: + // "Proxima Nova", + // fontSize: 22, + // color: Theme.of( + // context) + // .accentColor, + // fontWeight: + // FontWeight + // .normal), + // ), + // Icon( + // JamIcons.heart_f, + // size: 20, + // color: Theme.of( + // context) + // .accentColor, + // ), + // ], + // ), + // ), + // // Row( + // // children: [ + // // FutureBuilder( + // // future: Provider.of< + // // ProfileWallProvider>( + // // context, + // // listen: + // // false) + // // .getProfileWallsLength(), + // // builder: (context, + // // snapshot) { + // // return Text( + // // snapshot.data == + // // null + // // ? "${profileCount.toString()} " + // // : "${snapshot.data.toString()} ", + // // style: TextStyle( + // // fontFamily: + // // "Proxima Nova", + // // fontSize: + // // 22, + // // color: Theme.of( + // // context) + // // .accentColor, + // // fontWeight: + // // FontWeight + // // .normal), + // // ); + // // }), + // // Icon( + // // JamIcons.upload, + // // size: 20, + // // color: + // // Theme.of(context) + // // .accentColor, + // // ), + // // ], + // // ), + // StreamBuilder< + // QuerySnapshot>( + // stream: users + // .where("email", + // isEqualTo: globals + // .prismUser + // .email) + // .snapshots(), + // builder: (BuildContext + // context, + // AsyncSnapshot< + // QuerySnapshot> + // snapshot) { + // if (!snapshot + // .hasData) { + // return Row( + // children: [ + // Text( + // "0", + // style: TextStyle( + // fontFamily: + // "Proxima Nova", + // fontSize: + // 22, + // color: Theme.of( + // context) + // .accentColor, + // fontWeight: + // FontWeight + // .normal), + // ), + // Icon( + // JamIcons + // .users, + // size: 20, + // color: Theme.of( + // context) + // .accentColor, + // ), + // ], + // ); + // } else { + // List followers = []; + // if (snapshot.data! + // .docs != + // null && + // snapshot + // .data! + // .docs + // .isNotEmpty) { + // followers = snapshot + // .data! + // .docs[0] + // .data()['followers'] + // as List? ?? + // []; + // } + // return GestureDetector( + // onTap: () { + // // Navigator.pushNamed( + // // context, + // // followersRoute, + // // arguments: [ + // // followers + // // ]); + // }, + // child: Row( + // children: [ + // Text( + // followers.length > + // 1000 + // ? NumberFormat + // .compactCurrency( + // decimalDigits: + // 2, + // symbol: + // '', + // ) + // .format(followers + // .length) + // .toString() + // : followers + // .length + // .toString(), + // style: TextStyle( + // fontFamily: + // "Proxima Nova", + // fontSize: + // 22, + // color: Theme.of(context) + // .accentColor, + // fontWeight: + // FontWeight.normal), + // ), + // Icon( + // JamIcons + // .users, + // size: 20, + // color: Theme.of( + // context) + // .accentColor, + // ), + // ], + // ), + // ); + // } + // }), + // ], + // ), + // ), + // ]), + // ], + // ), + // ], + // ), + // ), + // ], + // ), ), - ), - SliverAppBar( - backgroundColor: Theme.of(context).errorColor, - automaticallyImplyLeading: false, - pinned: true, - titleSpacing: 0, - expandedHeight: globals.prismUser.loggedIn ? 50 : 0, - title: SizedBox( - width: MediaQuery.of(context).size.width, - height: 57, - child: Container( - color: Theme.of(context).errorColor, - child: SizedBox.expand( - child: TabBar( - indicatorColor: - Theme.of(context).accentColor, - indicatorSize: TabBarIndicatorSize.label, - unselectedLabelColor: - const Color(0xFFFFFFFF) - .withOpacity(0.5), - labelColor: const Color(0xFFFFFFFF), - tabs: [ - Text( - "Wallpapers", - style: Theme.of(context) - .textTheme - .bodyText2! - .copyWith( - color: Theme.of(context) - .accentColor), - ), - Text( - "Setups", - style: Theme.of(context) - .textTheme - .bodyText2! - .copyWith( - color: Theme.of(context) - .accentColor), - ), - ]), - ), - ), - ), - ), - ], - body: TabBarView(children: [ - Padding( - padding: const EdgeInsets.only(top: 5), - child: ProfileLoader( - future: Provider.of(context, - listen: false) - .getProfileWalls(), + Container( + width: double.maxFinite, + height: MediaQuery.of(context).padding.top, + color: Theme.of(context) + .primaryColor + .withOpacity(0.5), ), - ), - Padding( - padding: const EdgeInsets.only(top: 5), - child: UploadedSetupsLoader( - future: Provider.of(context, - listen: false) - .getProfileSetups(), + ], + ), + ), + SliverAppBar( + backgroundColor: Theme.of(context).primaryColor, + automaticallyImplyLeading: false, + pinned: true, + titleSpacing: 0, + expandedHeight: + !widget.ownProfile! || globals.prismUser.loggedIn + ? 50 + : 0, + title: SizedBox( + width: MediaQuery.of(context).size.width, + height: 57, + child: Container( + color: Theme.of(context).primaryColor, + child: SizedBox.expand( + child: TabBar( + indicatorColor: Theme.of(context).accentColor, + indicatorSize: TabBarIndicatorSize.label, + unselectedLabelColor: + const Color(0xFFFFFFFF).withOpacity(0.5), + labelColor: const Color(0xFFFFFFFF), + tabs: [ + Text( + "Wallpapers", + style: Theme.of(context) + .textTheme + .bodyText2! + .copyWith( + color: Theme.of(context) + .accentColor), + ), + Text( + "Setups", + style: Theme.of(context) + .textTheme + .bodyText2! + .copyWith( + color: Theme.of(context) + .accentColor), + ), + ]), ), ), - ]), + ), ), - ), - ], - )) - : Scaffold( - backgroundColor: Theme.of(context).primaryColor, - body: - CustomScrollView(controller: controller, slivers: [ - SliverAppBar( - backgroundColor: Theme.of(context).errorColor, - automaticallyImplyLeading: false, - expandedHeight: 280.0, - flexibleSpace: FlexibleSpaceBar( - background: Stack( - fit: StackFit.expand, - children: [ - Stack( - children: [ - Container( - color: Theme.of(context).errorColor, - ), - Padding( - padding: const EdgeInsets.fromLTRB(0, 20, 0, 0), - child: Center( - child: SizedBox( - width: - MediaQuery.of(context).size.width / 2, - child: const FlareActor( - "assets/animations/Text.flr", - animation: "Untitled", - ), - ), - ), - ) - ], + ], + body: TabBarView(children: [ + Padding( + padding: const EdgeInsets.only(top: 5), + child: UserProfileLoader( + email: widget.email, + ), + ), + Padding( + padding: const EdgeInsets.only(top: 5), + child: UserProfileSetupLoader( + email: widget.email, + ), + ), + ]), + ), + ), + ], + )) + : Scaffold( + backgroundColor: Theme.of(context).primaryColor, + body: CustomScrollView(controller: controller, slivers: [ + SliverAppBar( + backgroundColor: Theme.of(context).errorColor, + automaticallyImplyLeading: false, + expandedHeight: 280.0, + flexibleSpace: FlexibleSpaceBar( + background: Stack( + fit: StackFit.expand, + children: [ + Stack( + children: [ + Container( + color: Theme.of(context).errorColor, ), + Padding( + padding: const EdgeInsets.fromLTRB(0, 20, 0, 0), + child: Center( + child: SizedBox( + width: MediaQuery.of(context).size.width / 2, + child: const FlareActor( + "assets/animations/Text.flr", + animation: "Untitled", + ), + ), + ), + ) ], ), - ), + ], ), - SliverList( - delegate: SliverChildListDelegate([ - Padding( - padding: const EdgeInsets.only(top: 10), - child: PremiumList(), - ), - DownloadList(), - const GeneralList( - expanded: false, - ), - UserList( - expanded: false, - ), - AboutList(), - const SizedBox( - height: 300, - ), - ])) - ]), - )); + ), + ), + SliverList( + delegate: SliverChildListDelegate([ + Padding( + padding: const EdgeInsets.only(top: 10), + child: PremiumList(), + ), + DownloadList(), + const GeneralList( + expanded: false, + ), + UserList( + expanded: false, + ), + AboutList(), + const SizedBox( + height: 300, + ), + ])) + ]), + ); } } + +Map> linksData = { + 'github': { + 'name': 'github', + 'link': 'https://github.com/username', + 'icon': JamIcons.github, + 'value': '', + 'validator': 'github', + }, + 'twitter': { + 'name': 'twitter', + 'link': 'https://twitter.com/username', + 'icon': JamIcons.twitter, + 'value': '', + 'validator': 'twitter', + }, + 'instagram': { + 'name': 'instagram', + 'link': 'https://instagram.com/username', + 'icon': JamIcons.instagram, + 'value': '', + 'validator': 'instagram', + }, + 'email': { + 'name': 'email', + 'link': 'your@email.com', + 'icon': JamIcons.inbox, + 'value': '', + 'validator': '@', + }, + 'telegram': { + 'name': 'telegram', + 'link': 'https://t.me/username', + 'icon': JamIcons.paper_plane, + 'value': '', + 'validator': 't.me', + }, + 'dribbble': { + 'name': 'dribbble', + 'link': 'https://dribbble.com/username', + 'icon': JamIcons.basketball, + 'value': '', + 'validator': 'dribbble', + }, + 'linkedin': { + 'name': 'linkedin', + 'link': 'https://linkedin.com/in/username', + 'icon': JamIcons.linkedin, + 'value': '', + 'validator': 'linkedin', + }, + 'bio.link': { + 'name': 'bio.link', + 'link': 'https://bio.link/username', + 'icon': JamIcons.world, + 'value': '', + 'validator': 'bio.link', + }, + 'patreon': { + 'name': 'patreon', + 'link': 'https://patreon.com/username', + 'icon': JamIcons.patreon, + 'value': '', + 'validator': 'patreon', + }, + 'trello': { + 'name': 'trello', + 'link': 'https://trello.com/username', + 'icon': JamIcons.trello, + 'value': '', + 'validator': 'trello', + }, + 'reddit': { + 'name': 'reddit', + 'link': 'https://reddit.com/user/username', + 'icon': JamIcons.reddit, + 'value': '', + 'validator': 'reddit', + }, + 'behance': { + 'name': 'behance', + 'link': 'https://behance.net/username', + 'icon': JamIcons.behance, + 'value': '', + 'validator': 'behance.net', + }, + 'deviantart': { + 'name': 'deviantart', + 'link': 'https://deviantart.com/username', + 'icon': JamIcons.deviantart, + 'value': '', + 'validator': 'deviantart', + }, + 'gitlab': { + 'name': 'gitlab', + 'link': 'https://gitlab.com/username', + 'icon': JamIcons.gitlab, + 'value': '', + 'validator': 'gitlab', + }, + 'medium': { + 'name': 'medium', + 'link': 'https://username.medium.com/', + 'icon': JamIcons.medium, + 'value': '', + 'validator': 'medium', + }, + 'paypal': { + 'name': 'paypal', + 'link': 'https://paypal.me/username', + 'icon': JamIcons.paypal, + 'value': '', + 'validator': 'paypal', + }, + 'spotify': { + 'name': 'spotify', + 'link': 'https://open.spotify.com/user/username', + 'icon': JamIcons.spotify, + 'value': '', + 'validator': 'open.spotify', + }, + 'twitch': { + 'name': 'twitch', + 'link': 'https://twitch.tv/username', + 'icon': JamIcons.twitch, + 'value': '', + 'validator': 'twitch.tv', + }, + 'unsplash': { + 'name': 'unsplash', + 'link': 'https://unsplash.com/username', + 'icon': JamIcons.unsplash, + 'value': '', + 'validator': 'unsplash', + }, + 'youtube': { + 'name': 'youtube', + 'link': 'https://youtube.com/channel/username', + 'icon': JamIcons.youtube, + 'value': '', + 'validator': 'youtube', + }, + 'linktree': { + 'name': 'linktree', + 'link': 'https://linktr.ee/username', + 'icon': JamIcons.tree_alt, + 'value': '', + 'validator': 'linktr.ee', + }, + 'buymeacoffee': { + 'name': 'buymeacoffee', + 'link': 'https://buymeacoff.ee/username', + 'icon': JamIcons.coffee, + 'value': '', + 'validator': 'buymeacoff.ee', + }, + 'custom link': { + 'name': 'custom link', + 'link': '', + 'icon': JamIcons.link, + 'value': '', + 'validator': '', + }, +}; diff --git a/lib/ui/pages/profile/profileSetupViewScreen.dart b/lib/ui/pages/profile/profileSetupViewScreen.dart index 5ccb93bb..d80c4740 100644 --- a/lib/ui/pages/profile/profileSetupViewScreen.dart +++ b/lib/ui/pages/profile/profileSetupViewScreen.dart @@ -4,6 +4,7 @@ import 'package:Prism/data/favourites/provider/favouriteSetupProvider.dart'; import 'package:Prism/data/informatics/dataManager.dart'; import 'package:Prism/data/profile/wallpaper/profileSetupProvider.dart'; import 'package:Prism/data/share/createDynamicLink.dart'; +import 'package:Prism/logger/logger.dart'; import 'package:Prism/routes/router.dart'; import 'package:Prism/routes/routing_constants.dart'; import 'package:Prism/theme/jam_icons_icons.dart'; @@ -42,7 +43,7 @@ class _ProfileSetupViewScreenState extends State with SingleTickerProviderStateMixin { Future onWillPop() async { navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); return true; } @@ -578,7 +579,7 @@ class _ProfileSetupViewScreenState extends State .profileSetups![ index!]["wall_id"] == "") { - debugPrint("Id Not Found!"); + logger.d("Id Not Found!"); launch(Provider.of< ProfileSetupProvider>( context, @@ -765,7 +766,7 @@ class _ProfileSetupViewScreenState extends State .profileSetups![ index!]["wall_id"] == "") { - debugPrint("Id Not Found!"); + logger.d("Id Not Found!"); launch(Provider.of< ProfileSetupProvider>( context, @@ -1030,7 +1031,7 @@ class _ProfileSetupViewScreenState extends State .profileSetups![ index!]["wall_id"] == "") { - debugPrint("Id Not Found!"); + logger.d("Id Not Found!"); launch(Provider.of< ProfileSetupProvider>( context, @@ -1458,7 +1459,7 @@ class _ProfileSetupViewScreenState extends State animation: offsetAnimation, builder: (buildContext, child) { if (offsetAnimation.value < 0.0) { - debugPrint('${offsetAnimation.value + 8.0}'); + logger.d('${offsetAnimation.value + 8.0}'); } return GestureDetector( onPanUpdate: (details) { @@ -1526,7 +1527,7 @@ class _ProfileSetupViewScreenState extends State child: IconButton( onPressed: () { navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); Navigator.pop(context); }, color: Theme.of(context).accentColor, @@ -1551,11 +1552,11 @@ class _ProfileSetupViewScreenState extends State listen: false) .profileSetups![index!]["image"] .toString(); - debugPrint(link); + logger.d(link); final androidInfo = await DeviceInfoPlugin().androidInfo; final sdkInt = androidInfo.version.sdkInt; - debugPrint('(SDK $sdkInt)'); + logger.d('(SDK $sdkInt)'); toasts.codeSend("Starting Download"); if (sdkInt >= 30) { @@ -1574,7 +1575,7 @@ class _ProfileSetupViewScreenState extends State isLoading = false; }); }).catchError((e) { - debugPrint(e.toString()); + logger.d(e.toString()); setState(() { isLoading = false; }); diff --git a/lib/ui/pages/profile/profileWallViewScreen.dart b/lib/ui/pages/profile/profileWallViewScreen.dart index 689721b8..1abaa88a 100644 --- a/lib/ui/pages/profile/profileWallViewScreen.dart +++ b/lib/ui/pages/profile/profileWallViewScreen.dart @@ -22,6 +22,7 @@ import 'package:screenshot/screenshot.dart'; import 'package:sliding_up_panel/sliding_up_panel.dart'; import 'package:Prism/main.dart' as main; import 'package:Prism/global/globals.dart' as globals; +import 'package:Prism/logger/logger.dart'; class ProfileWallViewScreen extends StatefulWidget { final List? arguments; @@ -35,7 +36,7 @@ class _ProfileWallViewScreenState extends State with SingleTickerProviderStateMixin { Future onWillPop() async { if (navStack.length > 1) navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); return true; } @@ -154,7 +155,7 @@ class _ProfileWallViewScreenState extends State panelCollapsed = false; }); if (panelClosed) { - debugPrint('Screenshot Starting'); + logger.d('Screenshot Starting'); if (colorChanged) { screenshotController .capture( @@ -167,9 +168,9 @@ class _ProfileWallViewScreenState extends State screenshotTaken = true; panelClosed = false; }); - debugPrint('Screenshot Taken'); + logger.d('Screenshot Taken'); }).catchError((onError) { - debugPrint(onError.toString()); + logger.d(onError.toString()); }); } else { main.prefs.get('optimisedWallpapers') as bool? ?? true @@ -184,11 +185,11 @@ class _ProfileWallViewScreenState extends State screenshotTaken = true; panelClosed = false; }); - debugPrint('Screenshot Taken'); + logger.d('Screenshot Taken'); }).catchError((onError) { - debugPrint(onError.toString()); + logger.d(onError.toString()); }) - : debugPrint("Wallpaper Optimisation is disabled!"); + : logger.d("Wallpaper Optimisation is disabled!"); } } }, @@ -597,7 +598,7 @@ class _ProfileWallViewScreenState extends State animation: offsetAnimation, builder: (buildContext, child) { if (offsetAnimation.value < 0.0) { - debugPrint('${offsetAnimation.value + 8.0}'); + logger.d('${offsetAnimation.value + 8.0}'); } return GestureDetector( onPanUpdate: (details) { @@ -614,7 +615,7 @@ class _ProfileWallViewScreenState extends State }, onTap: () { HapticFeedback.vibrate(); - !isLoading ? updateAccent() : debugPrint(""); + !isLoading ? updateAccent() : logger.d(""); shakeController.forward(from: 0.0); }, child: CachedNetworkImage( @@ -675,7 +676,7 @@ class _ProfileWallViewScreenState extends State child: IconButton( onPressed: () { navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); Navigator.pop(context); }, color: isLoading diff --git a/lib/ui/pages/profile/reviewScreen.dart b/lib/ui/pages/profile/reviewScreen.dart index bc35b482..0ffeea48 100644 --- a/lib/ui/pages/profile/reviewScreen.dart +++ b/lib/ui/pages/profile/reviewScreen.dart @@ -20,6 +20,7 @@ import 'package:Prism/analytics/analytics_service.dart'; import 'package:animations/animations.dart'; import 'package:url_launcher/url_launcher.dart'; import 'package:Prism/global/globals.dart' as globals; +import 'package:Prism/logger/logger.dart'; class ReviewScreen extends StatefulWidget { @override @@ -31,7 +32,7 @@ class _ReviewScreenState extends State TabController? tabController; Future onWillPop() async { if (navStack.length > 1) navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); return true; } @@ -78,7 +79,7 @@ class _ReviewScreenState extends State icon: const Icon(JamIcons.chevron_left), onPressed: () { navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); Navigator.pop(context); }), backgroundColor: Theme.of(context).primaryColor, @@ -369,12 +370,12 @@ class WallTile extends StatelessWidget { final link = wallpaper .data()!["wallpaper_url"] .toString(); - debugPrint(link); + logger.d(link); final androidInfo = await DeviceInfoPlugin().androidInfo; final sdkInt = androidInfo.version.sdkInt; - debugPrint('(SDK $sdkInt)'); + logger.d('(SDK $sdkInt)'); toasts.codeSend("Starting Download"); main.localNotification .createDownloadNotification(); @@ -396,7 +397,7 @@ class WallTile extends StatelessWidget { "Couldn't download! Please Retry!"); } }).catchError((e) { - debugPrint(e.toString()); + logger.d(e.toString()); }); } else { GallerySaver.saveImage(link, @@ -708,12 +709,12 @@ class RejectedWallTile extends StatelessWidget { final link = wallpaper .data()!["wallpaper_url"] .toString(); - debugPrint(link); + logger.d(link); final androidInfo = await DeviceInfoPlugin().androidInfo; final sdkInt = androidInfo.version.sdkInt; - debugPrint('(SDK $sdkInt)'); + logger.d('(SDK $sdkInt)'); toasts.codeSend("Starting Download"); main.localNotification .createDownloadNotification(); @@ -735,7 +736,7 @@ class RejectedWallTile extends StatelessWidget { "Couldn't download! Please Retry!"); } }).catchError((e) { - debugPrint(e.toString()); + logger.d(e.toString()); }); } else { GallerySaver.saveImage(link, @@ -1359,12 +1360,12 @@ class SetupTile extends StatelessWidget { } final link = wallpaper.data()!["image"].toString(); - debugPrint(link); + logger.d(link); final androidInfo = await DeviceInfoPlugin().androidInfo; final sdkInt = androidInfo.version.sdkInt; - debugPrint('(SDK $sdkInt)'); + logger.d('(SDK $sdkInt)'); toasts.codeSend("Starting Download"); if (sdkInt >= 30) { @@ -1382,7 +1383,7 @@ class SetupTile extends StatelessWidget { "Couldn't download! Please Retry!"); } }).catchError((e) { - debugPrint(e.toString()); + logger.d(e.toString()); }); } else { GallerySaver.saveImage(link, @@ -1897,12 +1898,12 @@ class RejectedSetupTile extends StatelessWidget { } final link = wallpaper.data()!["image"].toString(); - debugPrint(link); + logger.d(link); final androidInfo = await DeviceInfoPlugin().androidInfo; final sdkInt = androidInfo.version.sdkInt; - debugPrint('(SDK $sdkInt)'); + logger.d('(SDK $sdkInt)'); toasts.codeSend("Starting Download"); if (sdkInt >= 30) { @@ -1920,7 +1921,7 @@ class RejectedSetupTile extends StatelessWidget { "Couldn't download! Please Retry!"); } }).catchError((e) { - debugPrint(e.toString()); + logger.d(e.toString()); }); } else { GallerySaver.saveImage(link, diff --git a/lib/ui/pages/profile/settings.dart b/lib/ui/pages/profile/settings.dart index 2b261ab3..5010412e 100644 --- a/lib/ui/pages/profile/settings.dart +++ b/lib/ui/pages/profile/settings.dart @@ -15,6 +15,7 @@ import 'package:Prism/data/favourites/provider/favouriteProvider.dart'; import 'package:Prism/data/favourites/provider/favouriteSetupProvider.dart'; import 'package:animations/animations.dart'; import 'package:Prism/global/globals.dart' as globals; +import 'package:Prism/logger/logger.dart'; class SettingsScreen extends StatefulWidget { const SettingsScreen({ @@ -35,7 +36,7 @@ class _SettingsScreenState extends State { return WillPopScope( onWillPop: () async { if (navStack.length > 1) navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); return true; }, child: Scaffold( @@ -347,7 +348,7 @@ class _SettingsScreenState extends State { Navigator.pop(context); main.RestartWidget.restartApp(context); }).catchError((e) { - debugPrint(e.toString()); + logger.d(e.toString()); Navigator.pop(context); globals.prismUser.loggedIn = false; main.prefs.put("prismUserV2", globals.prismUser); diff --git a/lib/ui/pages/profile/sharePrismScreen.dart b/lib/ui/pages/profile/sharePrismScreen.dart index 032efa50..b10e3f09 100644 --- a/lib/ui/pages/profile/sharePrismScreen.dart +++ b/lib/ui/pages/profile/sharePrismScreen.dart @@ -5,6 +5,7 @@ import 'package:flutter/material.dart'; import 'package:share/share.dart'; import 'package:Prism/theme/toasts.dart' as toasts; import 'package:Prism/global/globals.dart' as globals; +import 'package:Prism/logger/logger.dart'; class SharePrismScreen extends StatefulWidget { @override @@ -31,7 +32,7 @@ class _SharePrismScreenState extends State { Future onWillPop() async { if (navStack.length > 1) navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); return true; } diff --git a/lib/ui/pages/profile/themeView.dart b/lib/ui/pages/profile/themeView.dart index e97f070d..c6fd3222 100644 --- a/lib/ui/pages/profile/themeView.dart +++ b/lib/ui/pages/profile/themeView.dart @@ -1,4 +1,5 @@ import 'package:Prism/global/svgAssets.dart'; +import 'package:Prism/logger/logger.dart'; import 'package:Prism/routes/router.dart'; import 'package:Prism/theme/darkThemeModel.dart'; import 'package:Prism/theme/jam_icons_icons.dart'; @@ -84,7 +85,7 @@ class _ThemeViewState extends State { Future onWillPop() async { if (navStack.length > 1) navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); return true; } @@ -117,7 +118,7 @@ class _ThemeViewState extends State { analytics.logEvent( name: "accent_changed", parameters: {'color': hexString}); navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); Navigator.pop(context); }) ], @@ -331,7 +332,7 @@ class _ThemeViewState extends State { onPressed: () { Provider.of(context, listen: false) .changeThemeByID(themes.keys.toList()[index]); - debugPrint(selectedAccentColor.toString()); + logger.d(selectedAccentColor.toString()); setState(() { changingLight = true; selectedTheme = index; @@ -346,7 +347,7 @@ class _ThemeViewState extends State { .replaceAll("Color(", "") .replaceAll(")", ""))); }); - debugPrint(selectedAccentColor.toString()); + logger.d(selectedAccentColor.toString()); }, child: Stack( children: [ @@ -448,7 +449,7 @@ class _ThemeViewState extends State { Provider.of(context, listen: false) .changeThemeByID( darkThemes.keys.toList()[index]); - debugPrint(selectedDarkAccentColor.toString()); + logger.d(selectedDarkAccentColor.toString()); setState(() { changingLight = false; selectedDarkTheme = index; @@ -464,7 +465,7 @@ class _ThemeViewState extends State { .replaceAll("Color(", "") .replaceAll(")", ""))); }); - debugPrint(selectedDarkAccentColor.toString()); + logger.d(selectedDarkAccentColor.toString()); }, child: Stack( children: [ diff --git a/lib/ui/pages/profile/userProfileSetupViewScreen.dart b/lib/ui/pages/profile/userProfileSetupViewScreen.dart index b568bca7..63b75907 100644 --- a/lib/ui/pages/profile/userProfileSetupViewScreen.dart +++ b/lib/ui/pages/profile/userProfileSetupViewScreen.dart @@ -26,6 +26,7 @@ import 'package:Prism/analytics/analytics_service.dart'; import 'package:Prism/ui/widgets/animated/showUp.dart'; import 'package:Prism/ui/widgets/popup/signInPopUp.dart'; import 'package:hive/hive.dart'; +import 'package:Prism/logger/logger.dart'; class UserProfileSetupViewScreen extends StatefulWidget { final List? arguments; @@ -40,7 +41,7 @@ class _UserProfileSetupViewScreenState extends State with SingleTickerProviderStateMixin { Future onWillPop() async { navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); return true; } @@ -600,7 +601,7 @@ class _UserProfileSetupViewScreenState extends State index!] .data()["wall_id"] == "") { - debugPrint("Id Not Found!"); + logger.d("Id Not Found!"); launch(Provider.of< user_data .UserProfileProvider>( @@ -808,7 +809,7 @@ class _UserProfileSetupViewScreenState extends State index!] .data()["wall_id"] == "") { - debugPrint("Id Not Found!"); + logger.d("Id Not Found!"); launch(Provider.of< user_data .UserProfileProvider>( @@ -1118,7 +1119,7 @@ class _UserProfileSetupViewScreenState extends State index!] .data()["wall_id"] == "") { - debugPrint("Id Not Found!"); + logger.d("Id Not Found!"); launch(Provider.of< user_data .UserProfileProvider>( @@ -1606,7 +1607,7 @@ class _UserProfileSetupViewScreenState extends State animation: offsetAnimation, builder: (buildContext, child) { if (offsetAnimation.value < 0.0) { - debugPrint('${offsetAnimation.value + 8.0}'); + logger.d('${offsetAnimation.value + 8.0}'); } return GestureDetector( onPanUpdate: (details) { @@ -1675,7 +1676,7 @@ class _UserProfileSetupViewScreenState extends State child: IconButton( onPressed: () { navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); Navigator.pop(context); }, color: Theme.of(context).accentColor, diff --git a/lib/ui/pages/profile/userProfileWallViewScreen.dart b/lib/ui/pages/profile/userProfileWallViewScreen.dart index 4fa8d272..1876a362 100644 --- a/lib/ui/pages/profile/userProfileWallViewScreen.dart +++ b/lib/ui/pages/profile/userProfileWallViewScreen.dart @@ -22,6 +22,7 @@ import 'package:screenshot/screenshot.dart'; import 'package:sliding_up_panel/sliding_up_panel.dart'; import 'package:Prism/main.dart' as main; import 'package:Prism/global/globals.dart' as globals; +import 'package:Prism/logger/logger.dart'; class UserProfileWallViewScreen extends StatefulWidget { final List? arguments; @@ -36,7 +37,7 @@ class _UserProfileWallViewScreenState extends State with SingleTickerProviderStateMixin { Future onWillPop() async { if (navStack.length > 1) navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); return true; } @@ -158,7 +159,7 @@ class _UserProfileWallViewScreenState extends State panelCollapsed = false; }); if (panelClosed) { - debugPrint('Screenshot Starting'); + logger.d('Screenshot Starting'); if (colorChanged) { screenshotController .capture( @@ -171,9 +172,9 @@ class _UserProfileWallViewScreenState extends State screenshotTaken = true; panelClosed = false; }); - debugPrint('Screenshot Taken'); + logger.d('Screenshot Taken'); }).catchError((onError) { - debugPrint(onError.toString()); + logger.d(onError.toString()); }); } else { main.prefs.get('optimisedWallpapers') as bool? ?? true @@ -188,11 +189,11 @@ class _UserProfileWallViewScreenState extends State screenshotTaken = true; panelClosed = false; }); - debugPrint('Screenshot Taken'); + logger.d('Screenshot Taken'); }).catchError((onError) { - debugPrint(onError.toString()); + logger.d(onError.toString()); }) - : debugPrint("Wallpaper Optimisation is disabled!"); + : logger.d("Wallpaper Optimisation is disabled!"); } } }, @@ -612,7 +613,7 @@ class _UserProfileWallViewScreenState extends State animation: offsetAnimation, builder: (buildContext, child) { if (offsetAnimation.value < 0.0) { - debugPrint('${offsetAnimation.value + 8.0}'); + logger.d('${offsetAnimation.value + 8.0}'); } return GestureDetector( onPanUpdate: (details) { @@ -629,7 +630,7 @@ class _UserProfileWallViewScreenState extends State }, onTap: () { HapticFeedback.vibrate(); - !isLoading ? updateAccent() : debugPrint(""); + !isLoading ? updateAccent() : logger.d(""); shakeController.forward(from: 0.0); }, child: CachedNetworkImage( @@ -691,7 +692,7 @@ class _UserProfileWallViewScreenState extends State child: IconButton( onPressed: () { navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); Navigator.pop(context); }, color: isLoading diff --git a/lib/ui/pages/search/searchScreen.dart b/lib/ui/pages/search/searchScreen.dart index 2c33cf43..b4d1a40c 100644 --- a/lib/ui/pages/search/searchScreen.dart +++ b/lib/ui/pages/search/searchScreen.dart @@ -13,6 +13,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:provider/provider.dart'; import 'package:Prism/main.dart' as main; +import 'package:Prism/logger/logger.dart'; class SearchScreen extends StatefulWidget { @override @@ -22,7 +23,7 @@ class SearchScreen extends StatefulWidget { class _SearchScreenState extends State { Future onWillPop() async { if (navStack.length > 1) navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); return true; } @@ -165,7 +166,7 @@ class _SearchScreenState extends State { elevation: 4, initialValue: selectedProviders, onCanceled: () { - debugPrint('You have not choosed anything'); + logger.d('You have not choosed anything'); }, color: Theme.of(context).hintColor, tooltip: 'Providers', @@ -439,12 +440,12 @@ class _SearchLoaderState extends State { future: _future, builder: (ctx, snapshot) { if (snapshot == null) { - debugPrint("snapshot null"); + logger.d("snapshot null"); return const LoadingCards(); } if (snapshot.connectionState == ConnectionState.waiting || snapshot.connectionState == ConnectionState.none) { - debugPrint("snapshot none, waiting"); + logger.d("snapshot none, waiting"); return const LoadingCards(); } else { return SearchGrid( diff --git a/lib/ui/pages/search/searchWallpaperScreen.dart b/lib/ui/pages/search/searchWallpaperScreen.dart index 9e8f26fa..1a969fea 100644 --- a/lib/ui/pages/search/searchWallpaperScreen.dart +++ b/lib/ui/pages/search/searchWallpaperScreen.dart @@ -23,6 +23,7 @@ import 'package:screenshot/screenshot.dart'; import 'package:url_launcher/url_launcher.dart'; import 'package:Prism/main.dart' as main; import 'package:Prism/global/globals.dart' as globals; +import 'package:Prism/logger/logger.dart'; class SearchWallpaperScreen extends StatefulWidget { final List? arguments; @@ -35,7 +36,7 @@ class _SearchWallpaperScreenState extends State with SingleTickerProviderStateMixin { Future onWillPop() async { if (navStack.length > 1) navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); return true; } @@ -147,7 +148,7 @@ class _SearchWallpaperScreenState extends State panelCollapsed = false; }); if (panelClosed) { - debugPrint('Screenshot Starting'); + logger.d('Screenshot Starting'); setState(() { panelClosed = false; }); @@ -163,9 +164,9 @@ class _SearchWallpaperScreenState extends State screenshotTaken = true; panelClosed = false; }); - debugPrint('Screenshot Taken'); + logger.d('Screenshot Taken'); }).catchError((onError) { - debugPrint(onError.toString()); + logger.d(onError.toString()); }); } else { main.prefs.get('optimisedWallpapers') as bool? ?? true @@ -179,11 +180,11 @@ class _SearchWallpaperScreenState extends State _imageFile = File.fromRawPath(image!); screenshotTaken = true; }); - debugPrint('Screenshot Taken'); + logger.d('Screenshot Taken'); }).catchError((onError) { - debugPrint(onError.toString()); + logger.d(onError.toString()); }) - : debugPrint("Wallpaper Optimisation is disabled!"); + : logger.d("Wallpaper Optimisation is disabled!"); } } }, @@ -484,7 +485,7 @@ class _SearchWallpaperScreenState extends State animation: offsetAnimation, builder: (buildContext, child) { if (offsetAnimation.value < 0.0) { - debugPrint('${offsetAnimation.value + 8.0}'); + logger.d('${offsetAnimation.value + 8.0}'); } return GestureDetector( onPanUpdate: (details) { @@ -501,7 +502,7 @@ class _SearchWallpaperScreenState extends State }, onTap: () { HapticFeedback.vibrate(); - !isLoading ? updateAccent() : debugPrint(""); + !isLoading ? updateAccent() : logger.d(""); shakeController.forward(from: 0.0); }, child: CachedNetworkImage( @@ -561,7 +562,7 @@ class _SearchWallpaperScreenState extends State child: IconButton( onPressed: () { navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); Navigator.pop(context); }, color: isLoading @@ -629,7 +630,7 @@ class _SearchWallpaperScreenState extends State panelCollapsed = false; }); if (panelClosed) { - debugPrint('Screenshot Starting'); + logger.d('Screenshot Starting'); setState(() { panelClosed = false; }); @@ -645,9 +646,9 @@ class _SearchWallpaperScreenState extends State screenshotTaken = true; panelClosed = false; }); - debugPrint('Screenshot Taken'); + logger.d('Screenshot Taken'); }).catchError((onError) { - debugPrint(onError.toString()); + logger.d(onError.toString()); }); } else { main.prefs.get('optimisedWallpapers') as bool? ?? true @@ -661,11 +662,11 @@ class _SearchWallpaperScreenState extends State _imageFile = File.fromRawPath(image!); screenshotTaken = true; }); - debugPrint('Screenshot Taken'); + logger.d('Screenshot Taken'); }).catchError((onError) { - debugPrint(onError.toString()); + logger.d(onError.toString()); }) - : debugPrint("Wallpaper Optimisation is disabled!"); + : logger.d("Wallpaper Optimisation is disabled!"); } } }, @@ -981,7 +982,7 @@ class _SearchWallpaperScreenState extends State animation: offsetAnimation, builder: (buildContext, child) { if (offsetAnimation.value < 0.0) { - debugPrint('${offsetAnimation.value + 8.0}'); + logger.d('${offsetAnimation.value + 8.0}'); } return GestureDetector( onPanUpdate: (details) { @@ -998,7 +999,7 @@ class _SearchWallpaperScreenState extends State }, onTap: () { HapticFeedback.vibrate(); - !isLoading ? updateAccent() : debugPrint(""); + !isLoading ? updateAccent() : logger.d(""); shakeController.forward(from: 0.0); }, child: CachedNetworkImage( @@ -1059,7 +1060,7 @@ class _SearchWallpaperScreenState extends State child: IconButton( onPressed: () { navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); Navigator.pop(context); }, color: isLoading diff --git a/lib/ui/pages/setup/setupScreen.dart b/lib/ui/pages/setup/setupScreen.dart index 9783805d..a2ec8ef0 100644 --- a/lib/ui/pages/setup/setupScreen.dart +++ b/lib/ui/pages/setup/setupScreen.dart @@ -15,6 +15,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:provider/provider.dart'; import 'package:Prism/global/globals.dart' as globals; +import 'package:Prism/logger/logger.dart'; class SetupScreen extends StatefulWidget { const SetupScreen({ @@ -28,7 +29,7 @@ class SetupScreen extends StatefulWidget { class _SetupScreenState extends State { Future onWillPop() async { navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); return true; } @@ -155,12 +156,12 @@ class _SetupPageState extends State { future: widget.future, builder: (context, snapshot) { if (snapshot == null) { - debugPrint("snapshot null"); + logger.d("snapshot null"); return Center(child: Loader()); } if (snapshot.connectionState == ConnectionState.waiting || snapshot.connectionState == ConnectionState.none) { - debugPrint("snapshot none, waiting"); + logger.d("snapshot none, waiting"); return Center(child: Loader()); } else { Future.delayed(const Duration()) diff --git a/lib/ui/pages/setup/setupViewScreen.dart b/lib/ui/pages/setup/setupViewScreen.dart index 7963df42..49e35bf7 100644 --- a/lib/ui/pages/setup/setupViewScreen.dart +++ b/lib/ui/pages/setup/setupViewScreen.dart @@ -26,6 +26,7 @@ import 'package:url_launcher/url_launcher.dart'; import 'package:Prism/global/globals.dart' as globals; import 'package:flutter_svg/flutter_svg.dart'; import 'package:Prism/global/svgAssets.dart'; +import 'package:Prism/logger/logger.dart'; class SetupViewScreen extends StatefulWidget { final List? arguments; @@ -39,7 +40,7 @@ class _SetupViewScreenState extends State with SingleTickerProviderStateMixin { Future onWillPop() async { navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); return true; } @@ -569,7 +570,7 @@ class _SetupViewScreenState extends State .setups![index!] ["wall_id"] == "") { - debugPrint("Id Not Found!"); + logger.d("Id Not Found!"); launch(Provider.of( context, listen: false) @@ -745,7 +746,7 @@ class _SetupViewScreenState extends State .setups![index!] ["wall_id"] == "") { - debugPrint("Id Not Found!"); + logger.d("Id Not Found!"); launch( Provider.of( context, @@ -996,7 +997,7 @@ class _SetupViewScreenState extends State .setups![index!] ["wall_id"] == "") { - debugPrint("Id Not Found!"); + logger.d("Id Not Found!"); launch(Provider.of< SetupProvider>( context, @@ -1408,7 +1409,7 @@ class _SetupViewScreenState extends State animation: offsetAnimation, builder: (buildContext, child) { if (offsetAnimation.value < 0.0) { - debugPrint('${offsetAnimation.value + 8.0}'); + logger.d('${offsetAnimation.value + 8.0}'); } return GestureDetector( onPanUpdate: (details) { @@ -1476,7 +1477,7 @@ class _SetupViewScreenState extends State child: IconButton( onPressed: () { navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); Navigator.pop(context); }, color: Theme.of(context).accentColor, diff --git a/lib/ui/pages/setup/shareSetupViewScreen.dart b/lib/ui/pages/setup/shareSetupViewScreen.dart index 39242ab1..eaa985e5 100644 --- a/lib/ui/pages/setup/shareSetupViewScreen.dart +++ b/lib/ui/pages/setup/shareSetupViewScreen.dart @@ -29,6 +29,7 @@ import 'package:Prism/global/globals.dart' as globals; import 'package:flutter_svg/flutter_svg.dart'; import 'package:Prism/global/svgAssets.dart'; import 'package:Prism/theme/toasts.dart' as toasts; +import 'package:Prism/logger/logger.dart'; class ShareSetupViewScreen extends StatefulWidget { final List? arguments; @@ -42,7 +43,7 @@ class _ShareSetupViewScreenState extends State with SingleTickerProviderStateMixin { Future onWillPop() async { navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); return true; } @@ -112,7 +113,7 @@ class _ShareSetupViewScreenState extends State body: FutureBuilder( future: _future, builder: (BuildContext context, AsyncSnapshot snapshot) { - debugPrint(snapshot.connectionState.toString()); + logger.d(snapshot.connectionState.toString()); switch (snapshot.connectionState) { case ConnectionState.waiting: return Center(child: Loader()); @@ -583,8 +584,8 @@ class _ShareSetupViewScreenState extends State sdata.setup![ "wall_id"] == "") { - debugPrint( - "Id Not Found!"); + logger + .d("Id Not Found!"); launch(sdata.setup![ "wallpaper_url"] .toString()); @@ -712,7 +713,7 @@ class _ShareSetupViewScreenState extends State sdata.setup![ "wall_id"] == "") { - debugPrint( + logger.d( "Id Not Found!"); launch(sdata.setup![ "wallpaper_url"] @@ -898,7 +899,7 @@ class _ShareSetupViewScreenState extends State sdata.setup![ "wall_id"] == "") { - debugPrint( + logger.d( "Id Not Found!"); launch(sdata .setup![ @@ -1265,7 +1266,7 @@ class _ShareSetupViewScreenState extends State animation: offsetAnimation, builder: (buildContext, child) { if (offsetAnimation.value < 0.0) { - debugPrint('${offsetAnimation.value + 8.0}'); + logger.d('${offsetAnimation.value + 8.0}'); } return GestureDetector( onPanUpdate: (details) { @@ -1331,7 +1332,7 @@ class _ShareSetupViewScreenState extends State child: IconButton( onPressed: () { navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); Navigator.pop(context); }, color: Theme.of(context).accentColor, diff --git a/lib/ui/pages/share/shareWallViewScreen.dart b/lib/ui/pages/share/shareWallViewScreen.dart index 7c777d44..738dbea1 100644 --- a/lib/ui/pages/share/shareWallViewScreen.dart +++ b/lib/ui/pages/share/shareWallViewScreen.dart @@ -34,6 +34,7 @@ import 'package:Prism/main.dart' as main; import 'package:Prism/global/globals.dart' as globals; import 'package:flutter_svg/flutter_svg.dart'; import 'package:Prism/global/svgAssets.dart'; +import 'package:Prism/logger/logger.dart'; class ShareWallpaperViewScreen extends StatefulWidget { final List? arguments; @@ -86,7 +87,7 @@ class _ShareWallpaperViewScreenState extends State isLoading = false; }); colors = paletteGenerator.colors.toList(); - debugPrint(colors.toString()); + logger.d(colors.toString()); if (paletteGenerator.colors.length > 5) { colors = colors!.sublist(0, 5); } @@ -151,7 +152,7 @@ class _ShareWallpaperViewScreenState extends State Future onWillPop() async { if (navStack.length > 1) navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); return true; } @@ -178,7 +179,7 @@ class _ShareWallpaperViewScreenState extends State panelCollapsed = false; }); if (panelClosed) { - debugPrint('Screenshot Starting'); + logger.d('Screenshot Starting'); if (colorChanged) { screenshotController .capture( @@ -191,9 +192,9 @@ class _ShareWallpaperViewScreenState extends State screenshotTaken = true; panelClosed = false; }); - debugPrint('Screenshot Taken'); + logger.d('Screenshot Taken'); }).catchError((onError) { - debugPrint(onError.toString()); + logger.d(onError.toString()); }); } else { (main.prefs.get('optimisedWallpapers') ?? true) == true @@ -208,11 +209,11 @@ class _ShareWallpaperViewScreenState extends State screenshotTaken = true; panelClosed = false; }); - debugPrint('Screenshot Taken'); + logger.d('Screenshot Taken'); }).catchError((onError) { - debugPrint(onError.toString()); + logger.d(onError.toString()); }) - : debugPrint("Wallpaper Optimisation is disabled!"); + : logger.d("Wallpaper Optimisation is disabled!"); } } }, @@ -264,11 +265,11 @@ class _ShareWallpaperViewScreenState extends State ConnectionState.waiting || snapshot.connectionState == ConnectionState.none) { - debugPrint( - "snapshot none, waiting in share route"); + logger + .d("snapshot none, waiting in share route"); return Center(child: Loader()); } else { - debugPrint("done"); + logger.d("done"); return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -554,7 +555,7 @@ class _ShareWallpaperViewScreenState extends State animation: offsetAnimation, builder: (buildContext, child) { if (offsetAnimation.value < 0.0) { - debugPrint('${offsetAnimation.value + 8.0}'); + logger.d('${offsetAnimation.value + 8.0}'); } return GestureDetector( onPanUpdate: (details) { @@ -571,7 +572,7 @@ class _ShareWallpaperViewScreenState extends State }, onTap: () { HapticFeedback.vibrate(); - !isLoading ? updateAccent() : debugPrint(""); + !isLoading ? updateAccent() : logger.d(""); shakeController.forward(from: 0.0); }, child: CachedNetworkImage( @@ -631,7 +632,7 @@ class _ShareWallpaperViewScreenState extends State child: IconButton( onPressed: () { navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); Navigator.pop(context); }, color: isLoading @@ -700,7 +701,7 @@ class _ShareWallpaperViewScreenState extends State panelCollapsed = false; }); if (panelClosed) { - debugPrint('Screenshot Starting'); + logger.d('Screenshot Starting'); if (colorChanged) { screenshotController .capture( @@ -713,9 +714,9 @@ class _ShareWallpaperViewScreenState extends State screenshotTaken = true; panelClosed = false; }); - debugPrint('Screenshot Taken'); + logger.d('Screenshot Taken'); }).catchError((onError) { - debugPrint(onError.toString()); + logger.d(onError.toString()); }); } else { (main.prefs.get('optimisedWallpapers') ?? true) == @@ -731,12 +732,11 @@ class _ShareWallpaperViewScreenState extends State screenshotTaken = true; panelClosed = false; }); - debugPrint('Screenshot Taken'); + logger.d('Screenshot Taken'); }).catchError((onError) { - debugPrint(onError.toString()); + logger.d(onError.toString()); }) - : debugPrint( - "Wallpaper Optimisation is disabled!"); + : logger.d("Wallpaper Optimisation is disabled!"); } } }, @@ -792,11 +792,11 @@ class _ShareWallpaperViewScreenState extends State ConnectionState.waiting || snapshot.connectionState == ConnectionState.none) { - debugPrint( + logger.d( "snapshot none, waiting in share route"); return Center(child: Loader()); } else { - debugPrint("done"); + logger.d("done"); return Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -1325,7 +1325,7 @@ class _ShareWallpaperViewScreenState extends State animation: offsetAnimation, builder: (buildContext, child) { if (offsetAnimation.value < 0.0) { - debugPrint('${offsetAnimation.value + 8.0}'); + logger.d('${offsetAnimation.value + 8.0}'); } return GestureDetector( onPanUpdate: (details) { @@ -1342,7 +1342,7 @@ class _ShareWallpaperViewScreenState extends State }, onTap: () { HapticFeedback.vibrate(); - !isLoading ? updateAccent() : debugPrint(""); + !isLoading ? updateAccent() : logger.d(""); shakeController.forward(from: 0.0); }, child: CachedNetworkImage( @@ -1404,7 +1404,7 @@ class _ShareWallpaperViewScreenState extends State child: IconButton( onPressed: () { navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); Navigator.pop(context); }, color: isLoading @@ -1474,7 +1474,7 @@ class _ShareWallpaperViewScreenState extends State panelCollapsed = false; }); if (panelClosed) { - debugPrint('Screenshot Starting'); + logger.d('Screenshot Starting'); if (colorChanged) { screenshotController .capture( @@ -1487,9 +1487,9 @@ class _ShareWallpaperViewScreenState extends State screenshotTaken = true; panelClosed = false; }); - debugPrint('Screenshot Taken'); + logger.d('Screenshot Taken'); }).catchError((onError) { - debugPrint(onError.toString()); + logger.d(onError.toString()); }); } else { (main.prefs.get('optimisedWallpapers') ?? true) == @@ -1505,12 +1505,12 @@ class _ShareWallpaperViewScreenState extends State screenshotTaken = true; panelClosed = false; }); - debugPrint('Screenshot Taken'); + logger.d('Screenshot Taken'); }).catchError((onError) { - debugPrint(onError.toString()); + logger.d(onError.toString()); }) - : debugPrint( - "Wallpaper Optimisation is disabled!"); + : logger + .d("Wallpaper Optimisation is disabled!"); } } }, @@ -1567,11 +1567,11 @@ class _ShareWallpaperViewScreenState extends State ConnectionState.waiting || snapshot.connectionState == ConnectionState.none) { - debugPrint( + logger.d( "snapshot none, waiting in share route"); return Center(child: Loader()); } else { - debugPrint("done"); + logger.d("done"); return Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -1883,8 +1883,7 @@ class _ShareWallpaperViewScreenState extends State animation: offsetAnimation, builder: (buildContext, child) { if (offsetAnimation.value < 0.0) { - debugPrint( - '${offsetAnimation.value + 8.0}'); + logger.d('${offsetAnimation.value + 8.0}'); } return GestureDetector( onPanUpdate: (details) { @@ -1903,7 +1902,7 @@ class _ShareWallpaperViewScreenState extends State HapticFeedback.vibrate(); !isLoading ? updateAccent() - : debugPrint(""); + : logger.d(""); shakeController.forward(from: 0.0); }, child: CachedNetworkImage( @@ -1970,7 +1969,7 @@ class _ShareWallpaperViewScreenState extends State child: IconButton( onPressed: () { navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); Navigator.pop(context); }, color: isLoading diff --git a/lib/ui/pages/upload/editWallScreen.dart b/lib/ui/pages/upload/editWallScreen.dart index 363b5944..9e25e28a 100644 --- a/lib/ui/pages/upload/editWallScreen.dart +++ b/lib/ui/pages/upload/editWallScreen.dart @@ -7,6 +7,7 @@ import 'package:Prism/routes/router.dart'; import 'package:flutter/material.dart'; import 'package:extended_image/extended_image.dart'; import 'package:image_editor/image_editor.dart' hide ImageSource; +import 'package:Prism/logger/logger.dart'; class EditWallScreen extends StatefulWidget { final List? arguments; @@ -82,7 +83,7 @@ class _EditWallScreenState extends State { Future onWillPop() async { if (navStack.length > 1) navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); return true; } @@ -121,7 +122,7 @@ class _EditWallScreenState extends State { Icon(JamIcons.close, color: Theme.of(context).accentColor), onPressed: () { navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); Navigator.pop(context); }), actions: [ @@ -412,7 +413,7 @@ class _EditWallScreenState extends State { option.outputFormat = const OutputFormat.jpeg(100); - debugPrint(const JsonEncoder.withIndent(' ').convert(option.toJson())); + logger.d(const JsonEncoder.withIndent(' ').convert(option.toJson())); final DateTime start = DateTime.now(); final Uint8List result = await ImageEditor.editImage( @@ -420,13 +421,13 @@ class _EditWallScreenState extends State { imageEditorOption: option, ); - debugPrint('result.length = ${result.length}'); + logger.d('result.length = ${result.length}'); final Duration diff = DateTime.now().difference(start); image!.writeAsBytesSync(result); - debugPrint('image_editor time : $diff'); + logger.d('image_editor time : $diff'); if (navStack.length > 1) navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); Future.delayed(const Duration()).then((value) => Navigator.pushReplacementNamed(context, uploadWallRoute, arguments: [image, false])); diff --git a/lib/ui/pages/upload/setupGuidelines.dart b/lib/ui/pages/upload/setupGuidelines.dart index c6672d1a..0d5f8879 100644 --- a/lib/ui/pages/upload/setupGuidelines.dart +++ b/lib/ui/pages/upload/setupGuidelines.dart @@ -9,6 +9,7 @@ import 'package:image_picker/image_picker.dart'; import 'package:Prism/routes/router.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import 'package:Prism/logger/logger.dart'; class SetupGuidelinesScreen extends StatefulWidget { const SetupGuidelinesScreen(); @@ -24,7 +25,7 @@ class _SetupGuidelinesScreenState extends State { Future onWillPop() async { if (navStack.length > 1) navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); return true; } @@ -36,7 +37,7 @@ class _SetupGuidelinesScreenState extends State { }); Navigator.pop(context); if (navStack.length > 1) navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); Future.delayed(const Duration()).then((value) => Navigator.pushNamed(context, uploadSetupRoute, arguments: [_setup])); } diff --git a/lib/ui/pages/upload/uploadSetupScreen.dart b/lib/ui/pages/upload/uploadSetupScreen.dart index 97880bcf..f8bc77d9 100644 --- a/lib/ui/pages/upload/uploadSetupScreen.dart +++ b/lib/ui/pages/upload/uploadSetupScreen.dart @@ -16,6 +16,7 @@ import 'package:photo_view/photo_view.dart'; import 'package:Prism/data/upload/wallpaper/wallfirestore.dart' as WallStore; import 'package:Prism/theme/toasts.dart' as toasts; import 'package:Prism/global/globals.dart' as globals; +import 'package:Prism/logger/logger.dart'; class UploadSetupScreen extends StatefulWidget { final List? arguments; @@ -145,7 +146,7 @@ class _UploadSetupScreenState extends State { setState(() { id = tempid; }); - debugPrint(id); + logger.d(id); } Future processImage() async { @@ -171,22 +172,22 @@ class _UploadSetupScreenState extends State { .then((value) => setState(() { imageURL = value.content!.downloadUrl; })); - debugPrint('File Uploaded'); + logger.d('File Uploaded'); setState(() { isUploading = false; }); } catch (e) { - debugPrint(e.toString()); + logger.d(e.toString()); Navigator.pop(context); navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); toasts.error("Some uploading issue, please try again."); } } Future onWillPop() async { if (navStack.length > 1) navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); return true; } @@ -223,7 +224,7 @@ class _UploadSetupScreenState extends State { toasts.error("Please fill all required fields!"); } else { navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); Navigator.pop(context); analytics.logEvent( name: 'upload_setup', diff --git a/lib/ui/pages/upload/uploadWallScreen.dart b/lib/ui/pages/upload/uploadWallScreen.dart index 521dd989..7c834574 100644 --- a/lib/ui/pages/upload/uploadWallScreen.dart +++ b/lib/ui/pages/upload/uploadWallScreen.dart @@ -17,6 +17,7 @@ import 'package:Prism/data/upload/wallpaper/wallfirestore.dart' as WallStore; import 'package:Prism/theme/toasts.dart' as toasts; import 'package:flutter_image_compress/flutter_image_compress.dart'; import 'package:Prism/global/globals.dart' as globals; +import 'package:Prism/logger/logger.dart'; class UploadWallScreen extends StatefulWidget { final List? arguments; @@ -78,7 +79,7 @@ class _UploadWallScreenState extends State { setState(() { id = tempid; }); - debugPrint(id); + logger.d(id); } Future compressFile(File file) async { @@ -87,8 +88,8 @@ class _UploadWallScreenState extends State { minWidth: 400, quality: 85, ); - debugPrint(file.lengthSync().toString()); - debugPrint(result!.length.toString()); + logger.d(file.lengthSync().toString()); + logger.d(result!.length.toString()); return result; } @@ -96,8 +97,8 @@ class _UploadWallScreenState extends State { final imgList = image.readAsBytesSync(); final decodedImage = await decodeImageFromList(imgList); - debugPrint(decodedImage.width.toString()); - debugPrint(decodedImage.height.toString()); + logger.d(decodedImage.width.toString()); + logger.d(decodedImage.height.toString()); final res = "${decodedImage.width}x${decodedImage.height}"; @@ -120,7 +121,7 @@ class _UploadWallScreenState extends State { wallpaperPath, wallpaperPath, wallpaperSha, "master"); await github.repositories.deleteFile(RepositorySlug(gitUserName, repoName), thumbPath, thumbPath, thumbSha, "master"); - debugPrint("Files deleted"); + logger.d("Files deleted"); } Future uploadFile() async { @@ -156,22 +157,22 @@ class _UploadWallScreenState extends State { thumbPath = value.content!.path!; thumbSha = value.content!.sha!; })); - debugPrint('File Uploaded'); + logger.d('File Uploaded'); setState(() { isUploading = false; }); } catch (e) { - debugPrint(e.toString()); + logger.d(e.toString()); Navigator.pop(context); navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); toasts.error("Some uploading issue, please try again."); } } Future onWillPop() async { if (navStack.length > 1) navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); deleteFile(); return true; } @@ -302,7 +303,7 @@ class _UploadWallScreenState extends State { onPressed: !isProcessing && !isUploading ? () async { navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); Navigator.pop(context, [wallpaperUrl, id]); analytics.logEvent( name: 'upload_wallpaper', diff --git a/lib/ui/widgets/favourite/favLoader.dart b/lib/ui/widgets/favourite/favLoader.dart index 688a22a0..775176da 100644 --- a/lib/ui/widgets/favourite/favLoader.dart +++ b/lib/ui/widgets/favourite/favLoader.dart @@ -2,6 +2,7 @@ import 'package:Prism/ui/widgets/favourite/favGrid.dart'; import 'package:Prism/ui/widgets/home/wallpapers/loading.dart'; import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; +import 'package:Prism/logger/logger.dart'; class FavLoader extends StatefulWidget { final Future? future; @@ -24,12 +25,12 @@ class _FavLoaderState extends State { future: _future, builder: (ctx, snapshot) { if (snapshot == null) { - debugPrint("snapshot null"); + logger.d("snapshot null"); return const LoadingCards(); } if (snapshot.connectionState == ConnectionState.waiting || snapshot.connectionState == ConnectionState.none) { - debugPrint("snapshot none, waiting"); + logger.d("snapshot none, waiting"); return const LoadingCards(); } else { return const FavouriteGrid(); diff --git a/lib/ui/widgets/favourite/favSetupLoader.dart b/lib/ui/widgets/favourite/favSetupLoader.dart index 66e22cf6..9c02bea2 100644 --- a/lib/ui/widgets/favourite/favSetupLoader.dart +++ b/lib/ui/widgets/favourite/favSetupLoader.dart @@ -2,6 +2,7 @@ import 'package:Prism/ui/widgets/favourite/favSetupGrid.dart'; import 'package:Prism/ui/widgets/setups/loadingSetups.dart'; import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; +import 'package:Prism/logger/logger.dart'; class FavSetupLoader extends StatefulWidget { final Future? future; @@ -24,12 +25,12 @@ class _FavSetupLoaderState extends State { future: _future, builder: (ctx, snapshot) { if (snapshot == null) { - debugPrint("snapshot null"); + logger.d("snapshot null"); return const LoadingSetupCards(); } if (snapshot.connectionState == ConnectionState.waiting || snapshot.connectionState == ConnectionState.none) { - debugPrint("snapshot none, waiting"); + logger.d("snapshot none, waiting"); return const LoadingSetupCards(); } else { return const FavouriteSetupGrid(); diff --git a/lib/ui/widgets/focussedMenu/focusedMenuDetails.dart b/lib/ui/widgets/focussedMenu/focusedMenuDetails.dart index a8b32542..dd6fda9c 100644 --- a/lib/ui/widgets/focussedMenu/focusedMenuDetails.dart +++ b/lib/ui/widgets/focussedMenu/focusedMenuDetails.dart @@ -19,6 +19,7 @@ import 'package:flutter_svg/flutter_svg.dart'; import 'package:provider/provider.dart'; import 'package:url_launcher/url_launcher.dart'; import 'package:Prism/global/globals.dart' as globals; +import 'package:Prism/logger/logger.dart'; class FocusedMenuDetails extends StatefulWidget { final String? provider; @@ -125,7 +126,7 @@ class _FocusedMenuDetailsState extends State { @override Widget build(BuildContext context) { - debugPrint(widget.provider); + logger.d(widget.provider); try { return Scaffold( backgroundColor: Colors.transparent, @@ -2294,7 +2295,7 @@ class _FocusedMenuDetailsState extends State { ), ); } catch (e) { - debugPrint(e.toString()); + logger.d(e.toString()); Navigator.pop(context); return Container(); } diff --git a/lib/ui/widgets/focussedMenu/searchFocusedMenuDetails.dart b/lib/ui/widgets/focussedMenu/searchFocusedMenuDetails.dart index 486537fc..1c48f87e 100644 --- a/lib/ui/widgets/focussedMenu/searchFocusedMenuDetails.dart +++ b/lib/ui/widgets/focussedMenu/searchFocusedMenuDetails.dart @@ -10,6 +10,7 @@ import 'package:Prism/ui/widgets/menuButton/setWallpaperButton.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:url_launcher/url_launcher.dart'; +import 'package:Prism/logger/logger.dart'; class SearchFocusedMenuDetails extends StatelessWidget { final String? selectedProvider; @@ -485,7 +486,7 @@ class SearchFocusedMenuDetails extends StatelessWidget { ), ); } catch (e) { - debugPrint(e.toString()); + logger.d(e.toString()); Navigator.pop(context); return Container(); } diff --git a/lib/ui/widgets/home/collections/collectionsGrid.dart b/lib/ui/widgets/home/collections/collectionsGrid.dart index 6ce603f5..3ed867e5 100644 --- a/lib/ui/widgets/home/collections/collectionsGrid.dart +++ b/lib/ui/widgets/home/collections/collectionsGrid.dart @@ -13,6 +13,7 @@ import 'package:Prism/main.dart' as main; import 'package:Prism/global/globals.dart' as globals; import 'package:Prism/data/collections/provider/collectionsWithoutProvider.dart' as CData; +import 'package:Prism/logger/logger.dart'; class CollectionsGrid extends StatefulWidget { @override @@ -103,7 +104,7 @@ class _CollectionsGridState extends State } void showGooglePopUp(Function func) { - debugPrint(globals.prismUser.loggedIn.toString()); + logger.d(globals.prismUser.loggedIn.toString()); if (globals.prismUser.loggedIn == false) { googleSignInPopUp(context, func); } else { diff --git a/lib/ui/widgets/home/collections/collectionsViewGrid.dart b/lib/ui/widgets/home/collections/collectionsViewGrid.dart index 0aa382d7..009526ed 100644 --- a/lib/ui/widgets/home/collections/collectionsViewGrid.dart +++ b/lib/ui/widgets/home/collections/collectionsViewGrid.dart @@ -9,6 +9,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart'; import 'package:flutter/services.dart'; import 'package:provider/provider.dart'; +import 'package:Prism/logger/logger.dart'; class CollectionViewGrid extends StatefulWidget { const CollectionViewGrid(); @@ -136,7 +137,7 @@ class _CollectionViewGridState extends State animation: offsetAnimation, builder: (buildContext, child) { if (offsetAnimation.value < 0.0) { - debugPrint('${offsetAnimation.value + 8.0}'); + logger.d('${offsetAnimation.value + 8.0}'); } return Padding( padding: index == longTapIndex diff --git a/lib/ui/widgets/home/collections/loadingCardsCollection.dart b/lib/ui/widgets/home/collections/loadingCardsCollection.dart index 601538e5..13d208ca 100644 --- a/lib/ui/widgets/home/collections/loadingCardsCollection.dart +++ b/lib/ui/widgets/home/collections/loadingCardsCollection.dart @@ -3,6 +3,7 @@ import 'package:Prism/ui/widgets/home/core/inheritedScrollControllerProvider.dar import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart'; import 'package:provider/provider.dart'; +import 'package:Prism/logger/logger.dart'; class LoadingCardsCollection extends StatefulWidget { const LoadingCardsCollection({ @@ -83,7 +84,7 @@ class _LoadingCardsCollectionState extends State try { controller = InheritedDataProvider.of(context)!.scrollController; } catch (e) { - debugPrint(e.toString()); + logger.d(e.toString()); } return controller != null diff --git a/lib/ui/widgets/home/core/bottomNavBar.dart b/lib/ui/widgets/home/core/bottomNavBar.dart index 261b5ce4..41b7f745 100644 --- a/lib/ui/widgets/home/core/bottomNavBar.dart +++ b/lib/ui/widgets/home/core/bottomNavBar.dart @@ -14,6 +14,7 @@ import 'package:Prism/global/globals.dart' as globals; import 'package:Prism/main.dart' as main; import 'package:intl/intl.dart'; import 'package:Prism/theme/toasts.dart' as toasts; +import 'package:Prism/logger/logger.dart'; class BottomBar extends StatefulWidget { final Widget? child; @@ -197,7 +198,7 @@ class _BottomNavBarState extends State } void showGooglePopUp(Function func) { - debugPrint(isLoggedin.toString()); + logger.d(isLoggedin.toString()); if (isLoggedin == false) { googleSignInPopUp(context, func); } else { @@ -258,14 +259,14 @@ class _BottomNavBarState extends State ), onPressed: () { navStack.last == "Home" - ? debugPrint("Currently on Home") + ? logger.d("Currently on Home") : Navigator.of(context).popUntil((route) { if (navStack.last != "Home") { navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); return false; } else { - debugPrint(navStack.toString()); + logger.d(navStack.toString()); return true; } }); @@ -306,7 +307,7 @@ class _BottomNavBarState extends State ), onPressed: () { navStack.last == "Search" - ? debugPrint("Currently on Search") + ? logger.d("Currently on Search") : navStack.last == "Home" ? Navigator.of(context).pushNamed(searchRoute) : Navigator.of(context).pushNamed(searchRoute); @@ -418,7 +419,7 @@ class _BottomNavBarState extends State ), onPressed: () { navStack.last == "Setups" - ? debugPrint("Currently on Setups") + ? logger.d("Currently on Setups") : navStack.last == "Home" ? Navigator.of(context).pushNamed(setupRoute) : Navigator.of(context).pushNamed(setupRoute); @@ -487,24 +488,26 @@ class _BottomNavBarState extends State ), onPressed: () { if (navStack.last == "Profile") { - debugPrint("Currently on Profile"); + logger.d("Currently on Profile"); } else { if (navStack.last == "Home") { - Navigator.of(context).pushNamed(profileRoute); + Navigator.of(context).pushNamed(profileRoute, + arguments: [globals.prismUser.email]); } else { Navigator.of(context).popUntil((route) { if (navStack.last != "Home" && navStack.last != "Profile") { navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); return false; } else { - debugPrint(navStack.toString()); + logger.d(navStack.toString()); return true; } }); if ((navStack.last == "Home") == true) { - Navigator.of(context).pushNamed(profileRoute); + Navigator.of(context).pushNamed(profileRoute, + arguments: [globals.prismUser.email]); } } } @@ -827,7 +830,7 @@ class _AdBannerWidgetState extends State { ); if (size == null) { - debugPrint('Unable to get height of anchored banner.'); + logger.d('Unable to get height of anchored banner.'); return; } else { if (mounted) { @@ -835,7 +838,7 @@ class _AdBannerWidgetState extends State { adHeight = size.height; }); } - debugPrint('ad height is equal to $adHeight'); + logger.d('ad height is equal to $adHeight'); } final BannerAd banner = BannerAd( @@ -846,20 +849,20 @@ class _AdBannerWidgetState extends State { : BannerAd.testAdUnitId, listener: BannerAdListener( onAdLoaded: (Ad ad) { - debugPrint('$BannerAd loaded.'); + logger.d('$BannerAd loaded.'); setState(() { _anchoredBanner = ad as BannerAd?; }); }, onAdFailedToLoad: (Ad ad, LoadAdError error) { - debugPrint('$BannerAd failedToLoad: $error'); + logger.d('$BannerAd failedToLoad: $error'); setState(() { adHeight = 0; }); ad.dispose(); }, - onAdOpened: (Ad ad) => debugPrint('$BannerAd onAdOpened.'), - onAdClosed: (Ad ad) => debugPrint('$BannerAd onAdClosed.'), + onAdOpened: (Ad ad) => logger.d('$BannerAd onAdOpened.'), + onAdClosed: (Ad ad) => logger.d('$BannerAd onAdClosed.'), ), ); return banner.load(); diff --git a/lib/ui/widgets/home/core/categoriesBar.dart b/lib/ui/widgets/home/core/categoriesBar.dart index cba85114..f5155620 100644 --- a/lib/ui/widgets/home/core/categoriesBar.dart +++ b/lib/ui/widgets/home/core/categoriesBar.dart @@ -12,6 +12,7 @@ import 'package:Prism/routes/routing_constants.dart'; import 'package:Prism/analytics/analytics_service.dart'; import 'package:Prism/global/globals.dart' as globals; import 'package:Prism/main.dart' as main; +import 'package:Prism/logger/logger.dart'; class CategoriesBar extends StatefulWidget { const CategoriesBar({ @@ -72,7 +73,7 @@ class _CategoriesBarState extends State { } void _showError(dynamic exception) { - debugPrint(exception.toString()); + logger.d(exception.toString()); } @override @@ -91,7 +92,7 @@ class _CategoriesBarState extends State { }); } } catch (e) { - debugPrint(e.toString()); + logger.d(e.toString()); } }); } diff --git a/lib/ui/widgets/home/core/headingChipBar.dart b/lib/ui/widgets/home/core/headingChipBar.dart index 149ec9fc..6f96fa0c 100644 --- a/lib/ui/widgets/home/core/headingChipBar.dart +++ b/lib/ui/widgets/home/core/headingChipBar.dart @@ -1,6 +1,7 @@ import 'package:Prism/routes/router.dart'; import 'package:Prism/theme/jam_icons_icons.dart'; import 'package:flutter/material.dart'; +import 'package:Prism/logger/logger.dart'; class HeadingChipBar extends StatefulWidget { final String current; @@ -28,7 +29,7 @@ class _HeadingChipBarState extends State { (navStack.last == "SharedWallpaper") || (navStack.last == "SetupView")) {} } - debugPrint(navStack.toString()); + logger.d(navStack.toString()); }), title: Text( widget.current, diff --git a/lib/ui/widgets/home/wallpapers/colorGrid.dart b/lib/ui/widgets/home/wallpapers/colorGrid.dart index 06ea3760..fe8e57c5 100644 --- a/lib/ui/widgets/home/wallpapers/colorGrid.dart +++ b/lib/ui/widgets/home/wallpapers/colorGrid.dart @@ -10,6 +10,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart'; import 'package:flutter/services.dart'; import 'package:provider/provider.dart'; +import 'package:Prism/logger/logger.dart'; class ColorGrid extends StatefulWidget { final String provider; @@ -168,7 +169,7 @@ class _ColorGridState extends State with TickerProviderStateMixin { animation: offsetAnimation, builder: (buildContext, child) { if (offsetAnimation.value < 0.0) { - debugPrint('${offsetAnimation.value + 8.0}'); + logger.d('${offsetAnimation.value + 8.0}'); } return Padding( padding: index == longTapIndex diff --git a/lib/ui/widgets/home/wallpapers/colorLoader.dart b/lib/ui/widgets/home/wallpapers/colorLoader.dart index 7ca24f3f..f5723851 100644 --- a/lib/ui/widgets/home/wallpapers/colorLoader.dart +++ b/lib/ui/widgets/home/wallpapers/colorLoader.dart @@ -2,6 +2,7 @@ import 'package:Prism/data/pexels/provider/pexelsWithoutProvider.dart' as PData; import 'package:Prism/ui/widgets/home/wallpapers/colorGrid.dart'; import 'package:Prism/ui/widgets/home/wallpapers/loading.dart'; import 'package:flutter/material.dart'; +import 'package:Prism/logger/logger.dart'; class ColorLoader extends StatefulWidget { final Future future; @@ -27,12 +28,12 @@ class _ColorLoaderState extends State { future: _future, builder: (ctx, snapshot) { if (snapshot == null) { - debugPrint("snapshot null"); + logger.d("snapshot null"); return const LoadingCards(); } if (snapshot.connectionState == ConnectionState.waiting || snapshot.connectionState == ConnectionState.none) { - debugPrint("snapshot none, waiting"); + logger.d("snapshot none, waiting"); return const LoadingCards(); } else { return ColorGrid( diff --git a/lib/ui/widgets/home/wallpapers/loading.dart b/lib/ui/widgets/home/wallpapers/loading.dart index 894f51d1..84a02344 100644 --- a/lib/ui/widgets/home/wallpapers/loading.dart +++ b/lib/ui/widgets/home/wallpapers/loading.dart @@ -3,6 +3,7 @@ import 'package:Prism/ui/widgets/home/core/inheritedScrollControllerProvider.dar import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart'; import 'package:provider/provider.dart'; +import 'package:Prism/logger/logger.dart'; class LoadingCards extends StatefulWidget { const LoadingCards({ @@ -85,7 +86,7 @@ class _LoadingCardsState extends State controller = InheritedDataProvider.of(context)!.scrollController; } } catch (e) { - debugPrint(e.toString()); + logger.d(e.toString()); } return controller != null diff --git a/lib/ui/widgets/home/wallpapers/wallpaperGrid.dart b/lib/ui/widgets/home/wallpapers/wallpaperGrid.dart index f0beba6d..88c82462 100644 --- a/lib/ui/widgets/home/wallpapers/wallpaperGrid.dart +++ b/lib/ui/widgets/home/wallpapers/wallpaperGrid.dart @@ -15,6 +15,7 @@ import 'package:provider/provider.dart'; import 'package:Prism/data/prism/provider/prismWithoutProvider.dart' as Data; import 'package:Prism/global/globals.dart' as globals; import 'package:url_launcher/url_launcher.dart'; +import 'package:Prism/logger/logger.dart'; class WallpaperGrid extends StatefulWidget { final String? provider; @@ -41,7 +42,7 @@ class _WallpaperGridState extends State { } void showGooglePopUp(BuildContext context, Function func) { - debugPrint(globals.prismUser.loggedIn.toString()); + logger.d(globals.prismUser.loggedIn.toString()); if (globals.prismUser.loggedIn == false) { googleSignInPopUp(context, func); } else { diff --git a/lib/ui/widgets/home/wallpapers/wallpaperLoader.dart b/lib/ui/widgets/home/wallpapers/wallpaperLoader.dart index c0af85e8..8e54261f 100644 --- a/lib/ui/widgets/home/wallpapers/wallpaperLoader.dart +++ b/lib/ui/widgets/home/wallpapers/wallpaperLoader.dart @@ -1,6 +1,7 @@ import 'package:Prism/ui/widgets/home/wallpapers/loading.dart'; import 'package:Prism/ui/widgets/home/wallpapers/wallpaperGrid.dart'; import 'package:flutter/material.dart'; +import 'package:Prism/logger/logger.dart'; class WallpaperLoader extends StatefulWidget { final Future future; @@ -25,12 +26,12 @@ class _WallpaperLoaderState extends State { future: _future, builder: (ctx, snapshot) { if (snapshot == null) { - debugPrint("snapshot null"); + logger.d("snapshot null"); return const LoadingCards(); } if (snapshot.connectionState == ConnectionState.waiting || snapshot.connectionState == ConnectionState.none) { - debugPrint("snapshot none, waiting"); + logger.d("snapshot none, waiting"); return const LoadingCards(); } else { return WallpaperGrid( diff --git a/lib/ui/widgets/home/wallpapers/wallpaperTile.dart b/lib/ui/widgets/home/wallpapers/wallpaperTile.dart index 084cc0eb..0ab65382 100644 --- a/lib/ui/widgets/home/wallpapers/wallpaperTile.dart +++ b/lib/ui/widgets/home/wallpapers/wallpaperTile.dart @@ -7,6 +7,7 @@ import 'package:flutter/material.dart'; import 'package:Prism/data/prism/provider/prismWithoutProvider.dart' as Data; import 'package:provider/provider.dart'; import 'package:Prism/global/globals.dart' as globals; +import 'package:Prism/logger/logger.dart'; class WallpaperTile extends StatelessWidget { const WallpaperTile({ @@ -19,7 +20,7 @@ class WallpaperTile extends StatelessWidget { final int index; void showGooglePopUp(BuildContext context, Function func) { - debugPrint(globals.prismUser.loggedIn.toString()); + logger.d(globals.prismUser.loggedIn.toString()); if (globals.prismUser.loggedIn == false) { googleSignInPopUp(context, func); } else { diff --git a/lib/ui/widgets/menuButton/downloadButton.dart b/lib/ui/widgets/menuButton/downloadButton.dart index 1746bf70..d59090c1 100644 --- a/lib/ui/widgets/menuButton/downloadButton.dart +++ b/lib/ui/widgets/menuButton/downloadButton.dart @@ -14,6 +14,7 @@ import 'package:google_mobile_ads/google_mobile_ads.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:Prism/global/globals.dart' as globals; import 'package:flutter/foundation.dart'; +import 'package:Prism/logger/logger.dart'; const int maxFailedLoadAttempts = 3; @@ -52,13 +53,13 @@ class _DownloadButtonState extends State { onDownload(); } else { showDownloadPopup(context, () { - debugPrint("Download"); + logger.d("Download"); onDownload(); }); } } else { showDownloadPopup(context, () { - debugPrint("Download"); + logger.d("Download"); onDownload(); }); } @@ -115,11 +116,11 @@ class _DownloadButtonState extends State { setState(() { isLoading = true; }); - debugPrint(widget.link); + logger.d(widget.link); final androidInfo = await DeviceInfoPlugin().androidInfo; final sdkInt = androidInfo.version.sdkInt; - debugPrint('(SDK $sdkInt)'); + logger.d('(SDK $sdkInt)'); // toasts.codeSend("Starting Download"); // main.localNotification.createDownloadNotification(); // if (sdkInt >= 30) { @@ -138,7 +139,7 @@ class _DownloadButtonState extends State { // }); // main.localNotification.cancelDownloadNotification(); // }).catchError((e) { - // debugPrint(e.toString()); + // logger.d(e.toString()); // setState(() { // isLoading = false; // }); @@ -158,7 +159,7 @@ class _DownloadButtonState extends State { // }); // main.localNotification.cancelDownloadNotification(); // }).catchError((e) { - // debugPrint(e.toString()); + // logger.d(e.toString()); // setState(() { // isLoading = false; // }); @@ -201,7 +202,7 @@ class _DownloadButtonState extends State { // } // main.localNotification.cancelDownloadNotification(); // }).catchError((e) { - // debugPrint(e.toString()); + // logger.d(e.toString()); // setState(() { // isLoading = false; // }); @@ -245,7 +246,7 @@ class _DownloadDialogContentState extends State { void rewardFn(num rewardAmount) { downloadCoins += rewardAmount; - debugPrint("Coins : ${downloadCoins.toString()}"); + logger.d("Coins : ${downloadCoins.toString()}"); } @override @@ -267,7 +268,7 @@ class _DownloadDialogContentState extends State { request: request, rewardedAdLoadCallback: RewardedAdLoadCallback( onAdLoaded: (RewardedAd ad) { - debugPrint('$ad loaded.'); + logger.d('$ad loaded.'); globals.adHelper.rewardedAd = ad; _numRewardedLoadAttempts = 0; setState(() { @@ -276,7 +277,7 @@ class _DownloadDialogContentState extends State { }); }, onAdFailedToLoad: (LoadAdError error) { - debugPrint('RewardedAd failed to load: $error'); + logger.d('RewardedAd failed to load: $error'); setState(() { globals.adHelper.loadingAd = false; }); @@ -301,20 +302,20 @@ class _DownloadDialogContentState extends State { globals.adHelper.adLoaded = false; }); if (globals.adHelper.rewardedAd == null) { - debugPrint('Warning: attempt to show rewarded before loaded.'); + logger.d('Warning: attempt to show rewarded before loaded.'); return; } globals.adHelper.rewardedAd!.fullScreenContentCallback = FullScreenContentCallback( onAdShowedFullScreenContent: (RewardedAd ad) => - debugPrint('ad onAdShowedFullScreenContent.'), + logger.d('ad onAdShowedFullScreenContent.'), onAdDismissedFullScreenContent: (RewardedAd ad) { - debugPrint('$ad onAdDismissedFullScreenContent.'); + logger.d('$ad onAdDismissedFullScreenContent.'); ad.dispose(); _createRewardedAd(); }, onAdFailedToShowFullScreenContent: (RewardedAd ad, AdError error) { - debugPrint('$ad onAdFailedToShowFullScreenContent: $error'); + logger.d('$ad onAdFailedToShowFullScreenContent: $error'); ad.dispose(); _createRewardedAd(); }, @@ -322,8 +323,7 @@ class _DownloadDialogContentState extends State { globals.adHelper.rewardedAd!.show( onUserEarnedReward: (RewardedAd ad, RewardItem reward) { - debugPrint( - '$ad with reward $RewardItem(${reward.amount}, ${reward.type}'); + logger.d('$ad with reward $RewardItem(${reward.amount}, ${reward.type}'); rewardFn(reward.amount); if (downloadCoins >= 10) widget.rewardFunc(); }); diff --git a/lib/ui/widgets/menuButton/favWallpaperButton.dart b/lib/ui/widgets/menuButton/favWallpaperButton.dart index f100c330..e1670a9e 100644 --- a/lib/ui/widgets/menuButton/favWallpaperButton.dart +++ b/lib/ui/widgets/menuButton/favWallpaperButton.dart @@ -9,6 +9,7 @@ import 'package:hive/hive.dart'; import 'package:provider/provider.dart'; import 'package:Prism/routes/router.dart'; import 'package:Prism/global/globals.dart' as globals; +import 'package:Prism/logger/logger.dart'; class FavouriteWallpaperButton extends StatefulWidget { final String id; @@ -72,7 +73,7 @@ class _FavouriteWallpaperButtonState extends State { } if (widget.trash) { navStack.removeLast(); - debugPrint(navStack.toString()); + logger.d(navStack.toString()); Navigator.pop(context); } }, diff --git a/lib/ui/widgets/menuButton/setWallpaperButton.dart b/lib/ui/widgets/menuButton/setWallpaperButton.dart index ef61c477..41037673 100644 --- a/lib/ui/widgets/menuButton/setWallpaperButton.dart +++ b/lib/ui/widgets/menuButton/setWallpaperButton.dart @@ -5,6 +5,7 @@ import 'package:device_info/device_info.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:Prism/theme/toasts.dart' as toasts; +import 'package:Prism/logger/logger.dart'; class SetWallpaperButton extends StatefulWidget { final String? url; @@ -42,12 +43,12 @@ class _SetWallpaperButtonState extends State { }); } if (result!) { - debugPrint("Success"); + logger.d("Success"); analytics.logEvent( name: 'set_wall', parameters: {'type': 'Both', 'result': 'Success'}); } else { - debugPrint("Failed"); + logger.d("Failed"); toasts.error("Something went wrong!"); } if (mounted) { @@ -58,7 +59,7 @@ class _SetWallpaperButtonState extends State { } catch (e) { analytics.logEvent( name: 'set_wall', parameters: {'type': 'Both', 'result': 'Failure'}); - debugPrint(e.toString()); + logger.d(e.toString()); } } @@ -82,13 +83,13 @@ class _SetWallpaperButtonState extends State { }); } if (result!) { - debugPrint("Success"); + logger.d("Success"); analytics.logEvent( name: 'set_wall', parameters: {'type': 'Both', 'result': 'Success'}); toasts.codeSend("Wallpaper set successfully!"); } else { - debugPrint("Failed"); + logger.d("Failed"); toasts.error("Something went wrong!"); } if (mounted) { @@ -99,7 +100,7 @@ class _SetWallpaperButtonState extends State { } catch (e) { analytics.logEvent( name: 'set_wall', parameters: {'type': 'Both', 'result': 'Failure'}); - debugPrint(e.toString()); + logger.d(e.toString()); } } @@ -123,13 +124,13 @@ class _SetWallpaperButtonState extends State { }); } if (result!) { - debugPrint("Success"); + logger.d("Success"); analytics.logEvent( name: 'set_wall', parameters: {'type': 'Lock', 'result': 'Success'}); toasts.codeSend("Wallpaper set successfully!"); } else { - debugPrint("Failed"); + logger.d("Failed"); toasts.error("Something went wrong!"); } if (mounted) { @@ -138,7 +139,7 @@ class _SetWallpaperButtonState extends State { }); } } catch (e) { - debugPrint(e.toString()); + logger.d(e.toString()); analytics.logEvent( name: 'set_wall', parameters: {'type': 'Lock', 'result': 'Failure'}); } @@ -164,13 +165,13 @@ class _SetWallpaperButtonState extends State { }); } if (result!) { - debugPrint("Success"); + logger.d("Success"); analytics.logEvent( name: 'set_wall', parameters: {'type': 'Home', 'result': 'Success'}); toasts.codeSend("Wallpaper set successfully!"); } else { - debugPrint("Failed"); + logger.d("Failed"); toasts.error("Something went wrong!"); } if (mounted) { @@ -179,7 +180,7 @@ class _SetWallpaperButtonState extends State { }); } } catch (e) { - debugPrint(e.toString()); + logger.d(e.toString()); analytics.logEvent( name: 'set_wall', parameters: {'type': 'Home', 'result': 'Failure'}); } @@ -209,9 +210,9 @@ class _SetWallpaperButtonState extends State { if (Platform.isAndroid) { final androidInfo = await DeviceInfoPlugin().androidInfo; final sdkInt = androidInfo.version.sdkInt; - debugPrint('(SDK $sdkInt)'); + logger.d('(SDK $sdkInt)'); isLoading - ? debugPrint("") + ? logger.d("") : sdkInt >= 24 ? onPaint() : toasts @@ -222,7 +223,7 @@ class _SetWallpaperButtonState extends State { }, onTap: () { isLoading - ? debugPrint("") + ? logger.d("") : showModalBottomSheet( isScrollControlled: true, context: context, diff --git a/lib/ui/widgets/menuButton/shareButton.dart b/lib/ui/widgets/menuButton/shareButton.dart index b920e56d..536cc803 100644 --- a/lib/ui/widgets/menuButton/shareButton.dart +++ b/lib/ui/widgets/menuButton/shareButton.dart @@ -4,6 +4,7 @@ import 'package:firebase_dynamic_links/firebase_dynamic_links.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:share/share.dart'; +import 'package:Prism/logger/logger.dart'; class ShareButton extends StatefulWidget { final String? id; @@ -34,7 +35,7 @@ class _ShareButtonState extends State { Widget build(BuildContext context) { return GestureDetector( onTap: () { - debugPrint("Share"); + logger.d("Share"); onShare(); }, child: Stack( @@ -97,7 +98,7 @@ class _ShareButtonState extends State { final Uri shortUrl = shortDynamicLink.shortUrl; Clipboard.setData(ClipboardData(text: shortUrl.toString())); Share.share("🔥Check this out ➜ $shortUrl"); - debugPrint(shortUrl.toString()); + logger.d(shortUrl.toString()); analytics.logShare( contentType: 'wallpaperScreen', itemId: widget.id!, method: 'link'); setState(() { diff --git a/lib/ui/widgets/popup/categoryPopUp.dart b/lib/ui/widgets/popup/categoryPopUp.dart index 24389f93..6bf12a50 100644 --- a/lib/ui/widgets/popup/categoryPopUp.dart +++ b/lib/ui/widgets/popup/categoryPopUp.dart @@ -6,6 +6,7 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:Prism/ui/pages/home/core/pageManager.dart' as PM; +import 'package:Prism/logger/logger.dart'; void showCategories(BuildContext context, CategoryMenu initialValue) { final controller = ScrollController(); @@ -69,8 +70,7 @@ void showCategories(BuildContext context, CategoryMenu initialValue) { .changeSelectedChoice(choice as CategoryMenu); Provider.of(context, listen: false) - .changeWallpaperFuture( - choice, "r"); + .changeWallpaperFuture(choice, "r"); PM.tabController!.animateTo(0, duration: const Duration(milliseconds: 200), curve: Curves.easeInCubic); @@ -127,7 +127,7 @@ void showCategories(BuildContext context, CategoryMenu initialValue) { color: Theme.of(context).errorColor, onPressed: () { Navigator.of(context).pop(); - debugPrint('You have not chossed anything'); + logger.d('You have not chossed anything'); }, child: const Text( 'OK', diff --git a/lib/ui/widgets/popup/changelogPopUp.dart b/lib/ui/widgets/popup/changelogPopUp.dart index ac0552c9..bd83d87a 100644 --- a/lib/ui/widgets/popup/changelogPopUp.dart +++ b/lib/ui/widgets/popup/changelogPopUp.dart @@ -46,6 +46,20 @@ void showChangelog(BuildContext context, Function func) { child: Column( mainAxisSize: MainAxisSize.min, children: const [ + ChangeVersion(number: 'v2.6.8'), + Change( + icon: JamIcons.user, + text: "All-new beautiful profile."), + Change( + icon: JamIcons.link, + text: "Add upto 25 links in your profile."), + Change( + icon: JamIcons.filter, + text: "Added 23 new filters like Rise, Ashby, etc."), + Change( + icon: JamIcons.bug, + text: + "Fixed first time app open stuck on splash screen bug."), ChangeVersion(number: 'v2.6.7'), Change( icon: JamIcons.user, diff --git a/lib/ui/widgets/popup/colorsPopUp.dart b/lib/ui/widgets/popup/colorsPopUp.dart index 161c3159..a9cbe401 100644 --- a/lib/ui/widgets/popup/colorsPopUp.dart +++ b/lib/ui/widgets/popup/colorsPopUp.dart @@ -4,6 +4,7 @@ import 'package:animations/animations.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flare_flutter/flare_actor.dart'; import 'package:flutter/material.dart'; +import 'package:Prism/logger/logger.dart'; final databaseReference = FirebaseFirestore.instance; List colors = [ @@ -105,7 +106,7 @@ Color showColors(BuildContext context) { GestureDetector( onTap: () { currentColor = color; - debugPrint(navStack.toString()); + logger.d(navStack.toString()); Navigator.pop(context); Navigator.pushNamed( context, diff --git a/lib/ui/widgets/popup/contriPopUp.dart b/lib/ui/widgets/popup/contriPopUp.dart index bc5eda71..9b91c0da 100644 --- a/lib/ui/widgets/popup/contriPopUp.dart +++ b/lib/ui/widgets/popup/contriPopUp.dart @@ -5,6 +5,7 @@ import 'package:animations/animations.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:github/github.dart'; +import 'package:Prism/logger/logger.dart'; void showContributorDetails(BuildContext context, String username) { Future getUser(String username) async { @@ -13,7 +14,7 @@ void showContributorDetails(BuildContext context, String username) { await github.users.getUser(username).then((value) { user = value; }); - debugPrint(user!.blog); + logger.d(user!.blog); return user; } @@ -28,12 +29,12 @@ void showContributorDetails(BuildContext context, String username) { future: getUser(username), builder: (context, snapshot) { if (snapshot == null) { - debugPrint("snapshot null"); + logger.d("snapshot null"); return SizedBox(height: 300, child: Center(child: Loader())); } if (snapshot.connectionState == ConnectionState.waiting || snapshot.connectionState == ConnectionState.none) { - debugPrint("snapshot none, waiting"); + logger.d("snapshot none, waiting"); return SizedBox(height: 300, child: Center(child: Loader())); } else { return Column( diff --git a/lib/ui/widgets/popup/editProfilePanel.dart b/lib/ui/widgets/popup/editProfilePanel.dart index 277f940f..e1137448 100644 --- a/lib/ui/widgets/popup/editProfilePanel.dart +++ b/lib/ui/widgets/popup/editProfilePanel.dart @@ -4,6 +4,9 @@ import 'dart:typed_data'; import 'package:Prism/auth/google_auth.dart'; import 'package:Prism/gitkey.dart'; +import 'package:Prism/global/svgAssets.dart'; +import 'package:Prism/logger/logger.dart'; +import 'package:Prism/routes/router.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:Prism/global/globals.dart' as globals; @@ -12,6 +15,7 @@ import 'package:flutter/material.dart'; import 'package:Prism/theme/jam_icons_icons.dart'; import 'package:Prism/main.dart' as main; import 'package:flutter_image_compress/flutter_image_compress.dart'; +import 'package:flutter_svg/flutter_svg.dart'; import 'package:github/github.dart'; import 'package:image_picker/image_picker.dart'; import 'package:path/path.dart' as Path; @@ -26,24 +30,218 @@ class EditProfilePanel extends StatefulWidget { } class _EditProfilePanelState extends State { - final TextEditingController bioController = TextEditingController(); - final TextEditingController usernameController = TextEditingController(); + final TextEditingController linkController = TextEditingController(); + late TextEditingController bioController; + late TextEditingController usernameController; + late TextEditingController nameController; final FirebaseFirestore firestore = FirebaseFirestore.instance; bool isLoading = false; bool pfpEdit = false; + bool coverEdit = false; bool usernameEdit = false; + bool nameEdit = false; bool bioEdit = false; + bool linkEdit = false; bool enabled = false; bool? available; bool isCheckingUsername = false; File? _pfp; + File? _cover; late List _compressedPFP; + late List _compressedCover; late String pfpSha; late String pfpPath; late String pfpUrl; + late String coverSha; + late String coverPath; + late String coverUrl; final picker2 = ImagePicker(); + List> linkIcons = [ + // { + // 'name': 'Edit links...', + // 'link': 'Select your link first', + // 'icon': JamIcons.link, + // 'value': '', + // 'validator': '', + // }, + { + 'name': 'github', + 'link': 'https://github.com/username', + 'icon': JamIcons.github, + 'value': '', + 'validator': 'github', + }, + { + 'name': 'twitter', + 'link': 'https://twitter.com/username', + 'icon': JamIcons.twitter, + 'value': '', + 'validator': 'twitter', + }, + { + 'name': 'instagram', + 'link': 'https://instagram.com/username', + 'icon': JamIcons.instagram, + 'value': '', + 'validator': 'instagram', + }, + { + 'name': 'email', + 'link': 'your@email.com', + 'icon': JamIcons.inbox, + 'value': '', + 'validator': '@', + }, + { + 'name': 'telegram', + 'link': 'https://t.me/username', + 'icon': JamIcons.paper_plane, + 'value': '', + 'validator': 't.me', + }, + { + 'name': 'dribbble', + 'link': 'https://dribbble.com/username', + 'icon': JamIcons.basketball, + 'value': '', + 'validator': 'dribbble', + }, + { + 'name': 'linkedin', + 'link': 'https://linkedin.com/in/username', + 'icon': JamIcons.linkedin, + 'value': '', + 'validator': 'linkedin', + }, + { + 'name': 'bio.link', + 'link': 'https://bio.link/username', + 'icon': JamIcons.world, + 'value': '', + 'validator': 'bio.link', + }, + { + 'name': 'patreon', + 'link': 'https://patreon.com/username', + 'icon': JamIcons.patreon, + 'value': '', + 'validator': 'patreon', + }, + { + 'name': 'trello', + 'link': 'https://trello.com/username', + 'icon': JamIcons.trello, + 'value': '', + 'validator': 'trello', + }, + { + 'name': 'reddit', + 'link': 'https://reddit.com/user/username', + 'icon': JamIcons.reddit, + 'value': '', + 'validator': 'reddit', + }, + { + 'name': 'behance', + 'link': 'https://behance.net/username', + 'icon': JamIcons.behance, + 'value': '', + 'validator': 'behance.net', + }, + { + 'name': 'deviantart', + 'link': 'https://deviantart.com/username', + 'icon': JamIcons.deviantart, + 'value': '', + 'validator': 'deviantart', + }, + { + 'name': 'gitlab', + 'link': 'https://gitlab.com/username', + 'icon': JamIcons.gitlab, + 'value': '', + 'validator': 'gitlab', + }, + { + 'name': 'medium', + 'link': 'https://username.medium.com/', + 'icon': JamIcons.medium, + 'value': '', + 'validator': 'medium', + }, + { + 'name': 'paypal', + 'link': 'https://paypal.me/username', + 'icon': JamIcons.paypal, + 'value': '', + 'validator': 'paypal', + }, + { + 'name': 'spotify', + 'link': 'https://open.spotify.com/user/username', + 'icon': JamIcons.spotify, + 'value': '', + 'validator': 'open.spotify', + }, + { + 'name': 'twitch', + 'link': 'https://twitch.tv/username', + 'icon': JamIcons.twitch, + 'value': '', + 'validator': 'twitch.tv', + }, + { + 'name': 'unsplash', + 'link': 'https://unsplash.com/username', + 'icon': JamIcons.unsplash, + 'value': '', + 'validator': 'unsplash', + }, + { + 'name': 'youtube', + 'link': 'https://youtube.com/channel/username', + 'icon': JamIcons.youtube, + 'value': '', + 'validator': 'youtube', + }, + { + 'name': 'linktree', + 'link': 'https://linktr.ee/username', + 'icon': JamIcons.tree_alt, + 'value': '', + 'validator': 'linktr.ee', + }, + { + 'name': 'buymeacoffee', + 'link': 'https://buymeacoff.ee/username', + 'icon': JamIcons.coffee, + 'value': '', + 'validator': 'buymeacoff.ee', + }, + { + 'name': 'custom link', + 'link': '', + 'icon': JamIcons.link, + 'value': '', + 'validator': '', + }, + ]; + Map? _link; @override void initState() { + linkIcons + .sort((a, b) => a['name'].toString().compareTo(b['name'].toString())); + final links = globals.prismUser.links; + linkIcons.forEach((element) { + if (links[element['name']] != "" && links[element['name']] != null) { + element['value'] = links[element['name']]; + } + }); + _link = linkIcons[3]; + bioController = TextEditingController(text: globals.prismUser.bio); + usernameController = + TextEditingController(text: globals.prismUser.username); + nameController = TextEditingController(text: globals.prismUser.name); super.initState(); } @@ -57,21 +255,37 @@ class _EditProfilePanelState extends State { } } + Future getCover() async { + final pickedFile = await picker2.getImage(source: ImageSource.gallery); + if (pickedFile != null) { + setState(() { + _cover = File(pickedFile.path); + coverEdit = true; + }); + } + } + Future compressFile(File file) async { final result = await FlutterImageCompress.compressWithFile( file.absolute.path, minWidth: 400, quality: 85, ); - debugPrint(file.lengthSync().toString()); - debugPrint(result!.length.toString()); + logger.d(file.lengthSync().toString()); + logger.d(result!.length.toString()); return result; } Future processImage() async { final imgList = _pfp!.readAsBytesSync(); _compressedPFP = await compressFile(_pfp!); - uploadFile(); + await uploadFile(); + } + + Future processImageCover() async { + final imgList = _cover!.readAsBytesSync(); + _compressedCover = await compressFile(_cover!); + await uploadFileCover(); } Future uploadFile() async { @@ -90,7 +304,7 @@ class _EditProfilePanelState extends State { pfpPath = value.content!.path!; pfpSha = value.content!.sha!; })); - debugPrint('File Uploaded'); + logger.d('File Uploaded'); globals.prismUser.profilePhoto = pfpUrl; main.prefs.put("prismUserV2", globals.prismUser); await firestore @@ -100,426 +314,852 @@ class _EditProfilePanelState extends State { "profilePhoto": pfpUrl, }); } catch (e) { - debugPrint(e.toString()); + logger.d(e.toString()); + toasts.error("Some uploading issue, please try again."); + } + } + + Future uploadFileCover() async { + try { + final String base64Image = base64Encode(_compressedCover); + final github = GitHub(auth: Authentication.withToken(token)); + await github.repositories + .createFile( + RepositorySlug(gitUserName, repoName), + CreateFile( + message: Path.basename(_cover!.path), + content: base64Image, + path: Path.basename(_cover!.path))) + .then((value) => setState(() { + coverUrl = value.content!.downloadUrl!; + coverPath = value.content!.path!; + coverSha = value.content!.sha!; + })); + logger.d('Cover File Uploaded'); + globals.prismUser.coverPhoto = coverUrl; + main.prefs.put("prismUserV2", globals.prismUser); + await firestore + .collection(USER_NEW_COLLECTION) + .doc(globals.prismUser.id) + .update({ + "coverPhoto": coverUrl, + }); + } catch (e) { + logger.d(e.toString()); toasts.error("Some uploading issue, please try again."); } } + Future onWillPop() async { + if (navStack.length > 1) navStack.removeLast(); + logger.d(navStack.toString()); + return true; + } + @override Widget build(BuildContext context) { final width = MediaQuery.of(context).size.width * 0.85; - return Padding( - padding: MediaQuery.of(context).viewInsets, - child: SingleChildScrollView( - child: Container( - height: MediaQuery.of(context).size.height * 0.7, - decoration: BoxDecoration( - color: Theme.of(context).primaryColor, - borderRadius: const BorderRadius.only( - topLeft: Radius.circular(20), - topRight: Radius.circular(20), - ), + return WillPopScope( + onWillPop: onWillPop, + child: Scaffold( + appBar: AppBar( + leading: IconButton( + icon: const Icon(JamIcons.close), + onPressed: () { + navStack.removeLast(); + logger.d(navStack.toString()); + Navigator.pop(context); + }), + title: Text( + "Edit Profile", + style: Theme.of(context).textTheme.headline3, ), - child: Column( - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.center, - mainAxisSize: MainAxisSize.min, - children: [ - Padding( - padding: const EdgeInsets.all(12.0), - child: Container( - height: 5, - width: 30, - decoration: BoxDecoration( - color: Theme.of(context).hintColor, - borderRadius: BorderRadius.circular(500)), - ), - ) - ], - ), - const Spacer(), - Text( - "Edit Profile", - style: Theme.of(context).textTheme.headline2, + ), + backgroundColor: Theme.of(context).primaryColor, + body: SingleChildScrollView( + child: Container( + height: MediaQuery.of(context).size.height, + width: MediaQuery.of(context).size.width, + decoration: BoxDecoration( + color: Theme.of(context).primaryColor, + borderRadius: const BorderRadius.only( + topLeft: Radius.circular(20), + topRight: Radius.circular(20), ), - const Spacer(), - ClipOval( - child: Material( - child: InkWell( - onTap: () async { - await getPFP(); - }, - child: Stack( - children: [ - Container( - height: 120, - width: 120, - decoration: const BoxDecoration( - shape: BoxShape.circle, - border: Border.fromBorderSide( - BorderSide(color: Colors.white, width: 2), + ), + child: Column( + children: [ + ClipRRect( + child: Material( + child: InkWell( + onTap: () async { + await getCover(); + }, + child: Stack( + children: [ + Container( + height: + MediaQuery.of(context).size.width * 508 / 1234, + width: MediaQuery.of(context).size.width, + decoration: const BoxDecoration( + border: Border.fromBorderSide( + BorderSide(color: Colors.white, width: 2), + ), ), + child: (_cover == null) + ? (globals.prismUser.coverPhoto != null) + ? CachedNetworkImage( + imageUrl: globals.prismUser.coverPhoto!, + fit: BoxFit.cover, + ) + : SvgPicture.string( + defaultHeader + .replaceAll( + "#181818", + "#${Theme.of(context).primaryColor.value.toRadixString(16).toString().substring(2)}", + ) + .replaceAll( + "#E77597", + "#${Theme.of(context).errorColor.value.toRadixString(16).toString().substring(2)}", + ), + fit: BoxFit.cover, + ) + : Image.file( + _cover!, + fit: BoxFit.cover, + ), ), - child: (_pfp == null) - ? CachedNetworkImage( - imageUrl: globals.prismUser.profilePhoto, - fit: BoxFit.cover, - ) - : Image.file( - _pfp!, - fit: BoxFit.cover, - ), - ), - Container( - height: 120, - width: 120, - decoration: BoxDecoration( - shape: BoxShape.circle, - border: const Border.fromBorderSide( - BorderSide(color: Colors.white, width: 2), + Container( + height: + MediaQuery.of(context).size.width * 508 / 1234, + width: MediaQuery.of(context).size.width, + decoration: BoxDecoration( + border: const Border.fromBorderSide( + BorderSide(color: Colors.white, width: 2), + ), + color: + Theme.of(context).errorColor.withOpacity(0.5), + ), + child: const Icon( + JamIcons.pencil, + color: Colors.white, + ), + ), + ], + ), + ), + ), + ), + const Spacer(), + ClipOval( + child: Material( + child: InkWell( + onTap: () async { + await getPFP(); + }, + child: Stack( + children: [ + Container( + height: 100, + width: 100, + decoration: const BoxDecoration( + shape: BoxShape.circle, + border: Border.fromBorderSide( + BorderSide(color: Colors.white, width: 2), + ), ), - color: - Theme.of(context).errorColor.withOpacity(0.5), + child: (_pfp == null) + ? CachedNetworkImage( + imageUrl: globals.prismUser.profilePhoto, + fit: BoxFit.cover, + ) + : Image.file( + _pfp!, + fit: BoxFit.cover, + ), ), - child: const Icon( - JamIcons.pencil, - color: Colors.white, + Container( + height: 100, + width: 100, + decoration: BoxDecoration( + shape: BoxShape.circle, + border: const Border.fromBorderSide( + BorderSide(color: Colors.white, width: 2), + ), + color: + Theme.of(context).errorColor.withOpacity(0.5), + ), + child: const Icon( + JamIcons.pencil, + color: Colors.white, + ), ), - ), - ], + ], + ), ), ), ), - ), - const Spacer(), - Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - SizedBox( - height: 80, - width: width - 24, - child: Center( - child: TextField( - cursorColor: const Color(0xFFE57697), - style: Theme.of(context) - .textTheme - .headline5! - .copyWith(color: Colors.white), - controller: usernameController, - decoration: InputDecoration( - contentPadding: - const EdgeInsets.only(left: 30, top: 15), - border: OutlineInputBorder( - borderRadius: BorderRadius.circular(10), - borderSide: const BorderSide( - color: Colors.white, width: 2)), - disabledBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(10), - borderSide: const BorderSide( - color: Colors.white, width: 2)), - enabledBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(10), - borderSide: const BorderSide( - color: Colors.white, width: 2)), - focusedBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(10), - borderSide: const BorderSide( - color: Colors.white, width: 2)), - labelText: "username", - labelStyle: Theme.of(context) + const Spacer(), + Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SizedBox( + height: 80, + width: width - 24, + child: Center( + child: TextField( + cursorColor: const Color(0xFFE57697), + style: Theme.of(context) .textTheme .headline5! - .copyWith(fontSize: 14, color: Colors.white), - prefixIcon: const Padding( - padding: EdgeInsets.all(16.0), - child: Text( - "@", - style: TextStyle( - color: Colors.white, - fontSize: 14, - fontWeight: FontWeight.bold, + .copyWith(color: Colors.white), + controller: nameController, + decoration: InputDecoration( + contentPadding: + const EdgeInsets.only(left: 30, top: 15), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: const BorderSide( + color: Colors.white, width: 2)), + disabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: const BorderSide( + color: Colors.white, width: 2)), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: const BorderSide( + color: Colors.white, width: 2)), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: const BorderSide( + color: Colors.white, width: 2)), + labelText: "Name", + labelStyle: Theme.of(context) + .textTheme + .headline5! + .copyWith(fontSize: 14, color: Colors.white), + prefixIcon: const Padding( + padding: EdgeInsets.all(16.0), + child: Text( + "Name", + style: TextStyle( + color: Colors.white, + fontSize: 14, + fontWeight: FontWeight.bold, + ), ), ), ), - suffixIcon: isCheckingUsername - ? Padding( - padding: const EdgeInsets.all(16.0), - child: SizedBox( - width: 16, - height: 16, - child: CircularProgressIndicator( - color: Theme.of(context).errorColor, + onChanged: (value) async { + if (value == globals.prismUser.name || + value == "") { + setState(() { + nameEdit = false; + }); + } else { + setState(() { + nameEdit = true; + }); + } + }, + ), + ), + ), + SizedBox( + height: 80, + width: width - 24, + child: Center( + child: TextField( + cursorColor: const Color(0xFFE57697), + style: Theme.of(context) + .textTheme + .headline5! + .copyWith(color: Colors.white), + controller: usernameController, + decoration: InputDecoration( + contentPadding: + const EdgeInsets.only(left: 30, top: 15), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: const BorderSide( + color: Colors.white, width: 2)), + disabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: const BorderSide( + color: Colors.white, width: 2)), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: const BorderSide( + color: Colors.white, width: 2)), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: const BorderSide( + color: Colors.white, width: 2)), + labelText: "username", + labelStyle: Theme.of(context) + .textTheme + .headline5! + .copyWith(fontSize: 14, color: Colors.white), + prefixIcon: const Padding( + padding: EdgeInsets.all(16.0), + child: Text( + "@", + style: TextStyle( + color: Colors.white, + fontSize: 14, + fontWeight: FontWeight.bold, + ), + ), + ), + suffixIcon: isCheckingUsername + ? Padding( + padding: const EdgeInsets.all(16.0), + child: SizedBox( + width: 16, + height: 16, + child: CircularProgressIndicator( + color: Theme.of(context).errorColor, + ), ), - ), - ) - : Padding( - padding: EdgeInsets.all( - available == null ? 16.0 : 8), - child: available == null - ? const Text( - "", - style: TextStyle( - color: Colors.white, - fontSize: 14, - fontWeight: FontWeight.bold, + ) + : Padding( + padding: EdgeInsets.all( + available == null ? 16.0 : 8), + child: available == null + ? const Text( + "", + style: TextStyle( + color: Colors.white, + fontSize: 14, + fontWeight: FontWeight.bold, + ), + ) + : Icon( + available! + ? JamIcons.check + : JamIcons.close, + color: available! + ? Colors.green + : Colors.red, + size: 24, ), - ) - : Icon( - available! - ? JamIcons.check - : JamIcons.close, - color: available! - ? Colors.green - : Colors.red, - size: 24, - ), - ), + ), + ), + onChanged: (value) async { + if (value != "" && + value.length >= 8 && + !value.contains(RegExp(r"(?: |[^\w\s])+"))) { + setState(() { + enabled = true; + }); + } else { + setState(() { + enabled = false; + }); + } + if (enabled) { + setState(() { + isCheckingUsername = true; + }); + await FirebaseFirestore.instance + .collection(USER_NEW_COLLECTION) + .where("username", isEqualTo: value) + .get() + .then((snapshot) { + if (snapshot.size == 0) { + setState(() { + available = true; + }); + } else { + setState(() { + available = false; + }); + } + }); + setState(() { + isCheckingUsername = false; + }); + } else { + setState(() { + available = null; + }); + } + if (value == globals.prismUser.username || + value == "") { + setState(() { + usernameEdit = false; + available = null; + }); + } else { + setState(() { + usernameEdit = true; + }); + } + }, ), - onChanged: (value) async { - if (value == "") { - setState(() { - usernameEdit = false; - }); - } else { - setState(() { - usernameEdit = true; - }); - } - if (value != "" && - value.length >= 8 && - !value.contains(RegExp(r"(?: |[^\w\s])+"))) { - setState(() { - enabled = true; - }); - } else { - setState(() { - enabled = false; - }); - } - if (enabled) { - setState(() { - isCheckingUsername = true; - }); - await FirebaseFirestore.instance - .collection(USER_NEW_COLLECTION) - .where("username", isEqualTo: value) - .get() - .then((snapshot) { - if (snapshot.size == 0) { - setState(() { - available = true; - }); - } else { - setState(() { - available = false; - }); - } - }); - setState(() { - isCheckingUsername = false; - }); - } else { - setState(() { - available = null; - }); - } - }, ), ), - ), - SizedBox( - height: 80, - width: width - 24, - child: Center( - child: TextField( - cursorColor: const Color(0xFFE57697), - style: Theme.of(context) - .textTheme - .headline5! - .copyWith(color: Colors.white), - controller: bioController, - decoration: InputDecoration( - contentPadding: - const EdgeInsets.only(left: 30, top: 15), - border: OutlineInputBorder( - borderRadius: BorderRadius.circular(10), - borderSide: const BorderSide( - color: Colors.white, width: 2)), - disabledBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(10), - borderSide: const BorderSide( - color: Colors.white, width: 2)), - enabledBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(10), - borderSide: const BorderSide( - color: Colors.white, width: 2)), - focusedBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(10), - borderSide: const BorderSide( - color: Colors.white, width: 2)), - labelText: "Bio", - labelStyle: Theme.of(context) + SizedBox( + height: 80, + width: width - 24, + child: Center( + child: TextField( + cursorColor: const Color(0xFFE57697), + style: Theme.of(context) .textTheme .headline5! - .copyWith(fontSize: 14, color: Colors.white), - prefixIcon: const Padding( - padding: EdgeInsets.all(16.0), - child: Text( - "bio", - style: TextStyle( - color: Colors.white, - fontSize: 14, - fontWeight: FontWeight.bold, + .copyWith(color: Colors.white), + controller: bioController, + decoration: InputDecoration( + contentPadding: + const EdgeInsets.only(left: 30, top: 15), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: const BorderSide( + color: Colors.white, width: 2)), + disabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: const BorderSide( + color: Colors.white, width: 2)), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: const BorderSide( + color: Colors.white, width: 2)), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: const BorderSide( + color: Colors.white, width: 2)), + labelText: "Bio", + labelStyle: Theme.of(context) + .textTheme + .headline5! + .copyWith(fontSize: 14, color: Colors.white), + prefixIcon: const Padding( + padding: EdgeInsets.all(16.0), + child: Text( + "bio", + style: TextStyle( + color: Colors.white, + fontSize: 14, + fontWeight: FontWeight.bold, + ), ), ), ), + onChanged: (value) { + if (value == globals.prismUser.bio || value == "") { + setState(() { + bioEdit = false; + }); + } else { + setState(() { + bioEdit = true; + }); + } + }, ), - onChanged: (value) { - if (value == "") { - setState(() { - bioEdit = false; - }); - } else { - setState(() { - bioEdit = true; - }); - } - }, ), ), - ), - Padding( - padding: const EdgeInsets.all(8.0), - child: GestureDetector( - onTap: (!usernameEdit && (pfpEdit || bioEdit)) - ? () async { - setState(() { - isLoading = true; + SizedBox( + height: 80, + width: width - 24, + child: Stack( + alignment: Alignment.center, + children: [ + Positioned( + left: 0, + child: SizedBox( + height: 80, + width: 130, + child: Center( + child: DropdownButton>( + isExpanded: true, + items: linkIcons + .map((Map link) { + return DropdownMenuItem( + value: link, + child: Row( + crossAxisAlignment: + CrossAxisAlignment.end, + children: [ + Icon(link["icon"] as IconData), + const SizedBox( + width: 16, + ), + Text( + link["name"].toString().inCaps, + style: Theme.of(context) + .textTheme + .headline5! + .copyWith( + color: Colors.white, + fontSize: 14, + ), + ) + ], + ), + ); + }).toList(), + underline: Container(), + onChanged: (value) { + setState(() => _link = value); + linkController.text = + _link!["value"].toString(); + }, + icon: Container(), + value: _link, + dropdownColor: Theme.of(context).primaryColor, + selectedItemBuilder: (BuildContext context) { + return linkIcons.map((Map link) { + return Padding( + padding: + const EdgeInsets.only(left: 12.0), + child: Row( + children: [ + Icon(link["icon"] as IconData), + const Icon( + JamIcons.chevron_down, + size: 14, + ), + ], + ), + ); + }).toList(); + }, + ), + ), + ), + ), + Positioned( + right: 0, + child: SizedBox( + height: 80, + width: width - 80, + child: Center( + child: TextField( + cursorColor: const Color(0xFFE57697), + style: Theme.of(context) + .textTheme + .headline5! + .copyWith(color: Colors.white), + controller: linkController, + decoration: InputDecoration( + enabled: _link?["name"] != "Edit links...", + contentPadding: const EdgeInsets.only( + left: 30, top: 15), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: const BorderSide( + color: Colors.white, width: 2)), + disabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: const BorderSide( + color: Colors.white, width: 2)), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: const BorderSide( + color: Colors.white, width: 2)), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: const BorderSide( + color: Colors.white, width: 2)), + labelText: + _link?["name"].toString().inCaps ?? "", + labelStyle: Theme.of(context) + .textTheme + .headline5! + .copyWith( + fontSize: 14, color: Colors.white), + hintText: _link?["link"].toString() ?? "", + hintStyle: Theme.of(context) + .textTheme + .headline5! + .copyWith( + fontSize: 14, color: Colors.white), + ), + onChanged: (value) { + // logger.d("VALUE TEXT ${value.toLowerCase()}"); + // logger.d( + // "VALUE LINK NAME ${_link?["name"].toString().toLowerCase()}"); + // logger.d( + // "VALUE LINK VALUE ${_link?["value"].toString().toLowerCase()}"); + // logger.d("VALUE LINK EDIT ${linkEdit}"); + // logger.d( + // "VALUE LINK CONTAINS ${(value.toLowerCase().contains('${_link?["name"].toString().toLowerCase()}'))}"); + + if (value.toLowerCase().contains( + '${_link?["validator"].toString().toLowerCase()}')) { + setState(() { + _link?["value"] = value; + // if (_link?["name"].toString() == 'github') { + // githubUrl = value; + // } else if (_link?["name"].toString() == + // 'twitter') { + // twitterUrl = value; + // } else if (_link?["name"].toString() == + // 'instagram') { + // instagramUrl = value; + // } else if (_link?["name"].toString() == + // 'email') { + // emailUrl = value; + // } + }); + bool changed = false; + for (int i = 0; + i < linkIcons.length; + i++) { + if (linkIcons[i]["value"] != "") { + changed = true; + break; + } + } + setState(() { + linkEdit = changed; + }); + } else if (value == "") { + bool changed = false; + for (int i = 0; + i < linkIcons.length; + i++) { + if (linkIcons[i]["value"] != "") { + changed = true; + break; + } + } + setState(() { + linkEdit = changed; + }); + } else { + setState(() { + linkEdit = false; + }); + } + }, + ), + ), + ), + ), + ], + ), + ), + ], + ), + const Spacer(), + Padding( + padding: const EdgeInsets.all(8.0), + child: GestureDetector( + onTap: (!usernameEdit && + (pfpEdit || + bioEdit || + linkEdit || + coverEdit || + nameEdit)) + ? () async { + setState(() { + isLoading = true; + }); + if (_pfp != null && pfpEdit) { + await processImage(); + } + if (_cover != null && coverEdit) { + await processImageCover(); + } + if (bioEdit && bioController.text != "") { + globals.prismUser.bio = bioController.text; + main.prefs.put("prismUserV2", globals.prismUser); + await firestore + .collection(USER_NEW_COLLECTION) + .doc(globals.prismUser.id) + .update({ + "bio": bioController.text, }); - if (_pfp != null && pfpEdit) { - await processImage(); - } - if (bioEdit && bioController.text != "") { - globals.prismUser.bio = bioController.text; - main.prefs - .put("prismUserV2", globals.prismUser); - await firestore - .collection(USER_NEW_COLLECTION) - .doc(globals.prismUser.id) - .update({ - "bio": bioController.text, - }); + } + if (linkEdit) { + Map links = globals.prismUser.links; + for (int p = 0; p < linkIcons.length; p++) { + if (linkIcons[p]["value"] != "") { + links[linkIcons[p]["name"]] = + linkIcons[p]["value"]; + } } - setState(() { - isLoading = false; + globals.prismUser.links = links; + main.prefs.put("prismUserV2", globals.prismUser); + await firestore + .collection(USER_NEW_COLLECTION) + .doc(globals.prismUser.id) + .update({ + "links": links, }); - Navigator.pop(context); - toasts.codeSend("Details updated!"); } - : (usernameEdit && enabled) - ? () async { - setState(() { - isLoading = true; + if (nameEdit && nameController.text != "") { + globals.prismUser.name = nameController.text; + main.prefs.put("prismUserV2", globals.prismUser); + await firestore + .collection(USER_NEW_COLLECTION) + .doc(globals.prismUser.id) + .update({ + "name": nameController.text, + }); + } + setState(() { + isLoading = false; + }); + Navigator.pop(context); + navStack.removeLast(); + logger.d(navStack.toString()); + toasts.codeSend("Details updated!"); + } + : (usernameEdit && enabled) + ? () async { + setState(() { + isLoading = true; + }); + if (usernameEdit && + usernameController.text != "" && + usernameController.text.length >= 8) { + globals.prismUser.username = + usernameController.text; + main.prefs + .put("prismUserV2", globals.prismUser); + await firestore + .collection(USER_NEW_COLLECTION) + .doc(globals.prismUser.id) + .update({ + "username": usernameController.text, }); - if (usernameEdit && - usernameController.text != "" && - usernameController.text.length >= 8) { - globals.prismUser.username = - usernameController.text; - main.prefs - .put("prismUserV2", globals.prismUser); - await firestore - .collection(USER_NEW_COLLECTION) - .doc(globals.prismUser.id) - .update({ - "username": usernameController.text, - }); - } - if (_pfp != null && pfpEdit) { - await processImage(); - } - if (bioEdit && bioController.text != "") { - globals.prismUser.bio = bioController.text; - main.prefs - .put("prismUserV2", globals.prismUser); - await firestore - .collection(USER_NEW_COLLECTION) - .doc(globals.prismUser.id) - .update({ - "bio": bioController.text, - }); + } + if (_pfp != null && pfpEdit) { + await processImage(); + } + if (_cover != null && coverEdit) { + await processImageCover(); + } + if (bioEdit && bioController.text != "") { + globals.prismUser.bio = bioController.text; + main.prefs + .put("prismUserV2", globals.prismUser); + await firestore + .collection(USER_NEW_COLLECTION) + .doc(globals.prismUser.id) + .update({ + "bio": bioController.text, + }); + } + if (nameEdit && nameController.text != "") { + globals.prismUser.name = nameController.text; + main.prefs + .put("prismUserV2", globals.prismUser); + await firestore + .collection(USER_NEW_COLLECTION) + .doc(globals.prismUser.id) + .update({ + "name": nameController.text, + }); + } + if (linkEdit) { + Map links = globals.prismUser.links; + for (int p = 0; p < linkIcons.length; p++) { + if (linkIcons[p]["value"] != "") { + links[linkIcons[p]["name"]] = + linkIcons[p]["value"]; + } } - setState(() { - isLoading = false; + globals.prismUser.links = links; + main.prefs + .put("prismUserV2", globals.prismUser); + await firestore + .collection(USER_NEW_COLLECTION) + .doc(globals.prismUser.id) + .update({ + "links": links, }); - Navigator.pop(context); - toasts.codeSend("Details updated!"); } - : null, - child: SizedBox( - width: width - 20, + setState(() { + isLoading = false; + }); + Navigator.pop(context); + navStack.removeLast(); + logger.d(navStack.toString()); + toasts.codeSend("Details updated!"); + } + : null, + child: SizedBox( + width: width - 20, + height: 60, + child: Container( + width: width - 14, height: 60, - child: Container( - width: width - 14, - height: 60, - decoration: BoxDecoration( - color: !((!usernameEdit && (pfpEdit || bioEdit)) || - (usernameEdit && enabled)) - ? Theme.of(context).primaryColor - : Theme.of(context).errorColor.withOpacity(0.2), - border: Border.all( - color: - !((!usernameEdit && (pfpEdit || bioEdit)) || - (usernameEdit && enabled)) - ? Theme.of(context) - .accentColor - .withOpacity(0.5) - : Theme.of(context).errorColor, - width: 3), - borderRadius: BorderRadius.circular(10), - ), - child: Center( - child: isLoading - ? CircularProgressIndicator( - color: Theme.of(context).primaryColor) - : Text( - "Continue", - style: TextStyle( - fontSize: 16, - color: !((!usernameEdit && - (pfpEdit || bioEdit)) || - (usernameEdit && enabled)) - ? Theme.of(context) - .accentColor - .withOpacity(0.5) - : Theme.of(context).accentColor, - fontWeight: FontWeight.bold), - ), - ), + decoration: BoxDecoration( + color: !((!usernameEdit && + (pfpEdit || + bioEdit || + linkEdit || + coverEdit || + nameEdit)) || + (usernameEdit && enabled)) + ? Theme.of(context).primaryColor + : Theme.of(context).errorColor.withOpacity(0.2), + border: Border.all( + color: !((!usernameEdit && + (pfpEdit || + bioEdit || + linkEdit || + coverEdit || + nameEdit)) || + (usernameEdit && enabled)) + ? Theme.of(context) + .accentColor + .withOpacity(0.5) + : Theme.of(context).errorColor, + width: 3), + borderRadius: BorderRadius.circular(10), + ), + child: Center( + child: isLoading + ? CircularProgressIndicator( + color: Theme.of(context).primaryColor) + : Text( + "Update", + style: TextStyle( + fontSize: 16, + color: !((!usernameEdit && + (pfpEdit || + bioEdit || + linkEdit || + coverEdit || + nameEdit)) || + (usernameEdit && enabled)) + ? Theme.of(context) + .accentColor + .withOpacity(0.5) + : Theme.of(context).accentColor, + fontWeight: FontWeight.bold), + ), ), ), ), ), - ], - ), - const Spacer(flex: 2), - Padding( - padding: const EdgeInsets.fromLTRB(0, 0, 0, 32), - child: SizedBox( - width: MediaQuery.of(context).size.width * 0.8, - child: Text( - "Usernames are unique names through which fans can view your profile/search for you. They should be greater than 8 characters, and cannot contain any symbol except for underscore (_).", - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 13, - color: Theme.of(context).accentColor, + ), + const Spacer(flex: 2), + Padding( + padding: const EdgeInsets.fromLTRB(0, 0, 0, 32), + child: SizedBox( + width: MediaQuery.of(context).size.width * 0.8, + child: Text( + "Usernames are unique names through which fans can view your profile/search for you. They should be greater than 8 characters, and cannot contain any symbol except for underscore (_).", + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 13, + color: Theme.of(context).accentColor, + ), ), ), ), - ), - const Spacer(), - ], + const Spacer( + flex: 3, + ), + ], + ), ), ), ), diff --git a/lib/ui/widgets/popup/linkPopUp.dart b/lib/ui/widgets/popup/linkPopUp.dart index c96aa8fb..ddd77438 100644 --- a/lib/ui/widgets/popup/linkPopUp.dart +++ b/lib/ui/widgets/popup/linkPopUp.dart @@ -5,15 +5,16 @@ import 'package:Prism/ui/widgets/animated/loader.dart'; import 'package:animations/animations.dart'; import 'package:flutter/material.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:Prism/logger/logger.dart'; void showLinksPopUp(BuildContext context, String id) { Future> getLinks(String id) async { List links = []; final FirebaseFirestore firestore = FirebaseFirestore.instance; - debugPrint(id); + logger.d(id); await firestore.collection(USER_NEW_COLLECTION).doc(id).get().then((value) { links = linksToModel(value.data()!["links"] as Map); - debugPrint(links.toString()); + logger.d(links.toString()); }); return links; } @@ -29,12 +30,12 @@ void showLinksPopUp(BuildContext context, String id) { future: getLinks(id), builder: (context, snapshot) { if (snapshot == null) { - debugPrint("snapshot null"); + logger.d("snapshot null"); return SizedBox(height: 300, child: Center(child: Loader())); } if (snapshot.connectionState == ConnectionState.waiting || snapshot.connectionState == ConnectionState.none) { - debugPrint("snapshot none, waiting"); + logger.d("snapshot none, waiting"); return SizedBox(height: 300, child: Center(child: Loader())); } else { if (snapshot.data!.isNotEmpty) { diff --git a/lib/ui/widgets/popup/noLoadLinkPopUp.dart b/lib/ui/widgets/popup/noLoadLinkPopUp.dart index 820a9c40..c1ea84f2 100644 --- a/lib/ui/widgets/popup/noLoadLinkPopUp.dart +++ b/lib/ui/widgets/popup/noLoadLinkPopUp.dart @@ -1,17 +1,43 @@ -import 'package:Prism/data/links/model/linksModel.dart'; +import 'package:Prism/theme/jam_icons_icons.dart'; +// import 'package:Prism/data/links/model/linksModel.dart'; import 'package:Prism/ui/pages/profile/aboutScreen.dart'; import 'package:animations/animations.dart'; import 'package:flutter/material.dart'; +import 'package:Prism/global/globals.dart'; void showNoLoadLinksPopUp(BuildContext context, Map link) { - List links = []; - void getLinks(Map link) { - links = linksToModel(link); - } + // List links = []; + // void getLinks(Map link) { + // links = linksToModel(link); + // } - getLinks(link); + // getLinks(link); final AlertDialog linkPopUp = AlertDialog( shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), + title: Text( + 'More links', + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 16, + color: Theme.of(context).accentColor, + ), + ), + actions: [ + FlatButton( + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5)), + color: Theme.of(context).errorColor, + onPressed: () { + Navigator.of(context).pop(); + }, + child: const Text( + 'CLOSE', + style: TextStyle( + fontSize: 16.0, + color: Colors.white, + ), + ), + ), + ], content: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), @@ -23,12 +49,13 @@ void showNoLoadLinksPopUp(BuildContext context, Map link) { children: [ Wrap( alignment: WrapAlignment.center, - children: links + children: link.keys + .toList() .map( (e) => ActionButton( - icon: e.icon, - link: e.link, - text: "@${e.username}", + icon: (linksData[e] ?? {})["icon"] as IconData, + link: link[e].toString(), + text: (linksData[e] ?? {})["name"].toString().inCaps, ), ) .toList(), @@ -37,10 +64,174 @@ void showNoLoadLinksPopUp(BuildContext context, Map link) { ), ), backgroundColor: Theme.of(context).primaryColor, - contentPadding: const EdgeInsets.fromLTRB(0, 0, 0, 10), + actionsPadding: const EdgeInsets.fromLTRB(10, 0, 10, 0), ); showModal( context: context, configuration: const FadeScaleTransitionConfiguration(), builder: (BuildContext context) => linkPopUp); } + +Map> linksData = { + 'github': { + 'name': 'github', + 'link': 'https://github.com/username', + 'icon': JamIcons.github, + 'value': '', + 'validator': 'github', + }, + 'twitter': { + 'name': 'twitter', + 'link': 'https://twitter.com/username', + 'icon': JamIcons.twitter, + 'value': '', + 'validator': 'twitter', + }, + 'instagram': { + 'name': 'instagram', + 'link': 'https://instagram.com/username', + 'icon': JamIcons.instagram, + 'value': '', + 'validator': 'instagram', + }, + 'email': { + 'name': 'email', + 'link': 'your@email.com', + 'icon': JamIcons.inbox, + 'value': '', + 'validator': '@', + }, + 'telegram': { + 'name': 'telegram', + 'link': 'https://t.me/username', + 'icon': JamIcons.paper_plane, + 'value': '', + 'validator': 't.me', + }, + 'dribbble': { + 'name': 'dribbble', + 'link': 'https://dribbble.com/username', + 'icon': JamIcons.basketball, + 'value': '', + 'validator': 'dribbble', + }, + 'linkedin': { + 'name': 'linkedin', + 'link': 'https://linkedin.com/in/username', + 'icon': JamIcons.linkedin, + 'value': '', + 'validator': 'linkedin', + }, + 'bio.link': { + 'name': 'bio.link', + 'link': 'https://bio.link/username', + 'icon': JamIcons.world, + 'value': '', + 'validator': 'bio.link', + }, + 'patreon': { + 'name': 'patreon', + 'link': 'https://patreon.com/username', + 'icon': JamIcons.patreon, + 'value': '', + 'validator': 'patreon', + }, + 'trello': { + 'name': 'trello', + 'link': 'https://trello.com/username', + 'icon': JamIcons.trello, + 'value': '', + 'validator': 'trello', + }, + 'reddit': { + 'name': 'reddit', + 'link': 'https://reddit.com/user/username', + 'icon': JamIcons.reddit, + 'value': '', + 'validator': 'reddit', + }, + 'behance': { + 'name': 'behance', + 'link': 'https://behance.net/username', + 'icon': JamIcons.behance, + 'value': '', + 'validator': 'behance.net', + }, + 'deviantart': { + 'name': 'deviantart', + 'link': 'https://deviantart.com/username', + 'icon': JamIcons.deviantart, + 'value': '', + 'validator': 'deviantart', + }, + 'gitlab': { + 'name': 'gitlab', + 'link': 'https://gitlab.com/username', + 'icon': JamIcons.gitlab, + 'value': '', + 'validator': 'gitlab', + }, + 'medium': { + 'name': 'medium', + 'link': 'https://username.medium.com/', + 'icon': JamIcons.medium, + 'value': '', + 'validator': 'medium', + }, + 'paypal': { + 'name': 'paypal', + 'link': 'https://paypal.me/username', + 'icon': JamIcons.paypal, + 'value': '', + 'validator': 'paypal', + }, + 'spotify': { + 'name': 'spotify', + 'link': 'https://open.spotify.com/user/username', + 'icon': JamIcons.spotify, + 'value': '', + 'validator': 'open.spotify', + }, + 'twitch': { + 'name': 'twitch', + 'link': 'https://twitch.tv/username', + 'icon': JamIcons.twitch, + 'value': '', + 'validator': 'twitch.tv', + }, + 'unsplash': { + 'name': 'unsplash', + 'link': 'https://unsplash.com/username', + 'icon': JamIcons.unsplash, + 'value': '', + 'validator': 'unsplash', + }, + 'youtube': { + 'name': 'youtube', + 'link': 'https://youtube.com/channel/username', + 'icon': JamIcons.youtube, + 'value': '', + 'validator': 'youtube', + }, + 'linktree': { + 'name': 'linktree', + 'link': 'https://linktr.ee/username', + 'icon': JamIcons.tree_alt, + 'value': '', + 'validator': 'linktr.ee', + }, + 'buymeacoffee': { + 'name': 'buymeacoffee', + 'link': 'https://buymeacoff.ee/username', + 'icon': JamIcons.coffee, + 'value': '', + 'validator': 'buymeacoff.ee', + }, + 'custom link': { + 'name': 'custom link', + 'link': '', + 'icon': JamIcons.link, + 'value': '', + 'validator': '', + }, +}; diff --git a/lib/ui/widgets/popup/signInPopUp.dart b/lib/ui/widgets/popup/signInPopUp.dart index 5138e2c2..cd15279a 100644 --- a/lib/ui/widgets/popup/signInPopUp.dart +++ b/lib/ui/widgets/popup/signInPopUp.dart @@ -5,6 +5,7 @@ import 'package:flutter/material.dart'; import 'package:Prism/global/globals.dart' as globals; import 'package:Prism/main.dart' as main; import 'package:Prism/theme/toasts.dart' as toasts; +import 'package:Prism/logger/logger.dart'; void googleSignInPopUp(BuildContext context, Function func) { final Dialog loaderDialog = Dialog( @@ -244,7 +245,7 @@ void googleSignInPopUp(BuildContext context, Function func) { Navigator.pop(context); func(); }).catchError((e) { - debugPrint(e.toString()); + logger.d(e.toString()); Navigator.pop(context); globals.prismUser.loggedIn = false; main.prefs.put("prismUserV2", globals.prismUser); diff --git a/lib/ui/widgets/profile/downloadList.dart b/lib/ui/widgets/profile/downloadList.dart index 5739d189..4020b142 100644 --- a/lib/ui/widgets/profile/downloadList.dart +++ b/lib/ui/widgets/profile/downloadList.dart @@ -5,6 +5,7 @@ import 'package:animations/animations.dart'; import 'package:flutter/material.dart'; import 'package:fluttertoast/fluttertoast.dart'; import 'package:permission_handler/permission_handler.dart'; +import 'package:Prism/logger/logger.dart'; class DownloadList extends StatelessWidget { @override @@ -97,13 +98,13 @@ class DownloadList extends StatelessWidget { dir.deleteSync(recursive: true); deletedDir = true; } catch (e) { - debugPrint(e.toString()); + logger.d(e.toString()); } try { dir2.deleteSync(recursive: true); deletedDir2 = true; } catch (e) { - debugPrint(e.toString()); + logger.d(e.toString()); } if (deletedDir || deletedDir2) { Fluttertoast.showToast( diff --git a/lib/ui/widgets/profile/drawerWidget.dart b/lib/ui/widgets/profile/drawerWidget.dart index 6557fad3..0243e7db 100644 --- a/lib/ui/widgets/profile/drawerWidget.dart +++ b/lib/ui/widgets/profile/drawerWidget.dart @@ -210,13 +210,13 @@ class ProfileDrawer extends StatelessWidget { dir.deleteSync(recursive: true); deletedDir = true; } catch (e) { - debugPrint(e.toString()); + logger.d(e.toString()); } try { dir2.deleteSync(recursive: true); deletedDir2 = true; } catch (e) { - debugPrint(e.toString()); + logger.d(e.toString()); } if (deletedDir || deletedDir2) { Fluttertoast.showToast( @@ -300,8 +300,10 @@ class ProfileDrawer extends StatelessWidget { context: context, onTap: () { createUserDynamicLink( + globals.prismUser.name.toString(), globals.prismUser.username.toString(), globals.prismUser.email.toString(), + globals.prismUser.bio.toString(), globals.prismUser.profilePhoto.toString(), ); }), @@ -365,7 +367,7 @@ class ProfileDrawer extends StatelessWidget { final sdkInt = androidInfo.version.sdkInt; final manufacturer = androidInfo.manufacturer; final model = androidInfo.model; - debugPrint( + logger.d( 'Android $release (SDK $sdkInt), $manufacturer $model'); final String zipPath = await zipLogs(); final MailOptions mailOptions = MailOptions( diff --git a/lib/ui/widgets/profile/prismList.dart b/lib/ui/widgets/profile/prismList.dart index e05cd42d..bcf1c898 100644 --- a/lib/ui/widgets/profile/prismList.dart +++ b/lib/ui/widgets/profile/prismList.dart @@ -210,8 +210,8 @@ class PrismList extends StatelessWidget { final sdkInt = androidInfo.version.sdkInt; final manufacturer = androidInfo.manufacturer; final model = androidInfo.model; - debugPrint( - 'Android $release (SDK $sdkInt), $manufacturer $model'); + logger + .d('Android $release (SDK $sdkInt), $manufacturer $model'); final String zipPath = await zipLogs(); final MailOptions mailOptions = MailOptions( body: diff --git a/lib/ui/widgets/profile/uploadedSetupsLoader.dart b/lib/ui/widgets/profile/uploadedSetupsLoader.dart index 36a9cb1b..c74c7b5f 100644 --- a/lib/ui/widgets/profile/uploadedSetupsLoader.dart +++ b/lib/ui/widgets/profile/uploadedSetupsLoader.dart @@ -1,6 +1,7 @@ import 'package:Prism/ui/widgets/animated/loader.dart'; import 'package:Prism/ui/widgets/profile/uploadedSetupsGrid.dart'; import 'package:flutter/material.dart'; +import 'package:Prism/logger/logger.dart'; class UploadedSetupsLoader extends StatefulWidget { final Future future; @@ -26,15 +27,15 @@ class _UploadedSetupsLoaderState extends State { future: _future, builder: (ctx, snapshot) { if (snapshot == null) { - debugPrint("snapshot null"); + logger.d("snapshot null"); return Center( child: Loader(), ); } if (snapshot.connectionState == ConnectionState.waiting || snapshot.connectionState == ConnectionState.none) { - debugPrint("snapshot none, waiting"); - debugPrint(snapshot.data.toString()); + logger.d("snapshot none, waiting"); + logger.d(snapshot.data.toString()); return Center( child: Loader(), ); diff --git a/lib/ui/widgets/profile/uploadedWallsLoader.dart b/lib/ui/widgets/profile/uploadedWallsLoader.dart index 6492a33c..0edd913c 100644 --- a/lib/ui/widgets/profile/uploadedWallsLoader.dart +++ b/lib/ui/widgets/profile/uploadedWallsLoader.dart @@ -1,6 +1,7 @@ import 'package:Prism/ui/widgets/animated/loader.dart'; import 'package:Prism/ui/widgets/profile/uploadedWallsGrid.dart'; import 'package:flutter/material.dart'; +import 'package:Prism/logger/logger.dart'; class ProfileLoader extends StatefulWidget { final Future future; @@ -26,14 +27,14 @@ class _ProfileLoaderState extends State { future: _future, builder: (ctx, snapshot) { if (snapshot == null) { - debugPrint("snapshot null"); + logger.d("snapshot null"); return Center( child: Loader(), ); } if (snapshot.connectionState == ConnectionState.waiting || snapshot.connectionState == ConnectionState.none) { - debugPrint("snapshot none, waiting"); + logger.d("snapshot none, waiting"); return Center( child: Loader(), ); diff --git a/lib/ui/widgets/profile/userList.dart b/lib/ui/widgets/profile/userList.dart index 9a328fa6..4fdecbb2 100644 --- a/lib/ui/widgets/profile/userList.dart +++ b/lib/ui/widgets/profile/userList.dart @@ -7,6 +7,7 @@ import 'package:Prism/main.dart' as main; import 'package:Prism/global/globals.dart' as globals; import 'package:Prism/theme/toasts.dart' as toasts; import 'package:provider/provider.dart'; +import 'package:Prism/logger/logger.dart'; class UserList extends StatelessWidget { final bool expanded; @@ -42,7 +43,7 @@ class UserList extends StatelessWidget { Navigator.pop(context); main.RestartWidget.restartApp(context); }).catchError((e) { - debugPrint(e.toString()); + logger.d(e.toString()); Navigator.pop(context); globals.prismUser.loggedIn = false; main.prefs.put("prismUserV2", globals.prismUser); diff --git a/lib/ui/widgets/profile/userProfileGrid.dart b/lib/ui/widgets/profile/userProfileGrid.dart index d33a0096..f6595e4c 100644 --- a/lib/ui/widgets/profile/userProfileGrid.dart +++ b/lib/ui/widgets/profile/userProfileGrid.dart @@ -13,6 +13,7 @@ import 'package:flutter/scheduler.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:provider/provider.dart'; import 'package:Prism/global/globals.dart' as globals; +import 'package:Prism/logger/logger.dart'; class UserProfileGrid extends StatefulWidget { final String? email; @@ -311,7 +312,7 @@ class PhotographerWallTile extends StatelessWidget { final int index; void showGooglePopUp(BuildContext context, Function func) { - debugPrint(globals.prismUser.loggedIn.toString()); + logger.d(globals.prismUser.loggedIn.toString()); if (globals.prismUser.loggedIn == false) { googleSignInPopUp(context, func); } else { diff --git a/lib/ui/widgets/profile/userProfileLoader.dart b/lib/ui/widgets/profile/userProfileLoader.dart index 571452b1..e330efd6 100644 --- a/lib/ui/widgets/profile/userProfileLoader.dart +++ b/lib/ui/widgets/profile/userProfileLoader.dart @@ -3,6 +3,7 @@ import 'package:Prism/ui/widgets/home/wallpapers/loading.dart'; import 'package:Prism/ui/widgets/profile/userProfileGrid.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import 'package:Prism/logger/logger.dart'; class UserProfileLoader extends StatefulWidget { final String? email; @@ -29,12 +30,12 @@ class _UserProfileLoaderState extends State { future: _future, builder: (ctx, snapshot) { if (snapshot == null) { - debugPrint("snapshot null"); + logger.d("snapshot null"); return const LoadingCards(); } if (snapshot.connectionState == ConnectionState.waiting || snapshot.connectionState == ConnectionState.none) { - debugPrint("snapshot none, waiting"); + logger.d("snapshot none, waiting"); return const LoadingCards(); } else { return UserProfileGrid( diff --git a/lib/ui/widgets/profile/userProfileSetupGrid.dart b/lib/ui/widgets/profile/userProfileSetupGrid.dart index b4982b6a..2379a967 100644 --- a/lib/ui/widgets/profile/userProfileSetupGrid.dart +++ b/lib/ui/widgets/profile/userProfileSetupGrid.dart @@ -13,6 +13,7 @@ import 'package:flutter_svg/flutter_svg.dart'; import 'package:provider/provider.dart'; import 'package:Prism/main.dart' as main; import 'package:Prism/global/globals.dart' as globals; +import 'package:Prism/logger/logger.dart'; class UserProfileSetupGrid extends StatefulWidget { final String? email; @@ -42,7 +43,7 @@ class _UserProfileSetupGridState extends State } void showGooglePopUp(Function func) { - debugPrint(globals.prismUser.loggedIn.toString()); + logger.d(globals.prismUser.loggedIn.toString()); if (globals.prismUser.loggedIn == false) { googleSignInPopUp(context, func); } else { diff --git a/lib/ui/widgets/profile/userProfileSetupLoader.dart b/lib/ui/widgets/profile/userProfileSetupLoader.dart index da2af56b..00c8a685 100644 --- a/lib/ui/widgets/profile/userProfileSetupLoader.dart +++ b/lib/ui/widgets/profile/userProfileSetupLoader.dart @@ -3,6 +3,7 @@ import 'package:Prism/ui/widgets/profile/userProfileSetupGrid.dart'; import 'package:Prism/ui/widgets/setups/loadingSetups.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import 'package:Prism/logger/logger.dart'; class UserProfileSetupLoader extends StatefulWidget { final String? email; @@ -29,12 +30,12 @@ class _UserProfileSetupLoaderState extends State { future: _future, builder: (ctx, snapshot) { if (snapshot == null) { - debugPrint("snapshot null"); + logger.d("snapshot null"); return const LoadingSetupCards(); } if (snapshot.connectionState == ConnectionState.waiting || snapshot.connectionState == ConnectionState.none) { - debugPrint("snapshot none, waiting"); + logger.d("snapshot none, waiting"); return const LoadingSetupCards(); } else { return UserProfileSetupGrid( diff --git a/lib/ui/widgets/search/searchGrid.dart b/lib/ui/widgets/search/searchGrid.dart index b2684cf2..e14f077b 100644 --- a/lib/ui/widgets/search/searchGrid.dart +++ b/lib/ui/widgets/search/searchGrid.dart @@ -13,6 +13,7 @@ import 'package:flutter/scheduler.dart'; import 'package:flutter/services.dart'; import 'package:provider/provider.dart'; import 'package:Prism/main.dart' as main; +import 'package:Prism/logger/logger.dart'; class SearchGrid extends StatefulWidget { final String query; @@ -97,7 +98,9 @@ class _SearchGridState extends State with TickerProviderStateMixin { refreshHomeKey.currentState?.show(); if (widget.selectedProvider == "WallHaven") { wData.wallsS = []; - wData.getWallsbyQuery(widget.query, main.prefs.get('WHcategories') as int?, + wData.getWallsbyQuery( + widget.query, + main.prefs.get('WHcategories') as int?, main.prefs.get('WHpurity') as int?); } else if (widget.selectedProvider == "Pexels") { pData.wallsPS = []; @@ -222,7 +225,7 @@ class _SearchGridState extends State with TickerProviderStateMixin { animation: offsetAnimation, builder: (buildContext, child) { if (offsetAnimation.value < 0.0) { - debugPrint('${offsetAnimation.value + 8.0}'); + logger.d('${offsetAnimation.value + 8.0}'); } return Padding( padding: index == longTapIndex @@ -302,8 +305,8 @@ class _SearchGridState extends State with TickerProviderStateMixin { widget.selectedProvider, widget.query, index, - pData - .wallsPS[index].src!["medium"], + pData.wallsPS[index] + .src!["medium"], ]); } } @@ -334,7 +337,8 @@ class _SearchGridState extends State with TickerProviderStateMixin { createDynamicLink( pData.wallsPS[index].id!, "Pexels", - pData.wallsPS[index].src!["original"] + pData + .wallsPS[index].src!["original"] .toString(), pData.wallsPS[index].src!["medium"] .toString()); diff --git a/lib/ui/widgets/setups/loadingSetups.dart b/lib/ui/widgets/setups/loadingSetups.dart index 02f393f6..fdfe4a16 100644 --- a/lib/ui/widgets/setups/loadingSetups.dart +++ b/lib/ui/widgets/setups/loadingSetups.dart @@ -3,6 +3,7 @@ import 'package:Prism/ui/widgets/home/core/inheritedScrollControllerProvider.dar import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart'; import 'package:provider/provider.dart'; +import 'package:Prism/logger/logger.dart'; class LoadingSetupCards extends StatefulWidget { const LoadingSetupCards({ @@ -85,7 +86,7 @@ class _LoadingSetupCardsState extends State controller = InheritedDataProvider.of(context)!.scrollController; } } catch (e) { - debugPrint(e.toString()); + logger.d(e.toString()); } return controller != null diff --git a/pubspec.lock b/pubspec.lock index dceebe56..b0c59601 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -886,6 +886,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.2" + pixel_perfect: + dependency: "direct main" + description: + name: pixel_perfect + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" platform: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 6836bdb8..1c05b378 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -12,7 +12,7 @@ publish_to: none # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 2.6.7+69 +version: 2.6.8+70 environment: sdk: '>=2.12.0 <3.0.0' @@ -61,6 +61,7 @@ dependencies: permission_handler: ^7.1.0 photo_view: ^0.11.1 photofilters: ^2.0.1 + pixel_perfect: ^1.1.0 provider: ^4.1.3 purchases_flutter: ^3.2.1 quick_actions: ^0.6.0+1 @@ -104,6 +105,7 @@ flutter: assets: - assets/images/ + - assets/images/ref.jpg - assets/animations/ # To add assets to your application, add an assets section, like this: # assets: