Skip to content

Commit

Permalink
ios local test
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacakakpo1 committed Sep 25, 2024
1 parent 97c8829 commit 9a697a9
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 8 deletions.
22 changes: 22 additions & 0 deletions .lh/lib/view/screen/home_screen.dart.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"sourceFile": "lib/view/screen/home_screen.dart",
"activeCommit": 0,
"commits": [
{
"activePatchIndex": 1,
"patches": [
{
"date": 1724423596843,
"content": "Index: \n===================================================================\n--- \n+++ \n"
},
{
"date": 1724423713914,
"content": "Index: \n===================================================================\n--- \n+++ \n@@ -22,9 +22,10 @@\n \n @override\n void initState() {\n super.initState();\n- destinationController.text = 'isaac81763';\n+\n+ destinationController.text = \"isaac81763\";\n }\n \n void _observeResponses() {\n Provider.of<MainViewModel>(context, listen: true).observeResponses();\n"
}
],
"date": 1724423596843,
"name": "Commit-0",
"content": "import 'package:flutter/material.dart';\nimport 'package:telnyx_flutter_webrtc/main_view_model.dart';\nimport 'package:provider/provider.dart';\nimport 'package:logger/logger.dart';\nimport 'package:telnyx_flutter_webrtc/view/screen/call_screen.dart';\nimport 'package:telnyx_flutter_webrtc/view/widgets/invitation_widget.dart';\n\nclass HomeScreen extends StatefulWidget {\n const HomeScreen({Key? key, required this.title}) : super(key: key);\n final String title;\n\n @override\n State<HomeScreen> createState() => _HomeScreenState();\n}\n\nclass _HomeScreenState extends State<HomeScreen> {\n final logger = Logger();\n TextEditingController destinationController = TextEditingController();\n\n bool invitation = false;\n bool ongoingCall = false;\n\n @override\n void initState() {\n super.initState();\n destinationController.text = 'isaac81763';\n }\n\n void _observeResponses() {\n Provider.of<MainViewModel>(context, listen: true).observeResponses();\n invitation =\n Provider.of<MainViewModel>(context, listen: true).ongoingInvitation;\n ongoingCall = Provider.of<MainViewModel>(context, listen: true).ongoingCall;\n }\n\n\n void _callDestination() {\n Provider.of<MainViewModel>(context, listen: false)\n .call(destinationController.text);\n logger.i('Calling!');\n }\n\n void _endCall() {\n Provider.of<MainViewModel>(context, listen: false)\n .endCall();\n logger.i('Calling!');\n }\n\n void handleOptionClick(String value) {\n switch (value) {\n case 'Logout':\n Provider.of<MainViewModel>(context, listen: false).disconnect();\n WidgetsBinding.instance.addPostFrameCallback((_) {\n Navigator.of(context).pushReplacementNamed('/');\n });\n logger.i('Disconnecting!');\n break;\n }\n }\n\n @override\n Widget build(BuildContext context) {\n _observeResponses();\n if (invitation) {\n return InvitationWidget(\n title: 'Home',\n invitation: Provider.of<MainViewModel>(context, listen: false)\n .incomingInvitation);\n } else if (ongoingCall) {\n return CallScreen(\n title: \"Ongoing Call\",\n call: Provider.of<MainViewModel>(context, listen: false).currentCall);\n } else {\n return Scaffold(\n appBar: AppBar(\n title: Text(widget.title),\n actions: <Widget>[\n PopupMenuButton<String>(\n onSelected: handleOptionClick,\n itemBuilder: (BuildContext context) {\n return {'Logout'}.map((String choice) {\n return PopupMenuItem<String>(\n value: choice,\n child: Text(choice),\n );\n }).toList();\n },\n ),\n ],\n ),\n body: Center(\n child: Column(\n mainAxisAlignment: MainAxisAlignment.center,\n children: <Widget>[\n Padding(\n padding: const EdgeInsets.all(8.0),\n child: TextFormField(\n controller: destinationController,\n decoration: const InputDecoration(\n border: OutlineInputBorder(),\n labelText: 'Destination',\n ),\n ),\n ),\n Padding(\n padding: const EdgeInsets.all(8.0),\n child: TextButton(\n style: TextButton.styleFrom(\n foregroundColor: Colors.blue,\n ),\n onPressed: () {\n _callDestination();\n },\n child: const Text('Call'),\n ),\n )\n ],\n ),\n ),\n );\n }\n }\n}\n"
}
]
}
Binary file modified ios/.DS_Store
Binary file not shown.
1 change: 0 additions & 1 deletion ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import flutter_callkit_incoming
func onAccept(_ call: flutter_callkit_incoming.Call, _ action: CXAnswerCallAction) {
print("onRunner :: Accept")
action.fulfill()

}

func onDecline(_ call: flutter_callkit_incoming.Call, _ action: CXEndCallAction) {
Expand Down
4 changes: 2 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import 'package:telnyx_webrtc/model/socket_method.dart';

final logger = Logger();
final mainViewModel = MainViewModel();
const MOCK_USER = "<UserName>";
const MOCK_PASSWORD = "<Password>";
const MOCK_USER = "isaac69601";
const MOCK_PASSWORD = "DYVTuQ6V";
// Android Only - Push Notifications
@pragma('vm:entry-point')
Future _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
Expand Down
2 changes: 0 additions & 2 deletions lib/main_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,6 @@ class MainViewModel with ChangeNotifier {
}

void call(String destination) {
_telnyxClient.txSocket.close();
if (!_telnyxClient.isConnected()) {}
_currentCall = _telnyxClient.newInvite(
_localName, _localNumber, destination, "Fake State",
customHeaders: {"X-Header-1": "Value1", "X-Header-2": "Value2"});
Expand Down
6 changes: 3 additions & 3 deletions lib/view/screen/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class _HomeScreenState extends State<HomeScreen> {
@override
void initState() {
super.initState();

destinationController.text = "isaac81763";
}

void _observeResponses() {
Expand All @@ -32,16 +34,14 @@ class _HomeScreenState extends State<HomeScreen> {
ongoingCall = Provider.of<MainViewModel>(context, listen: true).ongoingCall;
}


void _callDestination() {
Provider.of<MainViewModel>(context, listen: false)
.call(destinationController.text);
logger.i('Calling!');
}

void _endCall() {
Provider.of<MainViewModel>(context, listen: false)
.endCall();
Provider.of<MainViewModel>(context, listen: false).endCall();
logger.i('Calling!');
}

Expand Down

0 comments on commit 9a697a9

Please sign in to comment.