Professional Documents
Culture Documents
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:jitsi_meet/jitsi_meet.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_core/firebase_core.dart';
@override
State<JoinMeeting> createState() => _JoinMeetingState();
}
@override
void initState() {
super.initState();
JitsiMeet.addListener(JitsiMeetingListener(
onConferenceWillJoin: _onConferenceWillJoin,
onConferenceJoined: _onConferenceJoined,
onConferenceTerminated: _onConferenceTerminated,
onError: _onError));
}
@override
void dispose() {
super.dispose();
JitsiMeet.removeAllListeners();
}
Future addmeetingdetails(String title, DateTime startdate, DateTime enddate) async
{
await FirebaseFirestore.instance
.collection('Users')
.doc(FirebaseAuth.instance.currentUser!.uid)
.collection('Past Meetings')
.add({
'MeetingID': title,
'Start Date/Time': startdate,
'End Date/Time': enddate,
});
}
@override
Widget build(BuildContext context) {
double width = MediaQuery.of(context).size.width;
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
appBar: AppBar(
backgroundColor: Color(0xFF0C1D36),
elevation: 0,
leading: IconButton(
onPressed: () => Get.back(),
icon: const Icon(
Icons.arrow_back_sharp,
color: Colors.white,
),
),
centerTitle: true,
title: Text(
'Join Meeting',
style: TextStyle(
color: Colors.white,
),
),
),
body: Container(
padding: const EdgeInsets.symmetric(
horizontal: 16.0,
),
child: kIsWeb
? Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
width: width * 0.30,
child: meetConfig(),
),
Container(
width: width * 0.60,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Card(
color: Colors.white54,
child: SizedBox(
width: width * 0.60 * 0.70,
height: width * 0.60 * 0.70,
child: JitsiMeetConferencing(
extraJS: [
// extraJs setup example
'<script>function echo(){console.log("echo!!!")};</script>',
'<script src="https://code.jquery.com/jquery-3.5.1.slim.js"
integrity="sha256-DrT5NfxfbHvMHux31Lkhxg42LY6of8TaYyK50jnxRnM="
crossorigin="anonymous"></script>'
],
),
)),
))
],
)
: meetConfig(),
),
),
);
}
Widget meetConfig() {
return SingleChildScrollView(
child: Column(
children: <Widget>[
SizedBox(height: 40),
Row(
children: [
Icon(
Icons.add_box,
color: Colors.black,
),
SizedBox(width: 10),
Text(
'Join a New Meeting',
style: TextStyle(fontSize: 22, fontWeight: FontWeight.bold),
),
],
),
Divider(height: 20, thickness: 1),
SizedBox(height: 20),
//Padding(
//padding: const EdgeInsets.only(right: 15),
Container(
//child
decoration: BoxDecoration(
color: Colors.grey[200],
border: Border.all(color: Colors.white),
//borderRadius: BorderRadius.circular(30),
),
child: Padding(
padding: const EdgeInsets.only(left: 15.0),
child: TextField(
controller: roomText,
decoration: InputDecoration(
border: InputBorder.none,
hintText: "Enter Meeting ID",
contentPadding: const EdgeInsets.only(bottom: 8.0, top: 10.0),
),
),
),
),
SizedBox(height: 15),
Container(
//child
decoration: BoxDecoration(
color: Colors.grey[200],
border: Border.all(color: Colors.white),
//borderRadius: BorderRadius.circular(30),
),
child: Padding(
padding: const EdgeInsets.only(left: 15.0),
child: TextField(
controller: nameText,
decoration: InputDecoration(
border: InputBorder.none,
hintText: "Enter Your Name",
contentPadding: const EdgeInsets.only(bottom: 8.0, top: 10.0),
),
),
),
),
//),
SizedBox(
height: 14.0,
),
Divider(height: 20, thickness: 1),
buildMeetingOption('Audio Only', isAudioOnly, _onAudioOnlyChanged),
buildMeetingOption('Audio Muted', isAudioMuted, _onAudioMutedChanged),
buildMeetingOption('Video Muted', isVideoMuted, _onVideoMutedChanged),
// CheckboxListTile(
// title: Text("Audio Only"),
// value: isAudioOnly,
// onChanged: _onAudioOnlyChanged,
// ),
// SizedBox(
// height: 14.0,
// ),
// CheckboxListTile(
// title: Text("Audio Muted"),
// value: isAudioMuted,
// onChanged: _onAudioMutedChanged,
// ),
// SizedBox(
// height: 14.0,
// ),
// CheckboxListTile(
// title: Text("Video Muted"),
// value: isVideoMuted,
// onChanged: _onVideoMutedChanged,
// ),
Divider(
height: 48.0,
thickness: 2.0,
),
SizedBox(
height: 50,
width: double.maxFinite,
child: ElevatedButton(
onPressed: () {
_joinMeeting();
},
style: ElevatedButton.styleFrom(
backgroundColor: Color(0xFF0C1D36),
side: BorderSide.none,
shape: const StadiumBorder(),
),
child: const Text(
'Join Meeting',
style: TextStyle(
fontSize: 18,
color: Colors.white,
),
),
),
),
SizedBox(
height: 48.0,
),
],
),
);
}
_onAudioOnlyChanged(bool value) {
setState(() {
isAudioOnly = value;
});
}
_onAudioMutedChanged(bool value) {
setState(() {
isAudioMuted = value;
});
}
_onVideoMutedChanged(bool value) {
setState(() {
isVideoMuted = value;
});
}
_joinMeeting() async {
String? serverUrl = 'https://meet.dpmeet.xyz';
debugPrint("JitsiMeetingOptions: $options");
await JitsiMeet.joinMeeting(
options,
listener: JitsiMeetingListener(
onConferenceWillJoin: (message) {
debugPrint("${options.room} will join with message: $message");
},
onConferenceJoined: (message) {
void _onConferenceWillJoin(message) {
debugPrint("_onConferenceWillJoin broadcasted with message: $message");
}
void _onConferenceJoined(message) {
_starttime = DateTime.now();
void _onConferenceTerminated(message) {
_endtime = DateTime.now();
_onError(error) {
debugPrint("_onError broadcasted: $error");
}
Padding buildMeetingOption(
String title, bool value, Function onChangeMethod) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
title,
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w400,
color: Colors.grey[600]),
),
Transform.scale(
scale: 0.85,
child: CupertinoSwitch(
activeColor: Color(0xFF0C1D36),
trackColor: Colors.grey,
value: value,
onChanged: (bool newValue) {
onChangeMethod(newValue);
},
),
)
],
),
);
}
}