Added internet permission and better message from api call
This commit is contained in:
parent
83393807c7
commit
6fae83674b
|
@ -1,6 +1,8 @@
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.example.rluv">
|
package="com.example.rluv">
|
||||||
<application
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||||
|
<application
|
||||||
android:label="rluv"
|
android:label="rluv"
|
||||||
android:name="${applicationName}"
|
android:name="${applicationName}"
|
||||||
android:icon="@mipmap/ic_launcher">
|
android:icon="@mipmap/ic_launcher">
|
||||||
|
|
|
@ -217,14 +217,21 @@ class _LoginState extends ConsumerState<Login> {
|
||||||
'password': passwordController.text,
|
'password': passwordController.text,
|
||||||
});
|
});
|
||||||
|
|
||||||
final bool success = data?['success'] ?? false;
|
String message = 'Login unsuccessful';
|
||||||
|
bool success = data?['success'] == 'false';
|
||||||
|
if (data != null) {
|
||||||
|
if (data['message'] != null) {
|
||||||
|
message = data['message'];
|
||||||
|
} else if (success) {
|
||||||
|
message = 'Logged in!';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// final bool success = data?['success'] ?? false;
|
||||||
|
printAmber(data);
|
||||||
showSnack(
|
showSnack(
|
||||||
ref: ref,
|
ref: ref,
|
||||||
text: data?['message'] ?? success
|
text: message,
|
||||||
? 'Login successful'
|
|
||||||
: 'Login unsuccessful',
|
|
||||||
type: !success ? SnackType.error : SnackType.success);
|
type: !success ? SnackType.error : SnackType.success);
|
||||||
printAmber(data);
|
|
||||||
} catch (err, st) {
|
} catch (err, st) {
|
||||||
printRed('Error in login: $err\n$st');
|
printRed('Error in login: $err\n$st');
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,8 @@ class _SignupState extends ConsumerState<Signup> {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
text: 'Email: (optional)',
|
text: 'Email:',
|
||||||
|
subtext: '(optional)',
|
||||||
index: 2),
|
index: 2),
|
||||||
generateTextField(
|
generateTextField(
|
||||||
controller: passwordController,
|
controller: passwordController,
|
||||||
|
@ -169,6 +170,7 @@ class _SignupState extends ConsumerState<Signup> {
|
||||||
|
|
||||||
Widget generateTextField({
|
Widget generateTextField({
|
||||||
required String text,
|
required String text,
|
||||||
|
String? subtext,
|
||||||
String? label,
|
String? label,
|
||||||
required int index,
|
required int index,
|
||||||
required TextEditingController controller,
|
required TextEditingController controller,
|
||||||
|
@ -182,9 +184,15 @@ class _SignupState extends ConsumerState<Signup> {
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: Text(
|
child: Column(
|
||||||
text,
|
children: [
|
||||||
style: TextStyle(fontSize: size.width < 350 ? 16 : 20),
|
Text(
|
||||||
|
text,
|
||||||
|
style: TextStyle(fontSize: size.width < 350 ? 16 : 20),
|
||||||
|
),
|
||||||
|
if (subtext != null)
|
||||||
|
Text(subtext, style: const TextStyle(fontSize: 12)),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
|
|
|
@ -21,9 +21,9 @@ class _SettingsScreenState extends ConsumerState<SettingsScreen> {
|
||||||
children: [
|
children: [
|
||||||
const Text('Settings'),
|
const Text('Settings'),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
Text(user!.name),
|
Text(user?.name ?? 'N/A'),
|
||||||
Text("Username: ${user.username ?? 'N/A'}"),
|
Text("Username: ${user?.username ?? 'N/A'}"),
|
||||||
Text("Email: ${user.email ?? 'N/A'}"),
|
Text("Email: ${user?.email ?? 'N/A'}"),
|
||||||
Text("Family Code: ${family?.code ?? 'N/A'}"),
|
Text("Family Code: ${family?.code ?? 'N/A'}"),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
UiButton(
|
UiButton(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user