Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bigataka yadaharu #1611

Open
jayany123 opened this issue Jan 28, 2025 · 0 comments
Open

bigataka yadaharu #1611

jayany123 opened this issue Jan 28, 2025 · 0 comments
Assignees

Comments

@jayany123
Copy link

import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_storage/firebase_storage.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
import 'dart:io';
import 'package:agora_rtc_engine/agora_rtc_engine.dart';

void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(MyApp());
}

class MyApp extends StatelessWidget {
@OverRide
Widget build(BuildContext context) {
return MaterialApp(
home: HomeScreen(),
);
}
}

class HomeScreen extends StatelessWidget {
@OverRide
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.blue, // Blue background
body: Center(
child: Text(
'Hello from Jayant Bista!', // Greeting message
style: TextStyle(
fontSize: 24,
color: Colors.black, // Black text
),
),
),
);
}
}

class SignUpScreen extends StatelessWidget {
final TextEditingController emailController = TextEditingController();
final TextEditingController passwordController = TextEditingController();

void signUp() async {
try {
await FirebaseAuth.instance.createUserWithEmailAndPassword(
email: emailController.text,
password: passwordController.text,
);
print("User signed up!");
} catch (e) {
print("Error: $e");
}
}

@OverRide
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Sign Up')),
body: Padding(
padding: EdgeInsets.all(16.0),
child: Column(
children: [
TextField(
controller: emailController,
decoration: InputDecoration(labelText: 'Email'),
),
TextField(
controller: passwordController,
decoration: InputDecoration(labelText: 'Password'),
obscureText: true,
),
ElevatedButton(onPressed: signUp, child: Text('Sign Up')),
],
),
),
);
}
}

class ChatScreen extends StatefulWidget {
@OverRide
_ChatScreenState createState() => _ChatScreenState();
}

class _ChatScreenState extends State {
final TextEditingController messageController = TextEditingController();

void sendMessage() {
FirebaseFirestore.instance.collection('chats').add({
'message': messageController.text,
'timestamp': FieldValue.serverTimestamp(),
});
messageController.clear();
}

@OverRide
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Chat')),
body: Column(
children: [
Expanded(
child: StreamBuilder(
stream: FirebaseFirestore.instance
.collection('chats')
.orderBy('timestamp')
.snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData) return CircularProgressIndicator();
var messages = snapshot.data!.docs;
return ListView.builder(
itemCount: messages.length,
itemBuilder: (context, index) {
return ListTile(
title: Text(messages[index]['message']),
);
},
);
},
),
),
Padding(
padding: EdgeInsets.all(8.0),
child: Row(
children: [
Expanded(
child: TextField(
controller: messageController,
decoration: InputDecoration(hintText: 'Type a message'),
),
),
IconButton(
icon: Icon(Icons.send),
onPressed: sendMessage,
),
],
),
),
],
),
);
}
}

class UploadScreen extends StatelessWidget {
void uploadFile() async {
final ImagePicker picker = ImagePicker();
final XFile? image = await picker.pickImage(source: ImageSource.gallery);

if (image != null) {
  File file = File(image.path);
  try {
    await FirebaseStorage.instance.ref('uploads/photo.jpg').putFile(file);
    print("File uploaded");
  } catch (e) {
    print("Error: $e");
  }
}

}

@OverRide
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Upload Photo')),
body: Center(
child: ElevatedButton(
onPressed: uploadFile,
child: Text('Upload Photo'),
),
),
);
}
}

class VideoCallScreen extends StatelessWidget {
static const String appId = "YOUR_AGORA_APP_ID";

void initializeAgora() {
AgoraRtcEngine.create(appId);
AgoraRtcEngine.enableVideo();
AgoraRtcEngine.joinChannel(null, 'test', null, 0);
}

@OverRide
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Video Call')),
body: Center(
child: ElevatedButton(
onPressed: initializeAgora,
child: Text('Start Video Call'),
),
),
);
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants