-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Se añadido la Authentication, registro desde el lado back-end y obtie…
…ne el nombre del usuario en la ventana del home
- Loading branch information
Showing
16 changed files
with
377 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" | ||
#include "Generated.xcconfig" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" | ||
#include "Generated.xcconfig" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Uncomment this line to define a global platform for your project | ||
# platform :ios, '9.0' | ||
|
||
# CocoaPods analytics sends network stats synchronously affecting flutter build latency. | ||
ENV['COCOAPODS_DISABLE_STATS'] = 'true' | ||
|
||
project 'Runner', { | ||
'Debug' => :debug, | ||
'Profile' => :release, | ||
'Release' => :release, | ||
} | ||
|
||
def flutter_root | ||
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) | ||
unless File.exist?(generated_xcode_build_settings_path) | ||
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" | ||
end | ||
|
||
File.foreach(generated_xcode_build_settings_path) do |line| | ||
matches = line.match(/FLUTTER_ROOT\=(.*)/) | ||
return matches[1].strip if matches | ||
end | ||
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" | ||
end | ||
|
||
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) | ||
|
||
flutter_ios_podfile_setup | ||
|
||
target 'Runner' do | ||
use_frameworks! | ||
use_modular_headers! | ||
|
||
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) | ||
end | ||
|
||
post_install do |installer| | ||
installer.pods_project.targets.each do |target| | ||
flutter_additional_ios_build_settings(target) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,23 @@ | ||
import 'package:chatapp/src/routes/routes.dart'; | ||
import 'package:chatapp/src/services/auth.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:provider/provider.dart'; | ||
|
||
void main() => runApp(MyApp()); | ||
|
||
class MyApp extends StatelessWidget { | ||
@override | ||
Widget build(BuildContext context) { | ||
return MaterialApp( | ||
debugShowCheckedModeBanner: false, | ||
title: 'Chat App', | ||
routes: appRoutes, | ||
initialRoute: 'users', | ||
return MultiProvider( | ||
providers: [ | ||
ChangeNotifierProvider(create: ( _ ) => AuthService() ) | ||
], | ||
child: MaterialApp( | ||
debugShowCheckedModeBanner: false, | ||
title: 'Chat App', | ||
routes: appRoutes, | ||
initialRoute: 'loading', | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
import 'dart:io'; | ||
|
||
class Environment { | ||
static String apiURL = 'http://192.168.0.22:3000/api'; | ||
static String socketUrl = 'http://192.168.0.22:3000'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:flutter/cupertino.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
|
||
Future<bool> showSimpleAlert( BuildContext context, String title, String subtitle ){ | ||
if( Platform.isAndroid ){ | ||
return showDialog( | ||
context: context, | ||
builder: ( _ ) => AlertDialog( | ||
title: Text('$title'), | ||
content: Text('$subtitle'), | ||
actions: [ | ||
MaterialButton( | ||
child: Text('Aceptar'), | ||
onPressed: () => Navigator.of(context).pop(), | ||
) | ||
], | ||
) | ||
); | ||
} else { | ||
return showDialog( | ||
context: context, | ||
builder: ( _ ) => CupertinoAlertDialog( | ||
title: Text('$title'), | ||
content: Text('$subtitle'), | ||
actions: [ | ||
CupertinoDialogAction( | ||
child: Text('Aceptar'), | ||
onPressed: () => Navigator.of(context).pop(), | ||
) | ||
], | ||
) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import 'dart:convert'; | ||
import 'package:chatapp/src/models/user.dart'; | ||
|
||
LoginResponse loginResponseFromJson(String str) => LoginResponse.fromJson(json.decode(str)); | ||
String loginResponseToJson(LoginResponse data) => json.encode(data.toJson()); | ||
|
||
class LoginResponse { | ||
LoginResponse({ | ||
this.ok, | ||
this.user, | ||
this.token, | ||
}); | ||
|
||
bool ok; | ||
User user; | ||
String token; | ||
|
||
factory LoginResponse.fromJson(Map<String, dynamic> json) => LoginResponse( | ||
ok: json["ok"], | ||
user: User.fromJson(json["user"]), | ||
token: json["token"], | ||
); | ||
|
||
Map<String, dynamic> toJson() => { | ||
"ok": ok, | ||
"user": user.toJson(), | ||
"token": token, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,27 @@ | ||
|
||
class User { | ||
|
||
final bool isOnline; | ||
final String email; | ||
final String name; | ||
final String uid; | ||
|
||
User({ | ||
this.isOnline, | ||
this.email, | ||
this.name, | ||
this.uid | ||
this.isOnline, | ||
this.name, | ||
this.email, | ||
this.uid, | ||
}); | ||
|
||
|
||
bool isOnline; | ||
String name; | ||
String email; | ||
String uid; | ||
|
||
factory User.fromJson(Map<String, dynamic> json) => User( | ||
isOnline: json["isOnline"], | ||
name: json["name"], | ||
email: json["email"], | ||
uid: json["uid"] | ||
); | ||
|
||
Map<String, dynamic> toJson() => { | ||
"isOnline": isOnline, | ||
"name": name, | ||
"email": email, | ||
"uid": uid | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,43 @@ | ||
import 'package:chatapp/src/pages/login.dart'; | ||
import 'package:chatapp/src/pages/users.dart'; | ||
import 'package:chatapp/src/services/auth.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:provider/provider.dart'; | ||
|
||
class LoadingPage extends StatelessWidget { | ||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
|
||
body: FutureBuilder<Object>( | ||
future: checkLoginState( context ), | ||
builder: (context, snapshot) { | ||
return Center( | ||
child: CircularProgressIndicator() | ||
); | ||
} | ||
), | ||
); | ||
} | ||
|
||
Future checkLoginState( BuildContext context ) async { | ||
final AuthService authService = Provider.of<AuthService>(context, listen: false); | ||
final isValidateToken = await authService.isLoggedIn(); | ||
|
||
if( isValidateToken ){ | ||
// TODO: Conectar al socket service | ||
Navigator.of(context).pushReplacement( | ||
PageRouteBuilder( | ||
pageBuilder: ( _, __, ___ ) => UsersPage(), | ||
transitionDuration: Duration(milliseconds: 0) | ||
) | ||
); | ||
} else { | ||
Navigator.of(context).pushReplacement( | ||
PageRouteBuilder( | ||
pageBuilder: ( _, __, ___ ) => LoginPage(), | ||
transitionDuration: Duration(milliseconds: 0) | ||
) | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.