Skip to content

Commit

Permalink
[video_call]: add connection node selection on login screen
Browse files Browse the repository at this point in the history
  • Loading branch information
YuliaGrigorieva committed May 23, 2024
1 parent d2f0451 commit 2a0d264
Show file tree
Hide file tree
Showing 11 changed files with 185 additions and 62 deletions.
2 changes: 1 addition & 1 deletion video_call/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ android {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.voximplant.flutter.videocall"
// set minSdk to 21 since multidex is enabled by default since this version
minSdkVersion flutter.minSdkVersion
minSdkVersion 21
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
Expand Down
74 changes: 40 additions & 34 deletions video_call/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ PODS:
- FirebaseCoreInternal (~> 10.0)
- GoogleUtilities/Environment (~> 7.8)
- GoogleUtilities/Logger (~> 7.8)
- FirebaseCoreInternal (10.13.0):
- FirebaseCoreInternal (10.25.0):
- "GoogleUtilities/NSData+zlib (~> 7.8)"
- FirebaseInstallations (10.13.0):
- FirebaseInstallations (10.25.0):
- FirebaseCore (~> 10.0)
- GoogleUtilities/Environment (~> 7.8)
- GoogleUtilities/UserDefaults (~> 7.8)
Expand All @@ -36,46 +36,52 @@ PODS:
- Flutter
- flutter_local_notifications (0.0.1):
- Flutter
- flutter_voximplant (3.8.1):
- flutter_voximplant (3.11.1):
- Flutter
- VoxImplantSDK (= 2.46.12)
- GoogleDataTransport (9.2.5):
- VoxImplantSDK (= 2.52.0)
- GoogleDataTransport (9.4.1):
- GoogleUtilities/Environment (~> 7.7)
- nanopb (< 2.30910.0, >= 2.30908.0)
- nanopb (< 2.30911.0, >= 2.30908.0)
- PromisesObjC (< 3.0, >= 1.2)
- GoogleUtilities/AppDelegateSwizzler (7.11.5):
- GoogleUtilities/AppDelegateSwizzler (7.13.3):
- GoogleUtilities/Environment
- GoogleUtilities/Logger
- GoogleUtilities/Network
- GoogleUtilities/Environment (7.11.5):
- GoogleUtilities/Privacy
- GoogleUtilities/Environment (7.13.3):
- GoogleUtilities/Privacy
- PromisesObjC (< 3.0, >= 1.2)
- GoogleUtilities/Logger (7.11.5):
- GoogleUtilities/Logger (7.13.3):
- GoogleUtilities/Environment
- GoogleUtilities/Network (7.11.5):
- GoogleUtilities/Privacy
- GoogleUtilities/Network (7.13.3):
- GoogleUtilities/Logger
- "GoogleUtilities/NSData+zlib"
- GoogleUtilities/Privacy
- GoogleUtilities/Reachability
- "GoogleUtilities/NSData+zlib (7.11.5)"
- GoogleUtilities/Reachability (7.11.5):
- "GoogleUtilities/NSData+zlib (7.13.3)":
- GoogleUtilities/Privacy
- GoogleUtilities/Privacy (7.13.3)
- GoogleUtilities/Reachability (7.13.3):
- GoogleUtilities/Logger
- GoogleUtilities/UserDefaults (7.11.5):
- GoogleUtilities/Privacy
- GoogleUtilities/UserDefaults (7.13.3):
- GoogleUtilities/Logger
- nanopb (2.30909.0):
- nanopb/decode (= 2.30909.0)
- nanopb/encode (= 2.30909.0)
- nanopb/decode (2.30909.0)
- nanopb/encode (2.30909.0)
- GoogleUtilities/Privacy
- nanopb (2.30909.1):
- nanopb/decode (= 2.30909.1)
- nanopb/encode (= 2.30909.1)
- nanopb/decode (2.30909.1)
- nanopb/encode (2.30909.1)
- permission_handler_apple (9.1.1):
- Flutter
- PromisesObjC (2.3.1)
- PromisesObjC (2.4.0)
- shared_preferences_foundation (0.0.1):
- Flutter
- FlutterMacOS
- VoxImplantSDK (2.46.12):
- VoxImplantSDK/Core (= 2.46.12)
- VoxImplantSDK/Core (2.46.12):
- VoxImplantWebRTC (= 93.0.0)
- VoxImplantWebRTC (93.0.0)
- VoxImplantSDK (2.52.0):
- VoxImplantWebRTC (= 112.0.0)
- VoxImplantWebRTC (112.0.0)

DEPENDENCIES:
- firebase_core (from `.symlinks/plugins/firebase_core/ios`)
Expand Down Expand Up @@ -124,22 +130,22 @@ SPEC CHECKSUMS:
firebase_core: 58542d7399889ebdbb034baa72d081e54c5c814d
firebase_messaging: 01a8db2962f81ea190d08db767aba2e7e805e647
FirebaseCore: fa80ad16a62d52f67274b5b88304c3a318bbf9a4
FirebaseCoreInternal: b342e37cd4f5b4454ec34308f073420e7920858e
FirebaseInstallations: b28af1b9f997f1a799efe818c94695a3728c352f
FirebaseCoreInternal: 910a81992c33715fec9263ca7381d59ab3a750b7
FirebaseInstallations: 91950fe859846fff0fbd296180909dd273103b09
FirebaseMessaging: fd93783258c53ae5cdb9b41bf0c51606a677f2d5
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_callkit_voximplant: 9e1128135757ea8a21ae7bbc06ff4a37e906ccc5
flutter_local_notifications: 0c0b1ae97e741e1521e4c1629a459d04b9aec743
flutter_voximplant: 3a9f36552a8fdd6a6708e4027629bf49a807b7ee
GoogleDataTransport: 54dee9d48d14580407f8f5fbf2f496e92437a2f2
GoogleUtilities: 13e2c67ede716b8741c7989e26893d151b2b2084
nanopb: b552cce312b6c8484180ef47159bc0f65a1f0431
flutter_voximplant: f8a0e7ce1af495fe6ecd53233640df972952f43d
GoogleDataTransport: 6c09b596d841063d76d4288cc2d2f42cc36e1e2a
GoogleUtilities: ea963c370a38a8069cc5f7ba4ca849a60b6d7d15
nanopb: d4d75c12cd1316f4a64e3c6963f879ecd4b5e0d5
permission_handler_apple: e76247795d700c14ea09e3a2d8855d41ee80a2e6
PromisesObjC: c50d2056b5253dadbd6c2bea79b0674bd5a52fa4
PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47
shared_preferences_foundation: e2dae3258e06f44cc55f49d42024fd8dd03c590c
VoxImplantSDK: 577259786bc3da6ed3cf3d4ee1a8e08245c19ce6
VoxImplantWebRTC: 8ddd8a63d0c20afa604fec22a2552c32b0371974
VoxImplantSDK: fbc3bfc64cedc98545758717c8395a64edc091bf
VoxImplantWebRTC: 2256a8b9157cc46e1a4c8e0ed5816c5c672d7d5d

PODFILE CHECKSUM: 4e8f8b2be68aeea4c0d5beb6ff1e79fface1d048

COCOAPODS: 1.15.0
COCOAPODS: 1.15.2
4 changes: 2 additions & 2 deletions video_call/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin\n";
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
Expand All @@ -218,7 +218,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build\n";
};
/* End PBXShellScriptBuildPhase section */

Expand Down
3 changes: 2 additions & 1 deletion video_call/lib/screens/login/bloc/login_bloc.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/// Copyright (c) 2011-2020, Zingaya, Inc. All rights reserved.
import 'dart:io';
import 'package:video_call/screens/login/login.dart';
import 'package:video_call/services/auth_service.dart';
Expand Down Expand Up @@ -42,8 +41,10 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> {
Future<void> _loginWithPassword(
LoginWithPassword event, Emitter<LoginState> emit) async {
emit(LoginInProgress());
VINode node = VINode.values.byName(event.node);
try {
await _authService.loginWithPassword(
node,
'${event.username}.voximplant.com',
event.password,
);
Expand Down
6 changes: 4 additions & 2 deletions video_call/lib/screens/login/bloc/login_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ class LoadLastUser extends LoginEvent {}
class LoginWithPassword extends LoginEvent {
final String username;
final String password;
final String node;

const LoginWithPassword({required this.username, required this.password});
const LoginWithPassword(
{required this.username, required this.password, required this.node});

@override
List<Object> get props => [username, password];
List<Object> get props => [username, password, node];

@override
String toString() => 'LoginWithPassword: '
Expand Down
49 changes: 46 additions & 3 deletions video_call/lib/screens/login/login_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@ import 'package:video_call/theme/voximplant_theme.dart';
import 'package:video_call/utils/navigation_helper.dart';
import 'package:video_call/widgets/widgets.dart';

const List<String> nodes = <String>[
'Node1',
'Node2',
'Node3',
'Node4',
'Node5',
'Node6',
'Node7',
'Node8',
'Node9',
'Node10'
];

class LoginPage extends StatefulWidget {
static const routeName = '/login';

Expand All @@ -22,6 +35,8 @@ class _LoginPageState extends State<LoginPage> {

bool _isUsernameValid = true;
bool _isPasswordValid = true;
bool _isNodeSelected = false;
String? _node;

@override
void initState() {
Expand All @@ -38,9 +53,18 @@ class _LoginPageState extends State<LoginPage> {

@override
Widget build(BuildContext context) {
void _login() => _bloc.add(LoginWithPassword(
username: _usernameController.text,
password: _passwordController.text));
void _login() {
final node = _node;
if (node != null) {
_bloc.add(
LoginWithPassword(
username: _usernameController.text,
password: _passwordController.text,
node: node,
),
);
}
}

void _handleLoginFailed(String errorCode, String errorDescription) {
if (errorCode == 'ERROR_INVALID_USERNAME') {
Expand Down Expand Up @@ -89,6 +113,25 @@ class _LoginPageState extends State<LoginPage> {
validator: (_) =>
_isPasswordValid ? null : 'Invalid password',
),
_isNodeSelected
? Container()
: const Padding(
padding: EdgeInsets.only(top: 5, left: 20),
child: Align(
alignment: Alignment.centerLeft,
child: Text(
"Connection Node is required",
style: TextStyle(color: VoximplantColors.red),
))),
Widgets.dropdown(
items: nodes,
onChange: (String? node) {
setState(() {
_isNodeSelected = true;
_node = node;
});
},
value: _node),
Widgets.maxWidthRaisedButton(
text: 'Log in',
onPressed: _login,
Expand Down
6 changes: 5 additions & 1 deletion video_call/lib/screens/main/bloc/main_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class MainBloc extends Bloc<MainEvent, MainState> {
final CallKitService? _callKitService =
Platform.isIOS ? CallKitService() : null;

bool _logoutRequested = false;
late StreamSubscription _callStateSubscription;

MainBloc()
Expand Down Expand Up @@ -52,13 +53,16 @@ class MainBloc extends Bloc<MainEvent, MainState> {
}

Future<void> _logout(LogOut event, Emitter<MainState> emit) async {
_logoutRequested = true;
await _authService.logout();
emit(const LoggedOut(networkIssues: false));
}

Future<void> _connectionClosed(
ConnectionClosed event, Emitter<MainState> emit) async {
emit(const LoggedOut(networkIssues: true));
if (!_logoutRequested) {
emit(const LoggedOut(networkIssues: true));
}
}

void _receivedIncomingCall(
Expand Down
Loading

0 comments on commit 2a0d264

Please sign in to comment.