Skip to content

Commit

Permalink
Merge pull request #160 from DAB-Co/1.0.2+4
Browse files Browse the repository at this point in the history
1.0.2+4
  • Loading branch information
atillaturkmen authored May 4, 2022
2 parents c94679a + 93d9bd2 commit c369294
Show file tree
Hide file tree
Showing 18 changed files with 268 additions and 142 deletions.
1 change: 1 addition & 0 deletions lib/config/app_url.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class AppUrl {
static const String topPreferences = apiUrl + "/top_preferences";
static const String updateProfilePic = apiUrl + "/update_profile_picture";
static const String getLanguages = apiUrl + "/get_languages";
static const String deleteAccount = apiUrl + "/delete_account";

static const String suggestion = baseURL + "/suggestion";

Expand Down
33 changes: 33 additions & 0 deletions lib/network/delete_account.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import 'dart:convert';

import 'package:http/http.dart';
import 'package:jam/config/app_url.dart';
import 'package:jam/providers/user_provider.dart';
import 'package:jam/widgets/show_snackbar.dart';

import '../main.dart';

/// Delete Account Call, returns answer from server,
/// null if could not connect
Future<String?> deleteAccountCall(String userId, String password) async {
final Map<String, dynamic> dataToSend = {
"user_id": userId,
"password": password,
};
try {
var response = await post(
Uri.parse(AppUrl.deleteAccount),
headers: {'Content-Type': 'application/json; charset=UTF-8'},
body: json.encode(dataToSend),
);
if (response.body == "Wrong api token") {
print("wrong api token in delete account call");
logout();
showSnackBar(navigatorKey.currentContext!, "Wrong api token");
}
return response.body;
} catch (err) {
print(err);
return null;
}
}
6 changes: 6 additions & 0 deletions lib/network/network_call.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import 'dart:convert';

import 'package:http/http.dart';
import 'package:jam/providers/user_provider.dart';
import 'package:jam/widgets/show_snackbar.dart';

import '../main.dart';

/// Can be used with api calls that return OK on success.
/// Returns true on success
Expand All @@ -16,6 +20,8 @@ Future<bool> networkCall(Map<String, dynamic> dataToSend, String apiUrl) async {
}
if (response.body == "Wrong api token") {
print("wrong api token in $apiUrl call");
logout();
showSnackBar(navigatorKey.currentContext!, "Wrong api token");
return false;
}
return false;
Expand Down
6 changes: 6 additions & 0 deletions lib/network/wake.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ Future<Map<String, dynamic>?> wakeRequest(
return null;
}
Map<String, dynamic> decoded = jsonDecode(response.body);
var smallPic = decoded["small_profile_picture"];
if (smallPic != null) {
Uint8List smallPicture = Uint8List.fromList(json.decode(smallPic).cast<int>());
saveSmallPicture(smallPicture, userId);
}

Map<String, dynamic> rawFriends = decoded["friends"];
result["refresh_token_expired"] = decoded["refresh_token_expired"];
print("raw friends length:");
Expand Down
6 changes: 4 additions & 2 deletions lib/pages/dm.dart
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,10 @@ class _DMState extends State<DM> with WidgetsBindingObserver {
},
);
AlertDialog alertDialog = alert(
"Do you really want to block $otherUsername?", blockButton,
content: "You won't be able to receive messages from $otherUsername.");
"Do you really want to block $otherUsername?",
blockButton,
content: Text("You won't be able to receive messages from $otherUsername."),
);

void _handleThreeDotClick(String value) {
switch (value) {
Expand Down
66 changes: 66 additions & 0 deletions lib/pages/explanation.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import 'package:flutter/material.dart';
import 'package:jam/config/routes.dart';

class Explanation extends StatelessWidget {
@override
Widget build(BuildContext context) {
TextStyle style = TextStyle(
color: Colors.white,
fontSize: 20,
);
return Scaffold(
backgroundColor: Color(0xFFFF66C4),
body: Padding(
padding:
const EdgeInsets.only(top: 70, bottom: 70, left: 50, right: 50),
child: Column(
children: [
Container(
height: 200,
width: 200,
decoration: BoxDecoration(
image: DecorationImage(
fit: BoxFit.contain,
image: AssetImage('assets/icon/icon.png'),
),
),
),
SizedBox(height: 20),
SingleChildScrollView(
child: Column(
children: [
Text(
"\tWelcome to Jam! This is an app that helps people with same music taste get together via spotify. The matches are made daily at the same time for everyone so you won't get a match until midnight GMT. We will send a notification to remind you. Have fun!",
style: style,
),
],
),
),
Expanded(
child: Align(
alignment: Alignment.bottomRight,
child: RawMaterialButton(
splashColor: Colors.white,
shape: CircleBorder(),
fillColor: Colors.white,
child: Icon(
Icons.check,
color: Colors.grey,
size: 50,
),
onPressed: () {
Navigator.pushNamedAndRemoveUntil(
context,
chatLanguages,
(Route<dynamic> route) => false,
);
},
),
),
),
],
),
),
);
}
}
8 changes: 7 additions & 1 deletion lib/pages/forms/register.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:jam/pages/explanation.dart';
import 'package:jam/widgets/app_bar.dart';
import 'package:jam/widgets/loading.dart';
import 'package:jam/widgets/show_snackbar.dart';
Expand Down Expand Up @@ -92,7 +93,12 @@ class _RegisterState extends State<Register> {
User? user = response['user'];
Provider.of<UserProvider>(context, listen: false)
.setUser(user, context);
Navigator.pushNamedAndRemoveUntil(context, routes.chatLanguages, (Route<dynamic> route) => false);
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(
builder: (BuildContext context) => Explanation()),
(route) => false,
);
} else {
showSnackBar(context, response['message']);
}
Expand Down
43 changes: 18 additions & 25 deletions lib/pages/homepage.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:jam/pages/kebab_menu/read_log.dart';
import 'package:jam/providers/message_provider.dart';
import 'package:jam/providers/unread_message_counter.dart';
import 'package:jam/util/local_notification.dart';
Expand Down Expand Up @@ -34,14 +33,6 @@ class _HomepageState extends State<Homepage> {
case "Contact Us":
Navigator.pushNamed(context, routes.contactUs);
break;
case "Logs":
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ReadLog(),
),
);
break;
}
}

Expand Down Expand Up @@ -99,7 +90,7 @@ class _HomepageState extends State<Homepage> {
PopupMenuButton<String>(
onSelected: _handleThreeDotClick,
itemBuilder: (BuildContext context) {
return {"Contact Us", 'About', 'Logs'}.map((String choice) {
return {"Contact Us", 'About'}.map((String choice) {
return PopupMenuItem<String>(
value: choice,
child: Text(choice),
Expand Down Expand Up @@ -150,22 +141,24 @@ class _HomepageState extends State<Homepage> {
),
),
Divider(color: Colors.grey),
FutureBuilder(
future: Provider.of<MessageProvider>(context, listen: false).init(
Provider.of<UnreadMessageProvider>(context, listen: false),
user,
context,
Expanded(
child: FutureBuilder(
future: Provider.of<MessageProvider>(context, listen: false).init(
Provider.of<UnreadMessageProvider>(context, listen: false),
user,
context,
),
builder: (context, snapshot) {
switch (snapshot.connectionState) {
case ConnectionState.none:
case ConnectionState.waiting:
print("messages future builder waiting");
return Center(child: CircularProgressIndicator());
default:
return messagesList(user, context);
}
},
),
builder: (context, snapshot) {
switch (snapshot.connectionState) {
case ConnectionState.none:
case ConnectionState.waiting:
print("messages future builder waiting");
return Center(child: CircularProgressIndicator());
default:
return messagesList(user, context);
}
},
),
],
),
Expand Down
4 changes: 2 additions & 2 deletions lib/pages/kebab_menu/about.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class About extends StatelessWidget {
onTap: _launchEmail,
child: FittedBox(
child: Text(
"dabco5317@gmail.com",
"overlapco0@gmail.com",
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 30,
Expand All @@ -64,7 +64,7 @@ class About extends StatelessWidget {
}

void _launchEmail() async {
var _url = "mailto:dabco5317@gmail.com?subject=Jam";
var _url = "mailto:overlapco0@gmail.com?subject=Jam";
if (!await launch(_url)) throw 'Could not launch $_url';
}
}
43 changes: 0 additions & 43 deletions lib/pages/kebab_menu/read_log.dart

This file was deleted.

21 changes: 13 additions & 8 deletions lib/pages/profile/chat_language.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,20 @@ class _ChatLanguageState extends State<ChatLanguage> {
Provider.of<UserProvider>(context, listen: false).addLanguage(iso);
});
} else if (success == 2) {
showSnackBar(
context, "It looks like you have already selected your languages");
List<String>? langs = await getLanguagesCall(user.id!, user.token!, user.id!);
showSnackBar(context,
"It looks like you have already selected your languages");
List<String>? langs =
await getLanguagesCall(user.id!, user.token!, user.id!);
if (langs != null) {
setState(() {
if (ModalRoute.of(context)!.isFirst) {
okVisible = true;
}
Provider.of<UserProvider>(context, listen: false).overrideLanguages(langs);
Provider.of<UserProvider>(context, listen: false)
.overrideLanguages(langs);
});
}
}
else {
} else {
showSnackBar(
context, "Could not add language, check your connection");
}
Expand Down Expand Up @@ -179,8 +180,12 @@ class _ChatLanguageState extends State<ChatLanguage> {
color: Colors.pinkAccent,
),
SizedBox(height: 10),
const Text("You don't have any language preference."
"You have to select at least one language in order to match with other people."),
const Text(
"Choose the languages you can speak.\n\n"
"You have to select at least one language in order to match with other people.",
style: TextStyle(fontSize: 15),
textAlign: TextAlign.center,
),
],
)
: Container(
Expand Down
Loading

0 comments on commit c369294

Please sign in to comment.