Skip to content

Commit

Permalink
Merge pull request #2 from redevRx/agora_call
Browse files Browse the repository at this point in the history
Agora call
  • Loading branch information
redevrx authored Feb 8, 2021
2 parents f7ad8bd + 04fb1cd commit 0c8aca8
Show file tree
Hide file tree
Showing 27 changed files with 1,479 additions and 355 deletions.
3 changes: 2 additions & 1 deletion .packages
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Generated by pub on 2021-02-03 20:56:35.380951.
# Generated by pub on 2021-02-06 15:15:29.158648.
_fe_analyzer_shared:file:///D:/Programs/ProgrammingLanguage/dart-sdk/flutter/.pub-cache/hosted/pub.dartlang.org/_fe_analyzer_shared-12.0.0/lib/
agora_rtc_engine:file:///D:/Programs/ProgrammingLanguage/dart-sdk/flutter/.pub-cache/hosted/pub.dartlang.org/agora_rtc_engine-1.0.15/lib/
analyzer:file:///D:/Programs/ProgrammingLanguage/dart-sdk/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-0.40.6/lib/
args:file:///D:/Programs/ProgrammingLanguage/dart-sdk/flutter/.pub-cache/hosted/pub.dartlang.org/args-1.6.0/lib/
async:file:///D:/Programs/ProgrammingLanguage/dart-sdk/flutter/.pub-cache/hosted/pub.dartlang.org/async-2.5.0-nullsafety.1/lib/
Expand Down
9 changes: 9 additions & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ android {

buildTypes {
release {
minifyEnabled true

shrinkResources true

proguardFiles getDefaultProguardFile(
'proguard-android-optimize.txt'),
'proguard-rules.pro'


// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
Expand Down
8 changes: 8 additions & 0 deletions android/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#Flutter Wrapper
-keep class io.flutter.app.** { *; }
-keep class io.flutter.plugin.** { *; }
-keep class io.flutter.util.** { *; }
-keep class io.flutter.view.** { *; }
-keep class io.flutter.** { *; }
-keep class io.flutter.plugins.** { *; }
-keep class io.agora.**{*;}
13 changes: 13 additions & 0 deletions app.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import 'dart:convert';

import 'package:http/http.dart' as http;

void main() async {
await http
.get(
"http://172.19.128.1:8080/resocial/api/v1/generate/token?channelName=redev&uid=0&role=publisher&expireTime=3600")
.then((token) {
Map t = jsonDecode(token.body);
print('${t['token']}');
}).catchError((e) => print(e));
}
3 changes: 1 addition & 2 deletions doc.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
there are bug like
- bug unfocus textfield
- login with facebook and google apple
-bug show notify chat
-remove comment and edit
- group freind notify
- disable request notify
Expand Down
29 changes: 19 additions & 10 deletions lib/Login/screen/login_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -230,30 +230,39 @@ class loginScreen extends StatelessWidget {
SizedBox(
height: 16.0,
),
Padding(
Container(
width: double.infinity,
padding: const EdgeInsets.symmetric(horizontal: 100.0),
child: Row(
children: [
InkWell(
onTap: () => loginBloc.add(onLoginWithGoogle()),
child: Container(
width: 42.0,
height: 42.0,
padding: const EdgeInsets.all(4.0),
child: ClipRRect(
child: Image.asset("assets/icons/google.png"),
child: Image.asset(
"assets/icons/google.png",
),
)),
),
SizedBox(
width: 32.0,
),
InkWell(
// onTap: () => loginBloc.add(onLoginWithFacebook()),
child: Container(
width: 42.0,
padding: const EdgeInsets.all(4.0),
child: ClipRRect(
child: Image.asset("assets/icons/facebook.png"),
)),
Expanded(
child: InkWell(
// onTap: () => loginBloc.add(onLoginWithFacebook()),
child: Container(
width: 42.0,
height: 42.0,
padding: const EdgeInsets.all(4.0),
child: ClipRRect(
child: Image.asset(
"assets/icons/facebook.png",
),
)),
),
),
],
),
Expand Down
11 changes: 7 additions & 4 deletions lib/Profile/AddProfile/screen/add_info_profile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ import 'dart:io';
class AddProfile extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: BlocProvider(
create: (context) => AddProfileBloc(),
child: addProfile(),
return WillPopScope(
onWillPop: () => Future(() => false),
child: Scaffold(
body: BlocProvider(
create: (context) => AddProfileBloc(),
child: addProfile(),
),
),
);
}
Expand Down
57 changes: 57 additions & 0 deletions lib/call/bloc/call_bloc.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import 'dart:async';

import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:socialapp/call/bloc/call_event.dart';
import 'package:socialapp/call/bloc/call_state.dart';
import 'package:socialapp/call/repository/call_agora_repository.dart';

class CallBloc extends Bloc<CallEvent, CallState> {
CallBloc(CallState initialState) : super(CallInitialState());

//call repository
CallAgoraRepository _callAgoraRepository;

//observer call info
StreamSubscription _callStreamSubscription;

@override
Stream<CallState> mapEventToState(CallEvent event) async* {
if (event is OnCallStreamStating) {
yield* onLoadCallStream(event);
}
if (event is OnCallStreamStated) {
yield OnCallStreamSuccess(callModel: event.callModel);
}
if (event is OnStartDialEvent) {
_callAgoraRepository.dial(
channelName: event.channelName,
context: event.context,
receiverId: event.receiverId,
senderId: event.senderId,
type: event.type);
}
}

/**
*start laod dial info
if has data give to go pickUp Screen
then go to home page screen
*/
@override
Stream<CallState> onLoadCallStream(OnCallStreamStating event) async* {
try {
_callStreamSubscription?.cancel();
_callStreamSubscription =
_callAgoraRepository.CallStream(uid: event.uid).listen((call) {
if (call != null) {
print("dial info not null");
add(OnCallStreamStated(callModel: call));
} else {
print("dial info null");
}
});
} catch (e) {
print("dial info null error :$e");
}
}
}
43 changes: 43 additions & 0 deletions lib/call/bloc/call_event.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import 'package:flutter/cupertino.dart';
import 'package:socialapp/call/model/call_model.dart';

abstract class CallEvent {}

/**
event call stream if call when there is dial to
current
*/
class OnCallStreamStating extends CallEvent {
final String uid;

OnCallStreamStating({this.uid});
}

/**
this method will call when load data call info success
will work from OnCallStreamStating
*/
class OnCallStreamStated extends CallEvent {
final CallModel callModel;

OnCallStreamStated({this.callModel});
}

/**
this method will call when start dial to you
freind
*/
class OnStartDialEvent extends CallEvent {
final BuildContext context;
final String senderId;
final String receiverId;
final String channelName;
final bool type;

OnStartDialEvent(
{this.context,
this.senderId,
this.receiverId,
this.channelName,
this.type});
}
24 changes: 24 additions & 0 deletions lib/call/bloc/call_state.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import 'package:equatable/equatable.dart';
import 'package:socialapp/call/model/call_model.dart';

abstract class CallState extends Equatable {}

//initial state
//return null value
class CallInitialState extends CallState {
@override
// TODO: implement props
List<Object> get props => [];
}

/**
this event will return result call stream
*/
class OnCallStreamSuccess extends CallState {
CallModel callModel;

OnCallStreamSuccess({this.callModel});
@override
// TODO: implement props
List<Object> get props => [this.callModel];
}
1 change: 1 addition & 0 deletions lib/call/config/agora_config.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
const String APP_ID = "48ae18e6f9834a76b6c9dabc9f390037";
58 changes: 58 additions & 0 deletions lib/call/model/call_model.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import 'dart:collection';

class CallModel {
String callId;
String callName;
String callPic;
String receiverName;
String receiverId;
String receiverPic;
String channelName;
String token;
bool typeCall;
//fasle is voic call true is video call
bool hasDialled;

CallModel(
{this.callId,
this.callName,
this.callPic,
this.receiverName,
this.receiverId,
this.receiverPic,
this.channelName,
this.token,
this.typeCall,
this.hasDialled});

//to map
Map<String, dynamic> toMap(CallModel call) {
Map<String, dynamic> callMap = HashMap();
callMap["caller_id"] = call.callId;
callMap["caller_name"] = call.callName;
callMap["caller_pic"] = call.callPic;
callMap["receiver_id"] = call.receiverId;
callMap["receiver_name"] = call.receiverName;
callMap["receiver_pic"] = call.receiverPic;
callMap["channel_id"] = call.channelName;
callMap["token"] = call.token;
callMap["type_call"] = call.typeCall;
callMap["has_dialled"] = call.hasDialled;
return callMap;
}

// String get hasDialled => this.hasDialled;

CallModel.formMap(Map<String, dynamic> callMap) {
this.callId = callMap["caller_id"];
this.callName = callMap["caller_name"];
this.callPic = callMap["caller_pic"];
this.receiverId = callMap["receiver_id"];
this.receiverName = callMap["receiver_name"];
this.receiverPic = callMap["receiver_pic"];
this.channelName = callMap["channel_id"];
this.token = callMap["token"];
this.typeCall = callMap["type_call"];
this.hasDialled = callMap["has_dialled"];
}
}
19 changes: 19 additions & 0 deletions lib/call/permission.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import 'package:permission_handler/permission_handler.dart';

class Permissions {
static Future<bool> checkVideoAndMicroPhonegrant() async {
Map<Permission, PermissionStatus> status =
await [Permission.camera, Permission.microphone].request();

//case user grant permission
if (status[Permission.camera].isGranted &&
status[Permission.microphone].isGranted) {
return true;
}

if (status[Permission.camera].isUndetermined ||
status[Permission.microphone].isUndetermined) {
return false;
}
}
}
Loading

0 comments on commit 0c8aca8

Please sign in to comment.