Skip to content

Commit

Permalink
Merge pull request #180 from quiet-programmer/mobile_app_dev
Browse files Browse the repository at this point in the history
updated packages and migrated app to Flutter 2.0
  • Loading branch information
sudo-which-qp authored Jul 18, 2021
2 parents baac4a3 + 766552a commit fbe4d9d
Show file tree
Hide file tree
Showing 13 changed files with 113 additions and 78 deletions.
2 changes: 1 addition & 1 deletion ndole/bond_app/lib/auth/wrapper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:provider/provider.dart';
class Wrapper extends StatelessWidget {
@override
Widget build(BuildContext context) {
final user = Provider.of<UserModels>(context);
final user = Provider.of<UserModels?>(context);
if (user == null) {
return GoogleSignInScreen();
} else {
Expand Down
12 changes: 6 additions & 6 deletions ndole/bond_app/lib/models/user_models.dart
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
class UserModels {
final String uid;
final String? uid;

UserModels({this.uid});
}

class UsersDetailsModel {
final String uid;
final String name;
final String username;
final String email;
final String photo;
final String? uid;
final String? name;
final String? username;
final String? email;
final String? photo;

UsersDetailsModel({
this.uid,
Expand Down
21 changes: 11 additions & 10 deletions ndole/bond_app/lib/providers/theme_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,34 @@ import 'package:shared_preferences/shared_preferences.dart';

class ThemeProvider with ChangeNotifier {
final String key = 'appTheme';
SharedPreferences _pref;
bool _mTheme;
SharedPreferences? _pref;
bool? _mTheme;

bool get mTheme => _mTheme;
bool get mTheme => _mTheme!;

ThemeProvider() {
_mTheme = false;
_loadFromPref();
}

_initPrefs() async {
if (_pref == null) _pref = await SharedPreferences.getInstance();
Future _initPrefs() async {
await SharedPreferences.getInstance();
}

_loadFromPref() async {
Future _loadFromPref() async {
await _initPrefs();
_mTheme = _pref.getBool(key) ?? false;

_mTheme = _pref!.getBool(key) ?? false;
notifyListeners();
}

_saveToPref() async {
Future _saveToPref() async {
await _initPrefs();
_pref.setBool(key, _mTheme);
_pref!.setBool(key, _mTheme!);
}

void checkTheme() {
_mTheme = !_mTheme;
_mTheme = !_mTheme!;
_saveToPref();
notifyListeners();
}
Expand Down
3 changes: 2 additions & 1 deletion ndole/bond_app/lib/screens/add_partner.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:bond_app/utils/default_button.dart';
// import 'package:bond_app/utils/firebase_user_call.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
Expand Down Expand Up @@ -36,7 +37,7 @@ class _AddPartnerScreenState extends State<AddPartnerScreen> {
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(80),
image: DecorationImage(
image: NetworkImage('${_auth.currentUser.photoURL}'),
image: NetworkImage('${_auth.currentUser!.photoURL}'),
fit: BoxFit.cover,
),
),
Expand Down
23 changes: 11 additions & 12 deletions ndole/bond_app/lib/screens/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class _HomeScreenState extends State<HomeScreen> {

final TextEditingController _email = TextEditingController();

showAddPartnerDialog() {
Dialog? showAddPartnerDialog() {
showDialog(
context: context,
builder: (_) {
Expand All @@ -32,10 +32,10 @@ class _HomeScreenState extends State<HomeScreen> {
TextFormField(
controller: _email,
validator: (val) {
if (val.isEmpty) {
return 'Please enter an Email';
} else {
if (val != null && val.isNotEmpty) {
return null;
} else {
return 'Please enter an Email';
}
},
decoration: InputDecoration(
Expand All @@ -57,7 +57,7 @@ class _HomeScreenState extends State<HomeScreen> {
TextButton(
onPressed: () {
var form = _formKey.currentState;
if (form.validate()) {
if (form != null && form.validate()) {
Navigator.pop(context);
}
},
Expand All @@ -70,11 +70,10 @@ class _HomeScreenState extends State<HomeScreen> {
}

// function to get only first name
String getOnlyFirstName() {
var mainFromFirebase = _auth.currentUser.displayName;
String? getOnlyFirstName() {
String mainFromFirebase = _auth.currentUser!.displayName.toString();
String firstUserName =
mainFromFirebase.substring(0, mainFromFirebase.indexOf(' '));

return firstUserName;
}

Expand Down Expand Up @@ -105,7 +104,7 @@ class _HomeScreenState extends State<HomeScreen> {
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(80),
border: Border.all(
color: Colors.grey[200],
color: Colors.grey.shade200,
style: BorderStyle.solid,
width: 8,
),
Expand Down Expand Up @@ -143,19 +142,19 @@ class _HomeScreenState extends State<HomeScreen> {
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(80),
border: Border.all(
color: Colors.grey[200],
color: Colors.grey.shade200,
style: BorderStyle.solid,
width: 8,
),
image: DecorationImage(
image: NetworkImage(
'${_auth.currentUser.photoURL}'),
'${_auth.currentUser!.photoURL}'),
fit: BoxFit.cover,
),
),
),
Text(
getOnlyFirstName(),
getOnlyFirstName().toString(),
style: GoogleFonts.roboto(
fontSize: 20,
),
Expand Down
2 changes: 1 addition & 1 deletion ndole/bond_app/lib/screens/tab_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class TabView extends StatefulWidget {
}

class _TabViewState extends State<TabView> {
final List<Map<String, Object>> _pages = [
final List<Map<String, Widget>> _pages = [
{
// we will do the checking for if the user has a partner or not
// then push to to HomeScreen() else Push to AddPartnerScreen()
Expand Down
8 changes: 4 additions & 4 deletions ndole/bond_app/lib/screens/user_profile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ class _UserProfileState extends State<UserProfile> {
child: CircleAvatar(
backgroundColor: Colors.grey[200],
backgroundImage:
NetworkImage('${_auth.currentUser.photoURL}'),
NetworkImage('${_auth.currentUser!.photoURL}'),
// child: ,
),
),
SizedBox(
height: 30,
),
Text(
'${_auth.currentUser.displayName}',
'${_auth.currentUser!.displayName}',
style: GoogleFonts.nunito(
fontSize: 20,
),
Expand Down Expand Up @@ -91,7 +91,7 @@ class _UserProfileState extends State<UserProfile> {
),
),
Text(
'${_auth.currentUser.displayName}',
'${_auth.currentUser!.displayName}',
style: GoogleFonts.nunito(
fontSize: 18,
),
Expand All @@ -113,7 +113,7 @@ class _UserProfileState extends State<UserProfile> {
),
),
Text(
'${_auth.currentUser.email}',
'${_auth.currentUser!.email}',
style: GoogleFonts.nunito(
fontSize: 18,
),
Expand Down
8 changes: 4 additions & 4 deletions ndole/bond_app/lib/services/api_request.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ class ApiRequest {
var req = await http.post(
Uri.parse(authUser),
body: {
'uid': _auth.currentUser.uid,
'name': _auth.currentUser.displayName,
'uid': _auth.currentUser!.uid,
'name': _auth.currentUser!.displayName,
'username': '',
'photo': _auth.currentUser.photoURL,
'email': _auth.currentUser.email,
'photo': _auth.currentUser!.photoURL,
'email': _auth.currentUser!.email,
},
);
var res = json.decode(req.body);
Expand Down
20 changes: 13 additions & 7 deletions ndole/bond_app/lib/services/auth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,39 @@ class AuthService {
final FirebaseAuth _auth = FirebaseAuth.instance;

//create user object based on firebase user
UserModels _userFromFirebaseUser(User user) {
UserModels? _userFromFirebaseUser(User? user) {
return user != null ? UserModels(uid: user.uid) : null;
}

//auth change user stream
Stream<UserModels> get user {
Stream<UserModels?> get user {
return _auth.authStateChanges().map(_userFromFirebaseUser);
}

String? userUID() {
User? user = _auth.currentUser;
if (user != null) {
return user.uid;
}
}

//sign in with Google
Future signUpWithGoogle(context) async {
try {
// Trigger the authentication flow
final GoogleSignInAccount googleUser = await GoogleSignIn().signIn();
GoogleSignInAccount? googleUser = await GoogleSignIn().signIn();

// Obtain the auth details from the request
final GoogleSignInAuthentication googleAuth =
await googleUser.authentication;
GoogleSignInAuthentication? googleAuth = await googleUser!.authentication;

// Create a new credential
final GoogleAuthCredential credential = GoogleAuthProvider.credential(
final credential = GoogleAuthProvider.credential(
accessToken: googleAuth.accessToken,
idToken: googleAuth.idToken,
);

await _auth.signInWithCredential(credential).then((result) {
User user = result.user;
User? user = result.user;
return _userFromFirebaseUser(user);
}).catchError((err) {
print('${err.toString()}.................');
Expand Down
17 changes: 7 additions & 10 deletions ndole/bond_app/lib/utils/default_button.dart
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
import 'package:bond_app/const_values.dart';
import 'package:flutter/material.dart';

class DefaultButton extends StatefulWidget {
final String title;
final Function onPress;
class DefaultButton extends StatelessWidget {
final String? title;
final VoidCallback? onPress;

DefaultButton({
Key? key,
@required this.title,
@required this.onPress,
});
@override
_DefaultButtonState createState() => _DefaultButtonState();
}
}) : super(key: key);

class _DefaultButtonState extends State<DefaultButton> {
@override
Widget build(BuildContext context) {
return Container(
Expand All @@ -25,9 +22,9 @@ class _DefaultButtonState extends State<DefaultButton> {
),
child: TextButton(
style: ButtonStyle(),
onPressed: widget.onPress,
onPressed: onPress,
child: Text(
widget.title,
title!,
style: TextStyle(
color: Colors.white,
),
Expand Down
31 changes: 31 additions & 0 deletions ndole/bond_app/lib/utils/firebase_user_call.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// import 'package:firebase_auth/firebase_auth.dart';

// final FirebaseAuth _auth = FirebaseAuth.instance;

// String? userUID() {
// User? user = _auth.currentUser;
// if (user != null) {
// return user.uid;
// }
// }

// String? userImage() {
// User? user = _auth.currentUser;
// if (user != null) {
// return user.photoURL;
// }
// }

// String? userName() {
// User? user = _auth.currentUser;
// if (user != null) {
// return user.displayName;
// }
// }

// String? userEmail() {
// User? user = _auth.currentUser;
// if (user != null) {
// return user.email;
// }
// }
Loading

2 comments on commit fbe4d9d

@vercel
Copy link

@vercel vercel bot commented on fbe4d9d Jul 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

bond-api – ./okok/node-api

bond-api-fotiemconstant.vercel.app
bond-api.vercel.app
bond-api-git-main-fotiemconstant.vercel.app

@vercel
Copy link

@vercel vercel bot commented on fbe4d9d Jul 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

bond – ./eru/

bond-git-main-fotiemconstant.vercel.app
bond-fotiemconstant.vercel.app
bond-nu.vercel.app

Please sign in to comment.