repo_id
stringlengths 21
168
| file_path
stringlengths 36
210
| content
stringlengths 1
9.98M
| __index_level_0__
int64 0
0
|
---|---|---|---|
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/components/themes.dart | import 'package:flutter/material.dart';
| 0 |
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/components/input-field.dart | import 'package:flutter/material.dart';
class InputField extends StatelessWidget {
const InputField(this.text, this.obscure,this.onChangedCallback);
final String text;
final bool obscure;
final Function onChangedCallback;
@override
Widget build(BuildContext context) {
return TextField(
obscureText: obscure,
onChanged: (value){
onChangedCallback(value);
},
cursorColor: Color(0xFF13192F),
decoration: InputDecoration(
hintText: text,
contentPadding:
const EdgeInsets.symmetric(vertical: 10.0, horizontal: 20.0),
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(32.0),
),
),
enabledBorder: const OutlineInputBorder(
borderSide: BorderSide(color: Color(0xFF13192F), width: 2.0),
borderRadius: BorderRadius.all(
Radius.circular(32.0),
),
),
focusedBorder: const OutlineInputBorder(
borderSide: BorderSide(color: Color(0xFF13192F), width: 2.0),
borderRadius: BorderRadius.all(Radius.circular(32.0)),
),
),
);
}
}
| 0 |
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/components/task-data.dart | import 'package:flutter/material.dart';
import 'package:firebase_auth/firebase_auth.dart';
class TaskData extends ChangeNotifier{
final _auth = FirebaseAuth.instance;
String userName = '';
String userEmail = '';
String userPhoto = '';
String courseCode = '';
String courseBatch = '';
String courseSection = '';
String classCode = '';
String teacher = '';
bool isStudent = false;
void getUser() {
userName = '';
final user = _auth.currentUser;
if(user!=null){
List<String> splitted = user.displayName!.split(' ');
if(splitted[splitted.length-1] != "student"){
userName = user.displayName!;
}
else{
isStudent = true;
for(int i=0;i<splitted.length-1;i++){
userName += splitted[i];
if(i!=splitted.length-2)userName +=' ';
}
}
userEmail = user.email!;
if(user.photoURL != null) {
userPhoto = user.photoURL!;
}
}
notifyListeners();
}
void getGroup(String code, String batch){
courseCode = code;
courseBatch = batch;
notifyListeners();
}
void getSubGroup(String section, String code,String newTeacher){
courseSection = section;
classCode = code;
teacher = newTeacher;
notifyListeners();
}
void updatePhoto(dynamic url)async{
final user = _auth.currentUser;
if(user!=null){
await user.updatePhotoURL(url);
getUser();
}
notifyListeners();
}
void logOut(){
_auth.signOut();
userName = '';
userEmail = '';
userPhoto = '';
courseCode = '';
courseBatch = '';
courseSection = '';
classCode = '';
isStudent = false;
notifyListeners();
}
} | 0 |
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/components/dropdown-field.dart | import 'dart:core';
import 'package:dropdown_button2/dropdown_button2.dart';
import 'package:flutter/material.dart';
class DropdownField extends StatelessWidget {
const DropdownField(this.dropdownValue, this.items,this.onChangedCallback);
final String dropdownValue;
final List<String> items;
final Function onChangedCallback;
@override
Widget build(BuildContext context) {
return DecoratedBox(
decoration: BoxDecoration(
border:
Border.all(color: const Color(0xFF13192F), width: 2.0),
borderRadius: BorderRadius.circular(15.0),
),
child: Padding(
padding:
EdgeInsets.symmetric(horizontal: 15.0),
child: DropdownButtonHideUnderline(
child: DropdownButton2(
dropdownMaxHeight: 200,
dropdownElevation: 8,
scrollbarRadius: const Radius.circular(40),
scrollbarThickness: 6,
scrollbarAlwaysShow: true,
offset: const Offset(-20, 0),
value: dropdownValue,
items: items.map((String items) {
return DropdownMenuItem(
value: items,
child: Text(
items,
style: TextStyle(color: Colors.black),
),
);
}).toList(),
onChanged: (String? newValue) {
onChangedCallback(newValue);
},
underline: Container(),
isExpanded: true,
),
),
),
);
}
}
| 0 |
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/components/error-message.dart | import 'package:flutter/material.dart';
class ErrorMessage extends StatefulWidget {
ErrorMessage(this.error);
late String error='';
@override
_ErrorMessageState createState() => _ErrorMessageState();
}
class _ErrorMessageState extends State<ErrorMessage> {
@override
Widget build(BuildContext context) {
return Column(
//crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
widget.error,
style: TextStyle(
//height: widget.error=='' ? 0.0 : 2.0,
color: Colors.red,
fontWeight: FontWeight.bold,
fontSize: widget.error=='' ? 0.0 : 16.0,
),
),
SizedBox(
height: widget.error=='' ? 0.0 : 10.0,
),
],
);
}
}
| 0 |
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/components/input-field2.dart | import 'package:flutter/material.dart';
class InputField2 extends StatelessWidget {
const InputField2(this.text, this.obscure,this.onChangedCallback);
final String text;
final bool obscure;
final Function onChangedCallback;
@override
Widget build(BuildContext context) {
return TextField(
obscureText: obscure,
onChanged: (value){
onChangedCallback(value);
},
cursorColor: Color(0xFF13192F),
decoration: InputDecoration(
hintText: text,
hintStyle: TextStyle(color: Color(0xFF13192F)),
contentPadding:
const EdgeInsets.symmetric(vertical: 10.0, horizontal: 15.0),
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(15.0),
),
),
enabledBorder: const OutlineInputBorder(
borderSide: BorderSide(color: Color(0xFF13192F), width: 2.0),
borderRadius: BorderRadius.all(
Radius.circular(15.0),
),
),
focusedBorder: const OutlineInputBorder(
borderSide: BorderSide(color: Color(0xFF13192F), width: 2.0),
borderRadius: BorderRadius.all(Radius.circular(15.0)),
),
),
);
}
}
| 0 |
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/components/navigation2.dart | import 'dart:ui';
import 'package:cms/screens/group-info.dart';
import 'package:flutter/material.dart';
import 'dart:math' as math;
import 'package:flutter/services.dart';
class CustomNavigation2 extends StatelessWidget {
const CustomNavigation2(this.batch, this.section, this.code, this.name, this.onChangeCallback);
final String batch;
final String section;
final String code;
final String name;
final Function onChangeCallback;
@override
Widget build(BuildContext context) {
return Container(
padding: EdgeInsets.symmetric(horizontal: 20.0),
decoration: BoxDecoration(
borderRadius:
BorderRadius.only(bottomRight: Radius.circular(30.0)),
color: Color(0xFF13192F),
),
child: Row(
children: [
SizedBox(
width: 10.0,
),
Padding(
padding: EdgeInsets.symmetric(vertical: 7.0),
child: CircleAvatar(
child: Column(
mainAxisAlignment:
MainAxisAlignment.center,
children: [
Text(
batch +'(' + section + ')',
style: TextStyle(
color: Colors.white,fontSize: 17,fontWeight: FontWeight.w500),
),
]),
radius: 24,
backgroundColor: Color((math.Random().nextDouble()*0xFFFF55).toInt()).withOpacity(0.6),
),
),
Padding(
padding: EdgeInsets.symmetric(vertical: 10.0),
child: Padding(
padding: EdgeInsets.all(7.0),
child: Text(name + '-' + batch + '(' + section + ')',
style: TextStyle(fontSize: 20.0,color: Colors.white, fontWeight: FontWeight.bold),),
)
),
Expanded(
child: Row(
//crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisAlignment: MainAxisAlignment.end,
children: [
Icon(
Icons.search,
color: Colors.white,
size: 30.0,
),
SizedBox(
width: 10.0,
),
PopupMenuButton(
icon: Icon(Icons.more_vert_outlined,color: Colors.white,),
itemBuilder: (context) => [
PopupMenuItem(
child: Text('Group Info'),
onTap:() => onChangeCallback
),
PopupMenuItem(
child: Text('Classroom Code'),
onTap: () {
Future.delayed(
const Duration(seconds: 0),
() => showDialog(
context: context,
builder: (context) => AlertDialog(
title: Text('This Classroom Code'),
content: Padding(
padding:
EdgeInsets.symmetric(horizontal: 0.0),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceAround,
children: [
Text(
code,
style: TextStyle(
color: Color(0xFF13192F),
fontSize: 18.0),
),
IconButton(
icon: Icon(
Icons.copy,
color: Color(0xFF13192F),
size: 18.0,
),
onPressed: () {
Clipboard.setData(ClipboardData(text: code));
},
),
],
),
),
actions: [
TextButton(
child: Text('Ok',style: TextStyle(color: Color(0xFF13192F)),),
onPressed: () => Navigator.pop(context),
)
],
),
));
},
)
],
),
],
),
)
],
),
);
}
}
| 0 |
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/components/navigation.dart |
import 'dart:ui';
import 'package:flutter/material.dart';
class CustomNavigation extends StatelessWidget {
const CustomNavigation(this.title,this.onChangedCallback(value));
final Function onChangedCallback;
final title;
@override
Widget build(BuildContext context) {
return Container(
padding: EdgeInsets.symmetric(horizontal: 20.0),
decoration: BoxDecoration(
borderRadius:
BorderRadius.only(bottomRight: Radius.circular(30.0)),
color: Color(0xFF13192F),
),
child: Row(
children: [
GestureDetector(
child: Icon(
Icons.list,
color: Colors.white,
size: 35.0,
),
onTap: (){
onChangedCallback(true);
},
),
SizedBox(
width: 10.0,
),
Padding(
padding: EdgeInsets.symmetric(vertical: 10.0),
child: Padding(
padding: EdgeInsets.all(7.0),
child: Text(title,
style: TextStyle(fontSize: 24.0,color: Colors.white, fontWeight: FontWeight.w500),),
)
),
],
),
);
}
}
| 0 |
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/student-screens/student-login.dart | import 'package:cms/components/error-message.dart';
import 'package:cms/components/task-data.dart';
import 'package:cms/student-screens/student-login-verification.dart';
import 'package:cms/student-screens/student-register.dart';
import 'package:flutter/material.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:provider/provider.dart';
import '../components/input-field.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import '../screens/forgot-password.dart';
import 'student-verification.dart';
class StudentLogin extends StatefulWidget {
static String id = 'student-login';
@override
_StudentLoginState createState() => _StudentLoginState();
}
class _StudentLoginState extends State<StudentLogin> {
final _auth = FirebaseAuth.instance;
late String email;
late String password;
late String errorMessage = '';
late bool spinner = false;
@override
Widget build(BuildContext context) {
return Scaffold(
body: spinner
? const Center(
child: SpinKitDoubleBounce(
color: Color(0xFF13192F),
size: 50.0,
),
)
: Padding(
padding: const EdgeInsets.symmetric(horizontal: 30.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Center(
child: Material(
borderRadius: BorderRadius.circular(100),
elevation: 5.0,
child: CircleAvatar(
backgroundColor: Color(0xFF13192F),
radius: 73.0,
child: CircleAvatar(
radius: 70.0,
backgroundImage: AssetImage('images/CMS-Logo.png'),
),
),
),
),
SizedBox(
height: 30.0,
),
Text("Login as Student",textAlign: TextAlign.center ,style: TextStyle(color: Color(0xFF13192F),fontSize: 20.0,fontWeight: FontWeight.bold),),
SizedBox(
height: 30.0,
),
InputField('Enter your email', false, (value) {
email = value;
}),
const SizedBox(
height: 10.0,
),
InputField('Enter your password', true, (value) {
password = value;
}),
const SizedBox(
height: 10.0,
),
ErrorMessage(errorMessage),
Padding(
padding: const EdgeInsets.symmetric(vertical: 16.0),
child: Material(
borderRadius: const BorderRadius.all(
Radius.circular(32.0),
),
color: Color(0xFF13192F),
elevation: 5.0,
child: MaterialButton(
onPressed: () async {
try {
setState(() {
spinner = true;
});
await Firebase.initializeApp();
final user = await _auth.signInWithEmailAndPassword(
email: email, password: password);
if (user != null) {
Provider.of<TaskData>(context,listen:false).getUser();
Navigator.pushNamed(context, StudentLoginVerification.id);
}
setState(() {
spinner = false;
});
} catch (e) {
setState(() {
spinner = false;
errorMessage = e.toString();
});
}
},
child: const Text(
'Login',
style: TextStyle(color: Colors.white),
),
),
),
),
TextButton(
onPressed: () {
Navigator.pushNamed(context, ForgotPassword.id);
},
style: TextButton.styleFrom(
primary: Color(0xFF13192F), // Text Color
),
child: const Text(
'Forgot password?',
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 16.0),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text('You don\'t have an account?'),
TextButton(
onPressed: () {
Navigator.pushNamed(context, StudentRegister.id);
},
style: TextButton.styleFrom(
primary: Color(0xFF13192F), // Text Color
),
child: const Text(
'Register Now',
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 16.0),
),
)
],
),
],
),
),
);
}
}
| 0 |
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/student-screens/student-multi-profile.dart | import 'dart:ui';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:cms/components/custom-drawer.dart';
import 'package:cms/components/task-data.dart';
import 'package:cms/screens/resource.dart';
import 'package:cms/student-screens/join-group.dart';
import 'package:cms/student-screens/student-group-screen.dart';
import 'package:cms/student-screens/student-profile.dart';
import 'package:flutter/material.dart';
import 'package:colorful_safe_area/colorful_safe_area.dart';
import 'package:provider/provider.dart';
import '../components/navigation.dart';
import 'dart:math' as math;
import '../screens/chat-screen.dart';
class StudentMultiProfile extends StatefulWidget {
static String id = 'student-multi-profile';
@override
_StudentMultiProfileState createState() => _StudentMultiProfileState();
}
class _StudentMultiProfileState extends State<StudentMultiProfile> {
final _firestore = FirebaseFirestore.instance;
final GlobalKey<ScaffoldState> _globalKey = GlobalKey<ScaffoldState>();
bool alreadyDisplayed = false;
@override
Widget build(BuildContext context) {
String email = Provider.of<TaskData>(context,listen: false).userEmail;
return Scaffold(
key: _globalKey,
drawer: CustomDrawer(),
backgroundColor: Colors.white,
body: ColorfulSafeArea(
color: Color(0xFF13192F),
child: Column(
children: [
CustomNavigation("Profile",(value){
_globalKey.currentState?.openDrawer();
}),
Container(
child: Stack(
children: [
Container(
height: 28.0,
margin: EdgeInsets.only(right: 50.0),
color: Color(0xFF13192F),
),
Container(
height: 35.0,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30.0))),
),
Positioned(
child: GestureDetector(
child: Padding(
padding: EdgeInsets.only(top: 10.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
GestureDetector(
onTap: (){
Navigator.pushNamed(context, StudentGroupScreen.id);
},
child: Padding(
padding: EdgeInsets.only(left: 20.0,right: 20.0,bottom: 7.0),
child: Text(
"Groups",
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.w500,
),
),
),
),
SizedBox(
width: 50.0,
),
Container(
padding: EdgeInsets.only(left: 20.0,right: 20.0,bottom: 7.0),
child: Text(
"Profile",
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.w500,
),
),
decoration: BoxDecoration(
border: Border(
bottom:BorderSide(color: Colors.black,width: 3.0),
),
),
),
],
),
),
),
),
],
),
),
SizedBox(
height: 20.0,
),
StreamBuilder<QuerySnapshot>(
stream: _firestore.collection('studentProfile').where('email', isEqualTo:Provider.of<TaskData>(context).userEmail).snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData)
return LinearProgressIndicator();
else {
final docs = snapshot.data!.docs;
return ListView.builder(
scrollDirection: Axis.vertical,
itemCount: docs.length,
shrinkWrap: true,
itemBuilder: (context, i) {
if (docs[i].exists &&
!alreadyDisplayed) {
alreadyDisplayed = true;
final data = docs[i];
return Column(
children: [
Container(
child: Column(
children: [
Padding(
padding: EdgeInsets.all(28.0),
child: Material(
borderRadius: BorderRadius.circular(100.0),
elevation: 3.0,
child: CircleAvatar(
backgroundColor: Color(0xFF13192F),
radius: 78.0,
child: CircleAvatar(
backgroundImage: Provider.of<TaskData>(
context)
.userPhoto ==
''
? NetworkImage(
'https://cdn.pixabay.com/photo/2015/10/05/22/37/blank-profile-picture-973460_1280.png')
: NetworkImage(Provider.of<
TaskData>(context)
.userPhoto),
radius: 75.0,
),
),
),
),
],
),
),
Column(
children: [
Text(
Provider.of<TaskData>(context).userName,
style: TextStyle(
fontSize: 27.0,
color: Color(0xFF13192F),
fontWeight: FontWeight.bold,
),
),
Text(
"Batch ${data['batch']}",
style: TextStyle(
fontSize: 20.0,
color: Color(0xFF13192F),
fontWeight: FontWeight.bold,
),
),
Text(
'Department of ' + data['dept'],
style: TextStyle(
fontSize: 20.0,
color: Color(0xFF13192F),
fontWeight: FontWeight.bold,
),
),
],
),
Row(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 30.0,
),
Padding(
padding: const EdgeInsets.only(
left: 25.0, bottom: 20.0),
child: SizedBox(
width: MediaQuery.of(context).size.width - 25.0,
child: Text(
data['bio'],
style: TextStyle(
fontSize: 20.0,
color: Color(0xFF13192F),
fontWeight: FontWeight.bold,
),
),
),
),
],
),
],
),
Row(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(
left: 25.0, top: 20.0),
child: Text(
'Phone: ' + data['mobile'],
style: TextStyle(
fontSize: 20.0,
color: Color(0xFF13192F),
),
),
),
],
),
],
),
Row(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(
left: 25.0, top: 20.0),
child: Text(
'Email: ' +
Provider.of<TaskData>(context)
.userEmail,
style: TextStyle(
fontSize: 20.0,
color: Color(0xFF13192F),
),
),
),
SizedBox(
height: 40.0,
),
],
),
],
),
],
);
} else {
return Container();
}
},
);
}
}),
],
)));
}
}
| 0 |
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/student-screens/student-profile-update.dart | import 'dart:io';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:cms/components/input-field2.dart';
import 'package:cms/components/multi-dropdown-field.dart';
import 'package:cms/screens/group-screen.dart';
import 'package:cms/student-screens/student-group-screen.dart';
import 'package:file_picker/file_picker.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_storage/firebase_storage.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:cms/components/task-data.dart';
import 'package:rflutter_alert/rflutter_alert.dart';
import 'package:image_picker/image_picker.dart';
import '../components/dropdown-field.dart';
class StudentProfileUpdate extends StatefulWidget {
static String id = 'student-profile-update';
@override
_StudentProfileUpdateState createState() => _StudentProfileUpdateState();
}
class _StudentProfileUpdateState extends State<StudentProfileUpdate> {
late PickedFile _imageFile;
final ImagePicker _picker = ImagePicker();
late bool isImage = false;
final user = FirebaseAuth.instance.currentUser;
File? file = null;
void takePhoto(ImageSource source) async {
final pickedFile = await _picker.getImage(
source: source,
);
setState(() {
_imageFile = pickedFile!;
});
File img = File(_imageFile.path);
String newFileName = img.path.toString().split('/').last;
final ref = FirebaseStorage.instance.ref().child('profileImages/${user?.email}/$newFileName');
await ref.putFile(img).whenComplete(()async{
await ref.getDownloadURL().then((value){
user?.updatePhotoURL(value);
Provider.of<TaskData>(context, listen: false).updatePhoto(value);
}
);
});
}
final _firestore = FirebaseFirestore.instance;
String _dropDownValue = 'Select Your Department';
List<String> items = ['Select Your Department','CSE', 'EEE','Civil Engineering','Business Administration', 'LAW', 'English', 'Architecture', 'Islamic Study',
'Public Health','Tourism and Hospitality Management','Bangla'];
late String mobile = '';
late String bio = '';
late String batch = '';
late CollectionReference routineRef;
@override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: () async => false,
child: Scaffold(
appBar: AppBar(
title: const Text(
'Student Profile',
),
backgroundColor: Color(0xFF13192F),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
_firestore.collection('studentProfile').doc(Provider.of<TaskData>(context, listen: false).userEmail).set({
'batch': batch,
'dept': _dropDownValue,
'bio': bio,
'mobile': mobile,
'email': Provider.of<TaskData>(context, listen: false).userEmail
});
Navigator.pushNamed(context, StudentGroupScreen.id);
},
backgroundColor: Color(0xFF13192F),
child: Icon(Icons.arrow_forward_sharp),
),
resizeToAvoidBottomInset: true,
body: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const SizedBox(
height: 40.0,
),
Stack(
children: [
CircleAvatar(
radius: 100.0,
backgroundColor: Color(0xFF13192F),
child: CircleAvatar(
radius: 95.0,
backgroundImage: Provider.of<TaskData>(context).userPhoto ==
''
? NetworkImage('https://cdn.pixabay.com/photo/2015/10/05/22/37/blank-profile-picture-973460_1280.png')
: NetworkImage(Provider.of<TaskData>(context).userPhoto)
as ImageProvider, // : FileImage() as ImageProvider,
backgroundColor: Colors.white,
),
),
Positioned(
top: 150,
left: 150,
child: GestureDetector(
onTap: () {
Alert(
context: context,
content: Column(
children: [
Material(
elevation: 4,
child: DialogButton(
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: const [
Icon(Icons.camera),
Text(
"Camera",
style: TextStyle(
color: Colors.black, fontSize: 20),
),
],
),
onPressed: () {
takePhoto(ImageSource.camera);
Navigator.pop(context);
},
color: Colors.white,
),
),
const SizedBox(
height: 10,
),
Material(
elevation: 4,
child: DialogButton(
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: const [
Icon(Icons.image),
Text(
"Gallery",
style: TextStyle(
color: Colors.black, fontSize: 20),
),
],
),
color: Colors.white,
onPressed: () {
takePhoto(ImageSource.gallery);
Navigator.pop(context);
}),
),
],
),
buttons: [],
).show();
},
child: const CircleAvatar(
backgroundColor: Color(0xFF13192F),
child: Icon(
Icons.add,
color: Colors.white,
),
),
),
),
],
),
SizedBox(height: 10.0),
Text(
Provider.of<TaskData>(context).userName,
style: TextStyle(fontSize: 30.0, fontWeight: FontWeight.w600),
),
SizedBox(
height: 10.0,
),
Padding(
padding: EdgeInsets.all(30.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
//crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
DropdownField(_dropDownValue, items, (value) {
setState(() {
_dropDownValue = value;
});
}),
SizedBox(
height: 10.0,
),
InputField2("Enter your batch", false, (value){
}),
SizedBox(
height: 10.0,
),
InputField2("Add Bio", false, (value) {
setState(() {
bio = value;
});
}),
SizedBox(
height: 10.0,
),
InputField2('Mobile Number', false, (value) {
setState(() {
mobile = value;
});
}),
SizedBox(
height: 10.0,
),
],
),
)
],
),
),
),
);
}
}
| 0 |
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/student-screens/student-group-screen.dart | import 'dart:ui';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:cms/components/custom-drawer.dart';
import 'package:cms/components/task-data.dart';
import 'package:cms/screens/resource.dart';
import 'package:cms/student-screens/join-group.dart';
import 'package:cms/student-screens/student-multi-profile.dart';
import 'package:cms/student-screens/student-profile.dart';
import 'package:flutter/material.dart';
import 'package:colorful_safe_area/colorful_safe_area.dart';
import 'package:provider/provider.dart';
import '../components/navigation.dart';
import '../screens/add-group.dart';
import 'dart:math' as math;
import '../screens/chat-screen.dart';
class StudentGroupScreen extends StatefulWidget {
static String id = 'student-group-screen';
@override
_StudentGroupScreenState createState() => _StudentGroupScreenState();
}
class _StudentGroupScreenState extends State<StudentGroupScreen> {
final _firestore = FirebaseFirestore.instance;
final GlobalKey<ScaffoldState> _globalKey = GlobalKey<ScaffoldState>();
@override
Widget build(BuildContext context) {
String email = Provider.of<TaskData>(context,listen: false).userEmail;
return Scaffold(
key: _globalKey,
drawer: CustomDrawer(),
floatingActionButton: FloatingActionButton.extended(
onPressed: () {
Navigator.pushNamed(context, JoinGroup.id);
},
label: Text(
"Join Groups",
textAlign: TextAlign.center,
),
backgroundColor: Color(0xFF13192F),
),
backgroundColor: Colors.white,
body: ColorfulSafeArea(
color: Color(0xFF13192F),
child: Column(
children: [
CustomNavigation("Groups",(value){
_globalKey.currentState?.openDrawer();
}),
Container(
child: Stack(
children: [
Container(
height: 28.0,
margin: EdgeInsets.only(right: 50.0),
color: Color(0xFF13192F),
),
Container(
height: 35.0,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30.0))),
),
Positioned(
child: GestureDetector(
child: Padding(
padding: EdgeInsets.only(top: 10.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
child: Padding(
padding: EdgeInsets.only(left: 20.0,right: 20.0,bottom: 7.0),
child: Text(
"Groups",
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.w500,
),
),
),
decoration: BoxDecoration(
border: Border(
bottom:BorderSide(color: Colors.black,width: 3.0),
),
),
),
SizedBox(
width: 50.0,
),
GestureDetector(
onTap: (){
Navigator.pushNamed(context, StudentMultiProfile.id);
},
child: Padding(
padding: EdgeInsets.only(left: 20.0,right: 20.0,bottom: 7.0),
child: Text(
"Profile",
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.w500,
),
),
),
),
],
),
),
),
),
],
),
),
SizedBox(
height: 20.0,
),
StreamBuilder<QuerySnapshot>(
stream: _firestore.collection('studentGroups').where('email', isEqualTo: email).snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData)
return LinearProgressIndicator();
else {
final docs = snapshot.data!.docs;
return Expanded(
child: SizedBox(
height: 500.0,
child: ListView.builder(
itemCount: docs.length,
itemBuilder: (context, i) {
final data = docs[i];
return Padding(
padding: EdgeInsets.symmetric(
vertical: 5.0, horizontal: 15.0),
child: Padding(
padding: EdgeInsets.only(bottom: 5.0),
child: Row(
mainAxisAlignment:
MainAxisAlignment.start,
children: [
CircleAvatar(
child: Column(
mainAxisAlignment:
MainAxisAlignment.center,
children: [
Text(
data['groupBatch'] +'(' + data['groupSection'] + ')',
style: TextStyle(
color: Colors.white,fontSize: 17,fontWeight: FontWeight.w500),
),
]),
radius: 28,
backgroundColor: Color((math
.Random()
.nextDouble() *
0xFFFF55)
.toInt())
.withOpacity(0.6),
),
SizedBox(
width: 10.0,
),
GestureDetector(
onTap: (){
print(data['teacher'] + "teach");
Provider.of<TaskData>(context,listen:false).getGroup(data['groupName'], data['groupBatch']);
Provider.of<TaskData>(context,listen:false).getSubGroup(data['groupSection'],data['classCode'],data['teacher']);
Navigator.pushNamed(context, ChatScreen.id);
},
child: Container(
width: MediaQuery.of(context).size.width - 100,
padding: EdgeInsets.only(bottom: 8.0),
decoration: BoxDecoration(
border: Border(
bottom:
BorderSide(color: Color(0xFF808080).withOpacity(0.6)),
),
),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
data['groupName'] + '-' + data['groupBatch'] + '(' + data['groupSection'] + ')',
style: TextStyle(
fontSize: 19.0,
fontWeight:
FontWeight.w600),
),
SizedBox(height: 2.0,),
Text(
'Welcome to our group',
style: TextStyle(
fontSize: 16.0,
fontWeight:
FontWeight.w400,
color: Colors.grey),
),
]),
),
),
]),
),
);
}
),
),
);
}
}),
],
)));
}
}
| 0 |
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/student-screens/quiz.dart | import 'package:cms/student-screens/quiz-page.dart';
import 'package:cms/student-screens/quizBrain.dart';
import 'package:flutter/material.dart';
QuestionBrain questionBrain = QuestionBrain();
class Quiz extends StatefulWidget {
static String id = 'quiz';
@override
State<Quiz> createState() => _QuizState();
}
class _QuizState extends State<Quiz> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.grey.shade900,
body: SafeArea(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 10.0),
child: QuizPage(),
),
),
);
}
}
| 0 |
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/student-screens/student-video-resources.dart | import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:cms/components/custom-drawer.dart';
import 'package:cms/components/navigation.dart';
import 'package:cms/components/task-data.dart';
import 'package:colorful_safe_area/colorful_safe_area.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:video_player/video_player.dart';
import '../screens/add-video.dart';
class StudentVideoResources extends StatefulWidget {
static String id = 'video-resources';
@override
_StudentVideoResourcesState createState() => _StudentVideoResourcesState();
}
class _StudentVideoResourcesState extends State<StudentVideoResources> {
final GlobalKey<ScaffoldState> _globalKey = GlobalKey<ScaffoldState>();
List<String> videoRef = [];
late VideoPlayerController _videoPlayerController;
@override
Widget build(BuildContext context) {
String code = Provider.of<TaskData>(context, listen: false).courseCode;
String batch = Provider.of<TaskData>(context, listen: false).courseBatch;
return Scaffold(
key: _globalKey,
drawer: CustomDrawer(),
body: ColorfulSafeArea(
color: Color(0xFF13192F),
child: Column(
children: [
CustomNavigation("Videos",(value) {
_globalKey.currentState?.openDrawer();
}),
StreamBuilder<QuerySnapshot>(
stream: FirebaseFirestore.instance
.collection('videoURLs').where('courseCode', isEqualTo:code).where('courseBatch', isEqualTo: batch)
.snapshots(),
builder: (context, snapshot) {
return !snapshot.hasData
?Center(
child: SpinKitDoubleBounce(
color: Color(0xFF13192F),
size: 50.0,
),
)
: Container(
padding: EdgeInsets.all(4.0),
child: GridView.builder(
scrollDirection: Axis.vertical,
shrinkWrap: true,
itemCount: snapshot.data?.docs.length,
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3),
itemBuilder: (context, index) {
final data = snapshot.data!.docs[index];
_videoPlayerController = VideoPlayerController.network(data['url'])..initialize().then((value) {
_videoPlayerController.play();
});
return Container(
margin: EdgeInsets.all(3.0),
child: AspectRatio(
aspectRatio: _videoPlayerController.value.aspectRatio,
child: VideoPlayer(
_videoPlayerController
),
)
);
}));
},
)
// FutureBuilder(
// future: listFiles(),
// builder: (BuildContext context, AsyncSnapshot<ListResult> snapshot){
// if(snapshot.connectionState == ConnectionState.done && snapshot.hasData){
// return Container(
// // child: ListView.builder(
// // shrinkWrap: true,
// // itemCount: snapshot.data!.items.length,
// // itemBuilder: (BuildContext context, int index){
// // Future<String> link = downloadURL(snapshot.data!.items[index].name) ;
// // return Container(
// // child: Text(link.toString()),
// // //Text(,style: TextStyle(color: Colors.black)),
// // );
// // }
// // ),
// );
// }
// if(snapshot.connectionState == ConnectionState.waiting || !snapshot.hasData){
// return CircularProgressIndicator();
// }
// return Container();
// },
// )
],
)));
}
// Future<String> downloadURL(imageName) async{
// print('ba;');
// String email = Provider.of<TaskData>(context, listen: false).userEmail;
// String code = Provider.of<TaskData>(context, listen: false).courseCode;
// String batch = Provider.of<TaskData>(context, listen: false).courseBatch;
// print('url;' + code + email+ batch);
// String down = '';
// String downloadURL = await FirebaseStorage.instance.ref('imageResources/$email/$code-$batch/$imageName').getDownloadURL().then((value) {
// setState(() {
// imgRef.add(value);
// });
// return "";
// }
// );
// return "";
// }
//
// Future<ListResult> listFiles()async{
// String email = Provider.of<TaskData>(context, listen: false).userEmail;
// String code = Provider.of<TaskData>(context, listen: false).courseCode;
// String batch = Provider.of<TaskData>(context, listen: false).courseBatch;
// ListResult results = await FirebaseStorage.instance.ref('imageResources/$email/$code-$batch').listAll();
// return results;
// }
//
// Future selectFiles() async {
// FilePickerResult? results = (await FilePicker.platform.pickFiles(allowMultiple: true,type: FileType.image));
// if (results == null) return;
// List<PlatformFile> files = results.files;
// files.forEach((element) {
// uploadFiles(File(element.path!));
// });
//
// }
// Future uploadFiles(fileName) async{
// String email = Provider.of<TaskData>(context, listen: false).userEmail;
// String code = Provider.of<TaskData>(context, listen: false).courseCode;
// String batch = Provider.of<TaskData>(context, listen: false).courseBatch;
// String newFileName = fileName.toString().split('/').last;
// final destination = 'imageResources/$email/$code-$batch/$newFileName';
// try{
// final ref = FirebaseStorage.instance.ref(destination);
// ref.putFile(fileName!);
// }
// catch(e){
// return null;
// }
// }
}
| 0 |
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/student-screens/student-resources.dart | import 'package:cms/components/custom-drawer.dart';
import 'package:cms/components/navigation.dart';
import 'package:cms/screens/subgroup-screen.dart';
import 'package:cms/screens/video.resource.dart';
import 'package:cms/student-screens/student-image-resources.dart';
import 'package:cms/student-screens/student-video-resources.dart';
import 'package:colorful_safe_area/colorful_safe_area.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../screens/image-resource.dart';
class StudentResources extends StatefulWidget {
static String id="student-resources";
@override
State<StudentResources> createState() => _StudentResourcesState();
}
class _StudentResourcesState extends State<StudentResources> {
final GlobalKey<ScaffoldState> _globalKey = GlobalKey<ScaffoldState>();
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
key: _globalKey,
drawer:CustomDrawer() ,
body: ColorfulSafeArea(
color: Color(0xFF13192F),
child: Column(
children: [
CustomNavigation("Resources",(value){
_globalKey.currentState?.openDrawer();
}),
Container(
child: Stack(
children: [
Container(
height: 28.0,
margin: EdgeInsets.only(right: 50.0),
color: Color(0xFF13192F),
),
Container(
height: 35.0,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30.0))),
),
],
),
),
Expanded(
child: Row(
children: [
Expanded(
child: Padding(
padding: const EdgeInsets.only(left: 10.0, top: 45.0),
child: GestureDetector(
onTap: (){
Navigator.pushNamed(context, StudentImageResources.id);
},
child: Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'Images',
style: TextStyle(
fontSize: 30.0,
fontWeight: FontWeight.bold,
),
),
],
),
margin: EdgeInsets.all(15.0),
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.2),
spreadRadius: 3,
blurRadius: 3,
offset: Offset(0, 2),
),
],
color: Colors.white,
borderRadius: BorderRadius.circular(20.0),
),
),
),
),
),
Expanded(child:
Padding(
padding: const EdgeInsets.only(right: 10.0, top: 45.0),
child: GestureDetector(
onTap: (){
Navigator.pushNamed(context, StudentVideoResources.id);
},
child: Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'Videos',
style: TextStyle(
fontSize: 30.0,
fontWeight: FontWeight.bold,
),
),
],
),
margin: EdgeInsets.all(15.0),
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.2),
spreadRadius: 3,
blurRadius: 3,
offset: Offset(0, 2),
),
],
color: Colors.white,
borderRadius: BorderRadius.circular(20.0),
),
),
),
),
),
],
),
),
Expanded(
child: Row(
children: [
Expanded(
child: Padding(
padding: const EdgeInsets.only(left: 10.0, bottom: 45.0),
child: Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'Docs',
style: TextStyle(
fontSize: 30.0,
fontWeight: FontWeight.bold,
),
),
],
),
margin: EdgeInsets.all(15.0),
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.2),
spreadRadius: 3,
blurRadius: 3,
offset: Offset(0, 2),
),
],
color: Colors.white,
borderRadius: BorderRadius.circular(20.0),
),
),
),
),
Expanded(child:
Padding(
padding: const EdgeInsets.only(right: 10.0, bottom: 45.0),
child: Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'Links',
style: TextStyle(
fontSize: 30.0,
fontWeight: FontWeight.bold,
),
),
],
),
margin: EdgeInsets.all(15.0),
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.2),
spreadRadius: 3,
blurRadius: 3,
offset: Offset(0, 2),
),
],
color: Colors.white,
borderRadius: BorderRadius.circular(20.0),
),
),
),
),
],
),
),
],
),
),
);
}
} | 0 |
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/student-screens/join-group.dart | import 'package:cms/components/custom-drawer.dart';
import 'package:cms/components/dropdown-field.dart';
import 'package:cms/components/input-field2.dart';
import 'package:cms/components/navigation.dart';
import 'package:cms/components/task-data.dart';
import 'package:cms/screens/group-screen.dart';
import 'package:cms/student-screens/student-group-screen.dart';
import 'package:colorful_safe_area/colorful_safe_area.dart';
import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:provider/provider.dart';
import '../components/multi-dropdown-field.dart';
class JoinGroup extends StatefulWidget {
static String id = 'join-group';
@override
_JoinGroupState createState() => _JoinGroupState();
}
class _JoinGroupState extends State<JoinGroup> {
final _firestore = FirebaseFirestore.instance;
final GlobalKey<ScaffoldState> _globalKey = GlobalKey<ScaffoldState>();
late String classCode;
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
key: _globalKey,
drawer: CustomDrawer(),
body: ColorfulSafeArea(
color: Color(0xFF13192F),
child: Column(
children: [
CustomNavigation("Join Groups",(value){
_globalKey.currentState?.openDrawer();
}),
Container(
child: Stack(
children: [
Container(
height: 28.0,
margin: EdgeInsets.only(right: 50.0),
color: Color(0xFF13192F),
),
Container(
height: 35.0,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30.0))),
),
],
),
),
Padding(
padding:
EdgeInsets.symmetric(horizontal: 30.0, vertical: 10.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
InputField2("Enter Class Code", false, (value) {
classCode = value;
}),
SizedBox(
height: 15.0,
),
Material(
color: Color(0xFF13192F),
borderRadius: BorderRadius.all(Radius.circular(10.0)),
child: MaterialButton(
child: const Padding(
padding: EdgeInsets.symmetric(
vertical: 15.0, horizontal: 20.0),
child: Text(
"Join Group",
style: TextStyle(
color: Colors.white, fontSize: 16.0),
),
),
onPressed: () async {
_firestore.collection('subGroups').where('classCode', isEqualTo: classCode).get().then((value){
if(value.docs.length == 0){
openDialog();
}
else{
final data = value.docs[0];
_firestore.collection('studentGroups').add({
'groupName': data['groupName'],
'groupBatch': data['groupBatch'],
'groupSection': data['groupSection'],
'classCode': data['classCode'],
'teacher': data['email'],
'email':
Provider.of<TaskData>(context, listen: false)
.userEmail
});
Navigator.pushNamed(context, StudentGroupScreen.id);
}
}).catchError((e){
print(e);
});
},
),
),
],
),
)
],
)));
}
Future openDialog() => showDialog(
context: context,
builder: (context) => AlertDialog(
title: Text('Class Not Found'),
content: Text('Sorry the given code is not valid!!'),
actions: [
TextButton(
onPressed: () {
Navigator.pop(context);
},
child: Text('Ok'),
)
],
),
);
}
| 0 |
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/student-screens/stundet-edit-profile.dart | import 'dart:io';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:cms/components/input-field2.dart';
import 'package:cms/components/multi-dropdown-field.dart';
import 'package:cms/screens/group-screen.dart';
import 'package:cms/student-screens/student-group-screen.dart';
import 'package:file_picker/file_picker.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_storage/firebase_storage.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:cms/components/task-data.dart';
import 'package:rflutter_alert/rflutter_alert.dart';
import 'package:image_picker/image_picker.dart';
import '../components/dropdown-field.dart';
class StudentEditProfile extends StatefulWidget {
static String id = 'student-edit-profile';
@override
_StudentEditProfileState createState() => _StudentEditProfileState();
}
class _StudentEditProfileState extends State<StudentEditProfile> {
late PickedFile _imageFile;
final ImagePicker _picker = ImagePicker();
late bool isImage = false;
final user = FirebaseAuth.instance.currentUser;
File? file = null;
void takePhoto(ImageSource source) async {
final pickedFile = await _picker.getImage(
source: source,
);
setState(() {
_imageFile = pickedFile!;
});
File img = File(_imageFile.path);
String newFileName = img.path.toString().split('/').last;
final ref = FirebaseStorage.instance.ref().child('profileImages/${user?.email}/$newFileName');
await ref.putFile(img).whenComplete(()async{
await ref.getDownloadURL().then((value){
user?.updatePhotoURL(value);
Provider.of<TaskData>(context, listen: false).updatePhoto(value);
}
);
});
}
final _firestore = FirebaseFirestore.instance;
String _dropDownValue = 'Select Your Department';
List<String> items = ['Select Your Department','CSE', 'EEE','Civil Engineering','Business Administration', 'LAW', 'English', 'Architecture', 'Islamic Study',
'Public Health','Tourism and Hospitality Management','Bangla'];
late String mobile = '';
late String bio = '';
late String batch = '';
@override
void initState() {
// TODO: implement initState
super.initState();
getData();
}
void getData()async{
await FirebaseFirestore.instance.collection('studentProfile').where('email', isEqualTo: user?.email).get().then((value){
final data = value.docs[0];
setState(() {
_dropDownValue = data['dept'];
batch = data['batch'];
bio = data['bio'];
mobile = data['mobile'];
});
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text(
'Student Profile',
),
backgroundColor: Color(0xFF13192F),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
_firestore.collection('studentProfile').doc(Provider.of<TaskData>(context, listen: false).userEmail).update({
'batch': batch,
'dept': _dropDownValue,
'bio': bio,
'mobile': mobile,
});
Navigator.pushNamed(context, StudentGroupScreen.id);
},
backgroundColor: Color(0xFF13192F),
child: Icon(Icons.arrow_forward_sharp),
),
resizeToAvoidBottomInset: true,
body: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const SizedBox(
height: 40.0,
),
Stack(
children: [
CircleAvatar(
radius: 100.0,
backgroundColor: Color(0xFF13192F),
child: CircleAvatar(
radius: 95.0,
backgroundImage: Provider.of<TaskData>(context).userPhoto ==
''
? NetworkImage('https://cdn.pixabay.com/photo/2015/10/05/22/37/blank-profile-picture-973460_1280.png')
: NetworkImage(Provider.of<TaskData>(context).userPhoto)
as ImageProvider, // : FileImage() as ImageProvider,
backgroundColor: Colors.white,
),
),
Positioned(
top: 150,
left: 150,
child: GestureDetector(
onTap: () {
Alert(
context: context,
content: Column(
children: [
Material(
elevation: 4,
child: DialogButton(
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: const [
Icon(Icons.camera),
Text(
"Camera",
style: TextStyle(
color: Colors.black, fontSize: 20),
),
],
),
onPressed: () {
takePhoto(ImageSource.camera);
Navigator.pop(context);
},
color: Colors.white,
),
),
const SizedBox(
height: 10,
),
Material(
elevation: 4,
child: DialogButton(
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: const [
Icon(Icons.image),
Text(
"Gallery",
style: TextStyle(
color: Colors.black, fontSize: 20),
),
],
),
color: Colors.white,
onPressed: () {
takePhoto(ImageSource.gallery);
Navigator.pop(context);
}),
),
],
),
buttons: [],
).show();
},
child: const CircleAvatar(
backgroundColor: Color(0xFF13192F),
child: Icon(
Icons.add,
color: Colors.white,
),
),
),
),
],
),
SizedBox(height: 10.0),
Text(
Provider.of<TaskData>(context).userName,
style: TextStyle(fontSize: 30.0, fontWeight: FontWeight.w600),
),
SizedBox(
height: 10.0,
),
Padding(
padding: EdgeInsets.all(30.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
//crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
DropdownField(_dropDownValue, items, (value) {
setState(() {
_dropDownValue = value;
});
}),
SizedBox(
height: 10.0,
),
InputField2(batch, false, (value){
}),
SizedBox(
height: 10.0,
),
InputField2(bio, false, (value) {
setState(() {
bio = value;
});
}),
SizedBox(
height: 10.0,
),
InputField2(mobile, false, (value) {
setState(() {
mobile = value;
});
}),
SizedBox(
height: 10.0,
),
],
),
)
],
),
),
);
}
}
| 0 |
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/student-screens/student-register.dart | import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:cms/components/error-message.dart';
import 'package:cms/components/input-field.dart';
import 'package:cms/components/task-data.dart';
import 'package:cms/student-screens/student-login.dart';
import 'package:email_validator/email_validator.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:password_strength/password_strength.dart';
import 'package:provider/provider.dart';
import 'student-verification.dart';
class StudentRegister extends StatefulWidget {
static String id = 'student-register';
const StudentRegister({Key? key}) : super(key: key);
@override
_StudentRegisterState createState() => _StudentRegisterState();
}
class _StudentRegisterState extends State<StudentRegister> {
final _auth = FirebaseAuth.instance;
late String name;
late String email;
late String password;
late String password2;
late String errorMessage = '';
late bool spinner = false;
static String pattern = r'^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[!@#\$&*~]).{8,}$';
RegExp regex = new RegExp(pattern);
String setter() {
return name;
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: spinner
? const Center(
child: SpinKitDoubleBounce(
color: Color(0xFF13192F),
size: 50.0,
),
)
: Padding(
padding: const EdgeInsets.symmetric(horizontal: 30.0),
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Center(
child: Material(
borderRadius: BorderRadius.circular(100),
elevation: 5.0,
child: CircleAvatar(
backgroundColor: Color(0xFF13192F),
radius: 73.0,
child: CircleAvatar(
radius: 70.0,
backgroundImage: AssetImage('images/CMS-Logo.png'),
),
),
),
),
SizedBox(
height: 30.0,
),
Text("Create an account as Student",textAlign: TextAlign.center ,style: TextStyle(color: Color(0xFF13192F),fontSize: 20.0,fontWeight: FontWeight.bold),),
const SizedBox(
height: 30.0,
),
InputField('Enter your name', false, (value) {
name = value;
}),
const SizedBox(
height: 10.0,
),
InputField('Enter your email', false, (value) {
email = value;
}),
const SizedBox(
height: 10.0,
),
InputField('Enter a password', true, (value) {
password = value;
}),
const SizedBox(
height: 10.0,
),
InputField('Confirm password', true, (value) {
password2 = value;
}),
const SizedBox(
height: 10.0,
),
ErrorMessage(errorMessage),
Padding(
padding: const EdgeInsets.symmetric(vertical: 16.0),
child: Material(
borderRadius: const BorderRadius.all(
Radius.circular(32.0),
),
color: Color(0xFF13192F),
elevation: 5.0,
child: MaterialButton(
onPressed: () async {
if(!EmailValidator.validate(email)){
setState(() {
errorMessage = "Email Not Valid";
});
}
else if(!regex.hasMatch(password)){
print('1234');
setState(() {
errorMessage = "Your password is weak";
});
}
else if (password != password2) {
setState(() {
errorMessage = "Password didn't match";
});
} else {
setState(() {
spinner = true;
});
try {
await Firebase.initializeApp();
UserCredential? result;
if (email != null && password != null) {
result =
await _auth.createUserWithEmailAndPassword(
email: email, password: password);
}
if (result != null) {
await _auth.currentUser
?.updateDisplayName(name+" student");
Provider.of<TaskData>(context, listen: false)
.getUser();
FirebaseFirestore.instance.collection('students').add({'email': _auth.currentUser?.email});
Navigator.pushNamed(context, StudentVerification.id);
}
setState(() {
spinner = false;
});
} catch (e) {
setState(() {
spinner = false;
errorMessage =
e.toString() + password + name + email;
});
}
}
},
child: const Text(
'Sign Up',
style: TextStyle(color: Colors.white),
),
),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text('You don\'t have an account?'),
TextButton(
onPressed: () {
Navigator.pushNamed(context, StudentLogin.id);
},
style: TextButton.styleFrom(
primary: Color(0xFF13192F), // Text Color
),
child: const Text(
'Login',
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 16.0),
),
)
],
),
],
),
),
),
);
}
}
| 0 |
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/student-screens/student-profile.dart | import 'dart:io';
import 'dart:ui';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:cms/components/navigation.dart';
import 'package:cms/components/task-data.dart';
import 'package:colorful_safe_area/colorful_safe_area.dart';
import 'package:dio/dio.dart';
import 'package:firebase_storage/firebase_storage.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:gallery_saver/gallery_saver.dart';
import 'package:path_provider/path_provider.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../components/custom-drawer.dart';
class StudentProfile extends StatefulWidget {
static String id = "student-profile";
@override
State<StudentProfile> createState() => _StudentProfileState();
}
class _StudentProfileState extends State<StudentProfile> {
final GlobalKey<ScaffoldState> _globalKey = GlobalKey<ScaffoldState>();
final _firestore = FirebaseFirestore.instance;
double downloadProgress = 0.0;
bool alreadyDisplayed = false;
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
key: _globalKey,
drawer: CustomDrawer(),
body: ColorfulSafeArea(
color: Color(0xFF13192F),
child: StreamBuilder<QuerySnapshot>(
stream: _firestore.collection('studentProfile').where('email', isEqualTo:Provider.of<TaskData>(context).userEmail).snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData)
return LinearProgressIndicator();
else {
final docs = snapshot.data!.docs;
return ListView.builder(
scrollDirection: Axis.vertical,
itemCount: docs.length,
shrinkWrap: true,
itemBuilder: (context, i) {
if (docs[i].exists &&
!alreadyDisplayed) {
alreadyDisplayed = true;
final data = docs[i];
return Column(
children: [
CustomNavigation("Profile",(value) {
_globalKey.currentState?.openDrawer();
}),
Container(
child: Stack(
children: [
Container(
height: 28.0,
margin:
EdgeInsets.only(right: 50.0, bottom: 1.0),
color: Color(0xFF13192F),
),
Container(
height: 35.0,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30.0))),
),
],
),
),
Container(
child: Column(
children: [
Padding(
padding: EdgeInsets.all(28.0),
child: Material(
borderRadius: BorderRadius.circular(100.0),
elevation: 3.0,
child: CircleAvatar(
backgroundColor: Color(0xFF13192F),
radius: 78.0,
child: CircleAvatar(
backgroundImage: Provider.of<TaskData>(
context)
.userPhoto ==
''
? NetworkImage(
'https://cdn.pixabay.com/photo/2015/10/05/22/37/blank-profile-picture-973460_1280.png')
: NetworkImage(Provider.of<
TaskData>(context)
.userPhoto),
radius: 75.0,
),
),
),
),
],
),
),
Column(
children: [
Text(
Provider.of<TaskData>(context).userName,
style: TextStyle(
fontSize: 27.0,
color: Color(0xFF13192F),
fontWeight: FontWeight.bold,
),
),
Text(
"Batch ${data['batch']}",
style: TextStyle(
fontSize: 20.0,
color: Color(0xFF13192F),
fontWeight: FontWeight.bold,
),
),
Text(
'Department of ' + data['dept'],
style: TextStyle(
fontSize: 20.0,
color: Color(0xFF13192F),
fontWeight: FontWeight.bold,
),
),
],
),
Row(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 30.0,
),
Padding(
padding: const EdgeInsets.only(
left: 25.0, bottom: 20.0),
child: SizedBox(
width: MediaQuery.of(context).size.width - 25.0,
child: Text(
data['bio'],
style: TextStyle(
fontSize: 20.0,
color: Color(0xFF13192F),
fontWeight: FontWeight.bold,
),
),
),
),
],
),
],
),
Row(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(
left: 25.0, top: 20.0),
child: Text(
'Phone: ' + data['mobile'],
style: TextStyle(
fontSize: 20.0,
color: Color(0xFF13192F),
),
),
),
],
),
],
),
Row(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(
left: 25.0, top: 20.0),
child: Text(
'Email: ' +
Provider.of<TaskData>(context)
.userEmail,
style: TextStyle(
fontSize: 20.0,
color: Color(0xFF13192F),
),
),
),
SizedBox(
height: 40.0,
),
],
),
],
),
],
);
} else {
return Container();
}
},
);
}
}),
),
);
}
}
| 0 |
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/student-screens/quizBrain.dart | import 'package:cms/student-screens/quiz-question.dart';
class QuestionBrain {
int _questionNumber = 0;
final List<Question> _questions = [
Question(questionText: 'Some cats are actually allergic to humans', answers: true),
Question(questionText: 'You can lead a cow down stairs but not up stairs.', answers: false),
Question(
questionText: 'Approximately one quarter of human bones are in the feet.',
answers: true),
Question(questionText: 'A slug\'s blood is green.', answers: true),
Question(questionText: 'Buzz Aldrin\'s mother\'s maiden name was \"Moon\".', answers: true),
Question(questionText: 'It is illegal to pee in the Ocean in Portugal.', answers: true),
Question(
questionText: 'No piece of square dry paper can be folded in half more than 7 times.',
answers: false),
Question(
questionText: 'In London, UK, if you happen to die in the House of Parliament, you are technically entitled to a state funeral, because the building is considered too sacred a place.',
answers: true),
Question(
questionText: 'The loudest sound produced by any animal is 188 decibels. That animal is the African Elephant.',
answers: false),
Question(
questionText: 'The total surface area of two human lungs is approximately 70 square metres.',
answers: true),
Question(questionText: 'Google was originally called \"Backrub\".', answers: true),
Question(
questionText: 'Chocolate affects a dog\'s heart and nervous system; a few ounces are enough to kill a small dog.',
answers: true),
Question(
questionText: 'In West Virginia, USA, if you accidentally hit an animal with your car, you are free to take it home to eat.',
answers: true),
];
bool nextQuestion(){
if(_questionNumber < _questions.length - 1){
_questionNumber++;
return true;
}
return false;
}
String getQuestion(){
return _questions[_questionNumber].questionText;
}
bool getAnswer(){
return _questions[_questionNumber].answers;
}
void reset(){
_questionNumber=0;
}
}
| 0 |
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/student-screens/student-login-verification.dart | import 'dart:async';
import 'package:cms/student-screens/student-group-screen.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
class StudentLoginVerification extends StatefulWidget {
static String id = 'student-login-verification';
@override
_StudentLoginVerificationState createState() => _StudentLoginVerificationState();
}
class _StudentLoginVerificationState extends State<StudentLoginVerification> {
bool isVarified = false;
bool canResendEmail = true;
Timer? timer;
Color color = Color(0xFF808080);
String sent = "A verification email has been sent to your email.";
@override
void initState(){
super.initState();
isVarified = FirebaseAuth.instance.currentUser!.emailVerified;
if(!isVarified) {
sendVarificationEmail();
timer = Timer.periodic(Duration(seconds: 5), (_){
checkEmailVarified();
});
}
}
@override
void dispose(){
timer?.cancel();
super.dispose();
}
Future checkEmailVarified()async{
await FirebaseAuth.instance.currentUser!.reload();
setState(() {
isVarified = FirebaseAuth.instance.currentUser!.emailVerified;
});
if(isVarified)timer?.cancel();
}
Future sendVarificationEmail() async{
setState(() {
color = Color(0xFF808080);
canResendEmail = false;
});
final user = FirebaseAuth.instance.currentUser!;
await user.sendEmailVerification();
await Future.delayed(Duration(seconds: 5));
setState(() {
canResendEmail = true;
color = Color(0xFF13192F);
});
}
Widget build(BuildContext context) {
if(isVarified) {
return StudentGroupScreen();
} else {
return Scaffold(
appBar: AppBar(
title: const Text(
'User Verification',
),
backgroundColor: Color(0xFF13192F),
),
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(sent, style: TextStyle(fontSize: 20.0),
textAlign: TextAlign.center,),
const SizedBox(height: 10.0,),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 100.0),
child: TextButton(
style: TextButton.styleFrom(
backgroundColor: color,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: const [
Icon(Icons.mail, size: 24.0, color: Colors.white,),
SizedBox(width: 10.0,),
Text('Resend',
style: TextStyle(fontSize: 24.0, color: Colors.white),),
],
),
onPressed: (){
canResendEmail?
setState(() {
sent = "A verification email has been resent to your email.";
sendVarificationEmail();
}):null;
}
,
),
)
],
),
);
}
}
}
| 0 |
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/student-screens/quiz-question.dart | class Question {
String questionText;
bool answers;
Question({required this.questionText,required this.answers}){
}
} | 0 |
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/student-screens/student-image-resources.dart | import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:transparent_image/transparent_image.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:cms/components/custom-drawer.dart';
import 'package:cms/components/navigation.dart';
import 'package:cms/components/task-data.dart';
import 'package:cms/screens/add-group.dart';
import 'package:cms/screens/add-image.dart';
import 'package:colorful_safe_area/colorful_safe_area.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class StudentImageResources extends StatefulWidget {
static String id = 'image-resources';
@override
_StudentImageResourcesState createState() => _StudentImageResourcesState();
}
class _StudentImageResourcesState extends State<StudentImageResources> {
final GlobalKey<ScaffoldState> _globalKey = GlobalKey<ScaffoldState>();
List<String> imgRef = [];
@override
Widget build(BuildContext context) {
String email = Provider.of<TaskData>(context, listen: false).userEmail;
String code = Provider.of<TaskData>(context, listen: false).courseCode;
String batch = Provider.of<TaskData>(context, listen: false).courseBatch;
return Scaffold(
key: _globalKey,
drawer: CustomDrawer(),
body: ColorfulSafeArea(
color: Color(0xFF13192F),
child: Column(
children: [
CustomNavigation("Image Resources",(value) {
_globalKey.currentState?.openDrawer();
}),
StreamBuilder<QuerySnapshot>(
stream: FirebaseFirestore.instance
.collection('imageURLs').where('courseCode', isEqualTo:code).where('courseBatch', isEqualTo: batch)
.snapshots(),
builder: (context, snapshot) {
return !snapshot.hasData
?Center(
child: SpinKitDoubleBounce(
color: Color(0xFF13192F),
size: 50.0,
),
)
: Container(
padding: EdgeInsets.all(4.0),
child: GridView.builder(
scrollDirection: Axis.vertical,
shrinkWrap: true,
itemCount: snapshot.data?.docs.length,
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3),
itemBuilder: (context, index) {
final data = snapshot.data!.docs[index];
return Container(
margin: EdgeInsets.all(3.0),
child: FadeInImage.assetNetwork(
fadeInDuration: Duration(seconds: 1),
fadeInCurve: Curves.bounceIn,
fit: BoxFit.cover,
image: data['url'],
placeholder: 'images/loading.gif'),
);
}));
},
)
// FutureBuilder(
// future: listFiles(),
// builder: (BuildContext context, AsyncSnapshot<ListResult> snapshot){
// if(snapshot.connectionState == ConnectionState.done && snapshot.hasData){
// return Container(
// // child: ListView.builder(
// // shrinkWrap: true,
// // itemCount: snapshot.data!.items.length,
// // itemBuilder: (BuildContext context, int index){
// // Future<String> link = downloadURL(snapshot.data!.items[index].name) ;
// // return Container(
// // child: Text(link.toString()),
// // //Text(,style: TextStyle(color: Colors.black)),
// // );
// // }
// // ),
// );
// }
// if(snapshot.connectionState == ConnectionState.waiting || !snapshot.hasData){
// return CircularProgressIndicator();
// }
// return Container();
// },
// )
],
)));
}
// Future<String> downloadURL(imageName) async{
// print('ba;');
// String email = Provider.of<TaskData>(context, listen: false).userEmail;
// String code = Provider.of<TaskData>(context, listen: false).courseCode;
// String batch = Provider.of<TaskData>(context, listen: false).courseBatch;
// print('url;' + code + email+ batch);
// String down = '';
// String downloadURL = await FirebaseStorage.instance.ref('imageResources/$email/$code-$batch/$imageName').getDownloadURL().then((value) {
// setState(() {
// imgRef.add(value);
// });
// return "";
// }
// );
// return "";
// }
//
// Future<ListResult> listFiles()async{
// String email = Provider.of<TaskData>(context, listen: false).userEmail;
// String code = Provider.of<TaskData>(context, listen: false).courseCode;
// String batch = Provider.of<TaskData>(context, listen: false).courseBatch;
// ListResult results = await FirebaseStorage.instance.ref('imageResources/$email/$code-$batch').listAll();
// return results;
// }
//
// Future selectFiles() async {
// FilePickerResult? results = (await FilePicker.platform.pickFiles(allowMultiple: true,type: FileType.image));
// if (results == null) return;
// List<PlatformFile> files = results.files;
// files.forEach((element) {
// uploadFiles(File(element.path!));
// });
//
// }
// Future uploadFiles(fileName) async{
// String email = Provider.of<TaskData>(context, listen: false).userEmail;
// String code = Provider.of<TaskData>(context, listen: false).courseCode;
// String batch = Provider.of<TaskData>(context, listen: false).courseBatch;
// String newFileName = fileName.toString().split('/').last;
// final destination = 'imageResources/$email/$code-$batch/$newFileName';
// try{
// final ref = FirebaseStorage.instance.ref(destination);
// ref.putFile(fileName!);
// }
// catch(e){
// return null;
// }
// }
}
| 0 |
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/student-screens/quiz-page.dart | import 'package:cms/screens/group-info.dart';
import 'package:cms/student-screens/quiz.dart';
import 'package:flutter/material.dart';
import 'package:rflutter_alert/rflutter_alert.dart';
class QuizPage extends StatefulWidget {
static String id = 'quiz-page';
@override
_QuizPageState createState() => _QuizPageState();
}
class _QuizPageState extends State<QuizPage> {
List<Icon> scorekeeper = [];
void displayAnswer(bool ans) {
bool correctAns = questionBrain.getAnswer();
setState(() {
if (ans == correctAns) {
scorekeeper.add(
const Icon(
Icons.check,
color: Colors.green,
),
);
} else {
scorekeeper.add(
const Icon(
Icons.close,
color: Colors.red,
),
);
}
bool res = questionBrain.nextQuestion();
if (!res) {
questionBrain.reset();
scorekeeper = [];
Alert(
context: context,
title: 'Finished!',
desc: 'You\'ve reached the end of the quiz.',
buttons: [
DialogButton(
child:const Text(
"Start Again",
style: TextStyle(color: Colors.white, fontSize: 20),
),
onPressed: () {
Navigator.pushNamed(context, Quiz.id);
},
color: Colors.red,
),
DialogButton(
child:const Text(
"Cancel",
style: TextStyle(color: Colors.white, fontSize: 20),
),
color: Colors.green,
onPressed: () => Navigator.pushNamed(context, GroupInfo.id),
),
]
).show();
}
});
}
@override
Widget build(BuildContext context) {
return Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Expanded(
flex: 5,
child: Padding(
padding: EdgeInsets.all(10.0),
child: Center(
child: Text(
questionBrain.getQuestion(),
textAlign: TextAlign.center,
style: const TextStyle(
fontSize: 25.0,
color: Colors.white,
),
),
),
),
),
Expanded(
child: Padding(
padding: const EdgeInsets.all(15.0),
child: FlatButton(
textColor: Colors.white,
color: Colors.green,
child: const Text(
'True',
style: TextStyle(
color: Colors.white,
fontSize: 20.0,
),
),
onPressed: () {
//The user picked true.
displayAnswer(true);
},
),
),
),
Expanded(
child: Padding(
padding: const EdgeInsets.all(15.0),
child: FlatButton(
color: Colors.red,
child: const Text(
'False',
style: TextStyle(
fontSize: 20.0,
color: Colors.white,
),
),
onPressed: () {
//The user picked false.
displayAnswer(false);
},
),
),
),
//TODO: Add a Row here as your score keeper
Row(
children: scorekeeper,
)
],
);
}
} | 0 |
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/student-screens/student-verification.dart | import 'dart:async';
import 'package:cms/student-screens/student-group-screen.dart';
import 'package:cms/student-screens/student-profile-update.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
class StudentVerification extends StatefulWidget {
static String id = 'student-verification';
@override
_StudentVerificationState createState() => _StudentVerificationState();
}
class _StudentVerificationState extends State<StudentVerification> {
bool isVarified = false;
bool canResendEmail = true;
Timer? timer;
Color color = Color(0xFF808080);
String sent = "A verification email has been sent to your email.";
@override
void initState(){
super.initState();
isVarified = FirebaseAuth.instance.currentUser!.emailVerified;
if(!isVarified) {
sendVarificationEmail();
timer = Timer.periodic(Duration(seconds: 5), (_){
checkEmailVarified();
});
}
}
@override
void dispose(){
timer?.cancel();
super.dispose();
}
Future checkEmailVarified()async{
await FirebaseAuth.instance.currentUser!.reload();
setState(() {
isVarified = FirebaseAuth.instance.currentUser!.emailVerified;
});
if(isVarified)timer?.cancel();
}
Future sendVarificationEmail() async{
setState(() {
color = Color(0xFF808080);
canResendEmail = false;
});
final user = FirebaseAuth.instance.currentUser!;
await user.sendEmailVerification();
await Future.delayed(Duration(seconds: 5));
setState(() {
canResendEmail = true;
color = Color(0xFF13192F);
});
}
Widget build(BuildContext context) {
if(isVarified) {
return StudentProfileUpdate();
} else {
return Scaffold(
appBar: AppBar(
title: const Text(
'User Verification',
),
backgroundColor: Color(0xFF13192F),
),
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(sent, style: TextStyle(fontSize: 20.0),
textAlign: TextAlign.center,),
const SizedBox(height: 10.0,),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 100.0),
child: TextButton(
style: TextButton.styleFrom(
backgroundColor: color,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: const [
Icon(Icons.mail, size: 24.0, color: Colors.white,),
SizedBox(width: 10.0,),
Text('Resend',
style: TextStyle(fontSize: 24.0, color: Colors.white),),
],
),
onPressed: (){
canResendEmail?
setState(() {
sent = "A verification email has been resent to your email.";
sendVarificationEmail();
}):null;
}
,
),
)
],
),
);
}
}
}
| 0 |
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/student-screens/teacher-profile-2.dart | import 'dart:io';
import 'dart:ui';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:cms/components/navigation.dart';
import 'package:cms/components/task-data.dart';
import 'package:colorful_safe_area/colorful_safe_area.dart';
import 'package:dio/dio.dart';
import 'package:firebase_storage/firebase_storage.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:gallery_saver/gallery_saver.dart';
import 'package:path_provider/path_provider.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../components/custom-drawer.dart';
class TeacherProfile2 extends StatefulWidget {
static String id = "teacher-profile2";
@override
State<TeacherProfile2> createState() => _TeacherProfile2State();
}
class _TeacherProfile2State extends State<TeacherProfile2> {
final GlobalKey<ScaffoldState> _globalKey = GlobalKey<ScaffoldState>();
final _firestore = FirebaseFirestore.instance;
double downloadProgress = 0.0;
bool alreadyDisplayed = false;
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
key: _globalKey,
drawer: CustomDrawer(),
body: ColorfulSafeArea(
color: Color(0xFF13192F),
child: StreamBuilder<QuerySnapshot>(
stream: _firestore.collection('teacherProfile').where('email', isEqualTo:Provider.of<TaskData>(context).teacher).snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData)
return LinearProgressIndicator();
else {
final docs = snapshot.data!.docs;
return ListView.builder(
scrollDirection: Axis.vertical,
itemCount: docs.length,
shrinkWrap: true,
itemBuilder: (context, i) {
if (docs[i].exists &&
!alreadyDisplayed) {
alreadyDisplayed = true;
final data = docs[i];
return Column(
children: [
CustomNavigation("Teacher Profile",(value) {
_globalKey.currentState?.openDrawer();
}),
Container(
child: Stack(
children: [
Container(
height: 28.0,
margin:
EdgeInsets.only(right: 50.0, bottom: 1.0),
color: Color(0xFF13192F),
),
Container(
height: 35.0,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30.0))),
),
],
),
),
Container(
child: Column(
children: [
Padding(
padding: EdgeInsets.all(28.0),
child: Material(
borderRadius: BorderRadius.circular(100.0),
elevation: 3.0,
child: CircleAvatar(
backgroundColor: Color(0xFF13192F),
radius: 78.0,
child: CircleAvatar(
backgroundImage: data['photoURL'] ==
''
? NetworkImage(
'https://cdn.pixabay.com/photo/2015/10/05/22/37/blank-profile-picture-973460_1280.png')
: NetworkImage(data['photoURL']),
radius: 75.0,
),
),
),
),
],
),
),
Column(
children: [
Text(
data['name'],
style: TextStyle(
fontSize: 27.0,
color: Color(0xFF13192F),
fontWeight: FontWeight.bold,
),
),
Text(
data['position'],
style: TextStyle(
fontSize: 20.0,
color: Color(0xFF13192F),
fontWeight: FontWeight.bold,
),
),
Text(
'Department of ' + data['dept'],
style: TextStyle(
fontSize: 20.0,
color: Color(0xFF13192F),
fontWeight: FontWeight.bold,
),
),
],
),
Row(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 30.0,
),
Padding(
padding: const EdgeInsets.only(
left: 25.0, bottom: 20.0),
child: SizedBox(
width: MediaQuery.of(context).size.width - 25.0,
child: Text(
data['bio'],
style: TextStyle(
fontSize: 20.0,
color: Color(0xFF13192F),
fontWeight: FontWeight.bold,
),
),
),
),
],
),
],
),
Row(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(
left: 25.0, top: 20.0),
child: Text(
'Phone: ' + data['mobile'],
style: TextStyle(
fontSize: 20.0,
color: Color(0xFF13192F),
),
),
),
],
),
],
),
Row(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(
left: 25.0, top: 20.0),
child: Text(
'Email: ' +
Provider.of<TaskData>(context)
.teacher,
style: TextStyle(
fontSize: 20.0,
color: Color(0xFF13192F),
),
),
),
SizedBox(
height: 40.0,
),
],
),
],
),
StreamBuilder<QuerySnapshot>(
stream: FirebaseFirestore.instance
.collection('routineURLs')
.snapshots(),
builder: (context, snapshot) {
return !snapshot.hasData
? Center(
child:
CircularProgressIndicator(
backgroundColor: Colors.black,
),
)
: ListView.builder(
shrinkWrap: true,
itemCount: snapshot.data?.docs.length,
itemBuilder: (context, index) {
final data = snapshot.data!.docs[index];
final url = data['url'];
String email = Provider.of<TaskData>(
context,listen: false).teacher;
if (data['email'] == email) {
return Padding(
padding: EdgeInsets.symmetric(horizontal: 12.0),
child: GestureDetector(
onTap: (){
downloadFile(url, data['fileName']);
},
child: ListTile(
title: Text('Download Routine',style: TextStyle(fontSize: 18.0,color: Color(0xFF13192F)),),
trailing: IconButton(
onPressed: (){
downloadFile(url, data['fileName']);
},
icon: Icon(Icons.download_sharp),
),
),
),
);
}
else return Container();
});
})
],
);
} else {
return Container();
}
},
);
}
}),
),
);
}
Future downloadFile(final url, String fileName) async {
final tempDir = await getTemporaryDirectory();
final path = '${tempDir.path}/$fileName';
await Dio().download(url, path);
if(url.contains('.jpg') || url.contains('.png') || url.contains('.jpeg')){
await GallerySaver.saveImage(path,toDcim: true);
}
if(url.contains('.mp4')){
await GallerySaver.saveVideo(path,toDcim: true);
}
print('object');
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text("Download Completed"),));
}
}
| 0 |
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/screens/video.resource.dart | import 'dart:convert';
import 'dart:io';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:transparent_image/transparent_image.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:cms/components/custom-drawer.dart';
import 'package:cms/components/navigation.dart';
import 'package:cms/components/task-data.dart';
import 'package:cms/screens/add-group.dart';
import 'package:cms/screens/add-image.dart';
import 'package:colorful_safe_area/colorful_safe_area.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:video_player/video_player.dart';
import 'add-video.dart';
class VideoResources extends StatefulWidget {
static String id = 'video-resources';
@override
_VideoResourcesState createState() => _VideoResourcesState();
}
class _VideoResourcesState extends State<VideoResources> {
final GlobalKey<ScaffoldState> _globalKey = GlobalKey<ScaffoldState>();
List<String> videoRef = [];
late VideoPlayerController _videoPlayerController;
@override
Widget build(BuildContext context) {
String email = Provider.of<TaskData>(context, listen: false).userEmail;
String code = Provider.of<TaskData>(context, listen: false).courseCode;
String batch = Provider.of<TaskData>(context, listen: false).courseBatch;
return Scaffold(
key: _globalKey,
drawer: CustomDrawer(),
floatingActionButton: FloatingActionButton(
backgroundColor: Color(0xFF13192F),
onPressed: () {
Navigator.pushNamed(context, AddVideo.id);
},
child: Icon(Icons.upload_rounded),
),
body: ColorfulSafeArea(
color: Color(0xFF13192F),
child: Column(
children: [
CustomNavigation("Videos",(value) {
_globalKey.currentState?.openDrawer();
}),
StreamBuilder<QuerySnapshot>(
stream: FirebaseFirestore.instance
.collection('videoURLs').where('courseCode', isEqualTo:code).where('courseBatch', isEqualTo: batch)
.snapshots(),
builder: (context, snapshot) {
return !snapshot.hasData
?Center(
child: SpinKitDoubleBounce(
color: Color(0xFF13192F),
size: 50.0,
),
)
: Container(
padding: EdgeInsets.all(4.0),
child: GridView.builder(
scrollDirection: Axis.vertical,
shrinkWrap: true,
itemCount: snapshot.data?.docs.length,
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3),
itemBuilder: (context, index) {
final data = snapshot.data!.docs[index];
_videoPlayerController = VideoPlayerController.network(data['url'])..initialize().then((value) {
_videoPlayerController.play();
});
return Container(
margin: EdgeInsets.all(3.0),
child: AspectRatio(
aspectRatio: _videoPlayerController.value.aspectRatio,
child: VideoPlayer(
_videoPlayerController
),
)
);
}));
},
)
// FutureBuilder(
// future: listFiles(),
// builder: (BuildContext context, AsyncSnapshot<ListResult> snapshot){
// if(snapshot.connectionState == ConnectionState.done && snapshot.hasData){
// return Container(
// // child: ListView.builder(
// // shrinkWrap: true,
// // itemCount: snapshot.data!.items.length,
// // itemBuilder: (BuildContext context, int index){
// // Future<String> link = downloadURL(snapshot.data!.items[index].name) ;
// // return Container(
// // child: Text(link.toString()),
// // //Text(,style: TextStyle(color: Colors.black)),
// // );
// // }
// // ),
// );
// }
// if(snapshot.connectionState == ConnectionState.waiting || !snapshot.hasData){
// return CircularProgressIndicator();
// }
// return Container();
// },
// )
],
)));
}
// Future<String> downloadURL(imageName) async{
// print('ba;');
// String email = Provider.of<TaskData>(context, listen: false).userEmail;
// String code = Provider.of<TaskData>(context, listen: false).courseCode;
// String batch = Provider.of<TaskData>(context, listen: false).courseBatch;
// print('url;' + code + email+ batch);
// String down = '';
// String downloadURL = await FirebaseStorage.instance.ref('imageResources/$email/$code-$batch/$imageName').getDownloadURL().then((value) {
// setState(() {
// imgRef.add(value);
// });
// return "";
// }
// );
// return "";
// }
//
// Future<ListResult> listFiles()async{
// String email = Provider.of<TaskData>(context, listen: false).userEmail;
// String code = Provider.of<TaskData>(context, listen: false).courseCode;
// String batch = Provider.of<TaskData>(context, listen: false).courseBatch;
// ListResult results = await FirebaseStorage.instance.ref('imageResources/$email/$code-$batch').listAll();
// return results;
// }
//
// Future selectFiles() async {
// FilePickerResult? results = (await FilePicker.platform.pickFiles(allowMultiple: true,type: FileType.image));
// if (results == null) return;
// List<PlatformFile> files = results.files;
// files.forEach((element) {
// uploadFiles(File(element.path!));
// });
//
// }
// Future uploadFiles(fileName) async{
// String email = Provider.of<TaskData>(context, listen: false).userEmail;
// String code = Provider.of<TaskData>(context, listen: false).courseCode;
// String batch = Provider.of<TaskData>(context, listen: false).courseBatch;
// String newFileName = fileName.toString().split('/').last;
// final destination = 'imageResources/$email/$code-$batch/$newFileName';
// try{
// final ref = FirebaseStorage.instance.ref(destination);
// ref.putFile(fileName!);
// }
// catch(e){
// return null;
// }
// }
}
| 0 |
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/screens/register.dart | import 'package:cms/components/error-message.dart';
import 'package:cms/components/input-field.dart';
import 'package:cms/components/task-data.dart';
import 'package:cms/screens/login.dart';
import 'package:cms/screens/varification.dart';
import 'package:email_validator/email_validator.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:provider/provider.dart';
class Register extends StatefulWidget {
static String id = 'register';
const Register({Key? key}) : super(key: key);
@override
_RegisterState createState() => _RegisterState();
}
class _RegisterState extends State<Register> {
final _auth = FirebaseAuth.instance;
late String name;
late String email;
late String password;
late String password2;
late String errorMessage = '';
late bool spinner = false;
static String pattern = r'^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[!@#\$&*~]).{8,}$';
RegExp regex = new RegExp(pattern);
String setter() {
return name;
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: spinner
? const Center(
child: SpinKitDoubleBounce(
color: Color(0xFF13192F),
size: 50.0,
),
)
: Padding(
padding: const EdgeInsets.symmetric(horizontal: 30.0),
child: Center(
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Center(
child: Material(
borderRadius: BorderRadius.circular(100),
elevation: 5.0,
child: CircleAvatar(
backgroundColor: Color(0xFF13192F),
radius: 73.0,
child: CircleAvatar(
maxRadius: 70.0,
backgroundImage: AssetImage('images/CMS-Logo.png'),
),
),
),
),
SizedBox(
height: 30.0,
),
Text("Create an account as Teacher",textAlign: TextAlign.center ,style: TextStyle(color: Color(0xFF13192F),fontSize: 20.0,fontWeight: FontWeight.bold),),
const SizedBox(
height: 30.0,
),
InputField('Enter your name', false, (value) {
name = value;
}),
const SizedBox(
height: 10.0,
),
InputField('Enter your email', false, (value) {
email = value;
}),
const SizedBox(
height: 10.0,
),
InputField('Enter a password', true, (value) {
password = value;
}),
const SizedBox(
height: 10.0,
),
InputField('Confirm password', true, (value) {
password2 = value;
}),
const SizedBox(
height: 10.0,
),
ErrorMessage(errorMessage),
Padding(
padding: const EdgeInsets.symmetric(vertical: 16.0),
child: Material(
borderRadius: const BorderRadius.all(
Radius.circular(32.0),
),
color: Color(0xFF13192F),
elevation: 5.0,
child: MaterialButton(
onPressed: () async {
if(!EmailValidator.validate(email)){
setState(() {
errorMessage = "Email Not Valid";
});
}
else if(!regex.hasMatch(password)){
print('1234');
setState(() {
errorMessage = "Your password is weak";
});
}
else if (password != password2) {
setState(() {
errorMessage = "Password didn't match";
});
} else {
setState(() {
spinner = true;
});
try {
await Firebase.initializeApp();
UserCredential? result;
if (email != null && password != null) {
result =
await _auth.createUserWithEmailAndPassword(
email: email, password: password);
}
if (result != null) {
await _auth.currentUser
?.updateDisplayName(name);
Provider.of<TaskData>(context, listen: false)
.getUser();
Navigator.pushNamed(context, Varification.id);
}
setState(() {
spinner = false;
});
} catch (e) {
setState(() {
spinner = false;
errorMessage =
e.toString() + password + name + email;
});
}
}
},
child: const Text(
'Sign Up',
style: TextStyle(color: Colors.white),
),
),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text('You don\'t have an account?'),
TextButton(
onPressed: () {
Navigator.pushNamed(context, Login.id);
},
style: TextButton.styleFrom(
primary: Color(0xFF13192F), // Text Color
),
child: const Text(
'Login',
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 16.0),
),
)
],
),
],
),
),
)
),
);
}
}
| 0 |
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/screens/teacher-edit-profile.dart | import 'dart:convert';
import 'dart:io';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:cms/components/input-field2.dart';
import 'package:cms/components/multi-dropdown-field.dart';
import 'package:cms/screens/group-screen.dart';
import 'package:file_picker/file_picker.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_storage/firebase_storage.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:cms/components/task-data.dart';
import 'package:rflutter_alert/rflutter_alert.dart';
import 'package:image_picker/image_picker.dart';
import '../components/dropdown-field.dart';
class TeacherEditProfile extends StatefulWidget {
static String id = 'teacher-edit-profile';
@override
_TeacherEditProfileState createState() => _TeacherEditProfileState();
}
class _TeacherEditProfileState extends State<TeacherEditProfile> {
late PickedFile _imageFile;
final ImagePicker _picker = ImagePicker();
late bool isImage = false;
final user = FirebaseAuth.instance.currentUser;
File? file = null;
void takePhoto(ImageSource source) async {
final pickedFile = await _picker.getImage(
source: source,
);
setState(() {
_imageFile = pickedFile!;
});
File img = File(_imageFile.path);
String newFileName = img.path
.toString()
.split('/')
.last;
final ref = FirebaseStorage.instance.ref().child(
'profileImages/${user?.email}/$newFileName');
await ref.putFile(img).whenComplete(() async {
await ref.getDownloadURL().then((value) {
user?.updatePhotoURL(value);
Provider.of<TaskData>(context, listen: false).updatePhoto(value);
}
);
});
}
final _firestore = FirebaseFirestore.instance;
String _position = ' Select Your Position';
List<Object?> selectPositions = [];
List<String> positions = [
'Professor',
'Associate Professor',
'Assistance Professor',
'Head',
'Lecturer',
'Adjunct Faculty'
];
String _dropDownValue = 'Select Your Department';
List<String> items = ['Select Your Department','CSE', 'EEE','Civil Engineering','Business Administration', 'LAW', 'English', 'Architecture', 'Islamic Study',
'Public Health','Tourism and Hospitality Management','Bangla'];
late String mobile = '';
late String bio = '';
late CollectionReference routineRef;
@override
void initState() {
// TODO: implement initState
super.initState();
getData();
}
void getData() async {
await FirebaseFirestore.instance.collection('teacherProfile').where(
'email', isEqualTo: user?.email).get().then((value) {
final data = value.docs[0];
setState(() {
_dropDownValue = data['dept'];
_position = data['position'];
bio = data['bio'];
mobile = data['mobile'];
});
});
}
@override
Widget build(BuildContext context) {
final fileName = file != null ? file!
.path
.split('/')
.last : "Add file";
double screenWidth = MediaQuery
.of(context)
.size
.width;
return Scaffold(
appBar: AppBar(
title: const Text(
'Edit Profile',
),
backgroundColor: Color(0xFF13192F),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
_firestore.collection('teacherProfile').doc(Provider
.of<TaskData>(context, listen: false)
.userEmail).update({
'name': user?.displayName,
'photoURL': user?.photoURL,
'position': _position,
'dept': _dropDownValue,
'bio': bio,
'mobile': mobile,
'email': Provider
.of<TaskData>(context, listen: false)
.userEmail
});
uploadFile();
Navigator.pushNamed(context, Groups.id);
},
backgroundColor: Color(0xFF13192F),
child: Icon(Icons.arrow_forward_sharp),
),
resizeToAvoidBottomInset: true,
body: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const SizedBox(
height: 40.0,
),
Stack(
children: [
CircleAvatar(
radius: 100.0,
backgroundColor: Color(0xFF13192F),
child: CircleAvatar(
radius: 95.0,
backgroundImage: Provider
.of<TaskData>(context)
.userPhoto ==
''
? NetworkImage(
'https://cdn.pixabay.com/photo/2015/10/05/22/37/blank-profile-picture-973460_1280.png')
: NetworkImage(Provider
.of<TaskData>(context)
.userPhoto)
as ImageProvider, // : FileImage() as ImageProvider,
backgroundColor: Colors.white,
),
),
Positioned(
top: 150,
left: 150,
child: GestureDetector(
onTap: () {
Alert(
context: context,
content: Column(
children: [
Material(
elevation: 4,
child: DialogButton(
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: const [
Icon(Icons.camera),
Text(
"Camera",
style: TextStyle(
color: Colors.black, fontSize: 20),
),
],
),
onPressed: () {
takePhoto(ImageSource.camera);
Navigator.pop(context);
},
color: Colors.white,
),
),
const SizedBox(
height: 10,
),
Material(
elevation: 4,
child: DialogButton(
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: const [
Icon(Icons.image),
Text(
"Gallery",
style: TextStyle(
color: Colors.black,
fontSize: 20),
),
],
),
color: Colors.white,
onPressed: () {
takePhoto(ImageSource.gallery);
Navigator.pop(context);
}),
),
],
),
buttons: [],
).show();
},
child: const CircleAvatar(
backgroundColor: Color(0xFF13192F),
child: Icon(
Icons.add,
color: Colors.white,
),
),
),
),
],
),
SizedBox(height: 10.0),
Text(
Provider
.of<TaskData>(context)
.userName,
style: TextStyle(fontSize: 30.0, fontWeight: FontWeight.w600),
),
SizedBox(
height: 10.0,
),
Padding(
padding: EdgeInsets.all(30.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
//crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
MultiDropdownField(
_position, _position, positions, (value) {
setState(() {
selectPositions = value;
_position = '';
selectPositions.forEach((element) {
setState(() {
if (_position != '') {
_position = _position + ', ' + element.toString();
} else {
_position = element.toString();
}
});
});
if (_position == '') {
setState(() {
_position = ' Select Your Position';
});
}
});
}),
SizedBox(
height: 10.0,
),
DropdownField(_dropDownValue, items, (value) {
setState(() {
_dropDownValue = value;
});
}),
SizedBox(
height: 10.0,
),
InputField2(bio, false, (value) {
setState(() {
bio = value;
});
}),
SizedBox(
height: 10.0,
),
InputField2(mobile, false, (value) {
setState(() {
mobile = value;
});
}),
SizedBox(
height: 10.0,
),
// GestureDetector(
// onTap: selectFile,
// child: Container(
// width: screenWidth,
// padding: EdgeInsets.symmetric(
// vertical: 12.0, horizontal: 20.0),
// decoration: BoxDecoration(
// border: Border.all(
// color: Color(0xFF13192F), width: 2.0),
// color: Color(0xFF13192F),
// borderRadius: BorderRadius.circular(15.0),
// ),
// child: Text(
// fileName,
// style: TextStyle(
// color: Colors.white, fontSize: 16.0),
// overflow: TextOverflow.ellipsis,
// ),
// ),
// )
],
),
)
],
),
),
);
}
Future selectFile() async {
final result = await FilePicker.platform.pickFiles(allowMultiple: false);
if (result == null) return;
final path = result.files.single.path!;
setState(() {
file = File(path);
});
}
Future uploadFile() async {
String email = Provider
.of<TaskData>(context, listen: false)
.userEmail;
if (file == null) return;
final fileName = file!
.path
.split('/')
.last;
final destination = 'teacherRoutine/$email/$fileName';
try {
final ref = FirebaseStorage.instance.ref(destination);
ref.putFile(file!).whenComplete(() async {
await ref.getDownloadURL().then((value) {
routineRef.add(
{'url': fileName, 'email': email, 'fileName': fileName});
}
);
});
}
catch (e) {
return null;
}
}
}
| 0 |
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/screens/teacher-profile-update.dart | import 'dart:convert';
import 'dart:io';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:cms/components/input-field2.dart';
import 'package:cms/components/multi-dropdown-field.dart';
import 'package:cms/screens/group-screen.dart';
import 'package:file_picker/file_picker.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_storage/firebase_storage.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:cms/components/task-data.dart';
import 'package:rflutter_alert/rflutter_alert.dart';
import 'package:image_picker/image_picker.dart';
import '../components/dropdown-field.dart';
class TeacherProfileUpdate extends StatefulWidget {
static String id = 'teacher-profile-update';
@override
_TeacherProfileUpdateState createState() => _TeacherProfileUpdateState();
}
class _TeacherProfileUpdateState extends State<TeacherProfileUpdate> {
late PickedFile _imageFile;
final ImagePicker _picker = ImagePicker();
late bool isImage = false;
final user = FirebaseAuth.instance.currentUser;
File? file = null;
void takePhoto(ImageSource source) async {
final pickedFile = await _picker.getImage(
source: source,
);
setState(() {
_imageFile = pickedFile!;
});
File img = File(_imageFile.path);
String newFileName = img.path.toString().split('/').last;
final ref = FirebaseStorage.instance.ref().child('profileImages/${user?.email}/$newFileName');
await ref.putFile(img).whenComplete(()async{
await ref.getDownloadURL().then((value){
user?.updatePhotoURL(value);
Provider.of<TaskData>(context, listen: false).updatePhoto(value);
}
);
});
}
final _firestore = FirebaseFirestore.instance;
String _position = ' Select Your Position';
List<Object?> selectPositions = [];
List<String> positions = [
'Professor',
'Associate Professor',
'Assistance Professor',
'Head',
'Lecturer',
'Adjunct Faculty'
];
String _dropDownValue = 'Select Your Department';
List<String> items = ['Select Your Department','CSE', 'EEE','Civil Engineering','Business Administration', 'LAW', 'English', 'Architecture', 'Islamic Study',
'Public Health','Tourism and Hospitality Management','Bangla'];
late String mobile = '';
late String bio = '';
late CollectionReference routineRef;
@override
Widget build(BuildContext context) {
final fileName = file != null ? file!.path.split('/').last : "Add Class Routine";
double screenWidth = MediaQuery.of(context).size.width;
return WillPopScope(
onWillPop: () async => false,
child: Scaffold(
appBar: AppBar(
title: const Text(
'Teacher Profile',
),
backgroundColor: Color(0xFF13192F),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
_firestore.collection('teacherProfile').doc(Provider.of<TaskData>(context, listen: false).userEmail).set({
'name': user?.displayName,
'photoURL':user?.photoURL,
'position': _position,
'dept': _dropDownValue,
'bio': bio,
'mobile': mobile,
'email': Provider.of<TaskData>(context, listen: false).userEmail
});
uploadFile();
Navigator.pushNamed(context, Groups.id);
},
backgroundColor: Color(0xFF13192F),
child: Icon(Icons.arrow_forward_sharp),
),
resizeToAvoidBottomInset: true,
body: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const SizedBox(
height: 40.0,
),
Stack(
children: [
CircleAvatar(
radius: 100.0,
backgroundColor: Color(0xFF13192F),
child: CircleAvatar(
radius: 95.0,
backgroundImage: Provider.of<TaskData>(context).userPhoto ==
''
? NetworkImage('https://cdn.pixabay.com/photo/2015/10/05/22/37/blank-profile-picture-973460_1280.png')
: NetworkImage(Provider.of<TaskData>(context).userPhoto)
as ImageProvider, // : FileImage() as ImageProvider,
backgroundColor: Colors.white,
),
),
Positioned(
top: 150,
left: 150,
child: GestureDetector(
onTap: () {
Alert(
context: context,
content: Column(
children: [
Material(
elevation: 4,
child: DialogButton(
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: const [
Icon(Icons.camera),
Text(
"Camera",
style: TextStyle(
color: Colors.black, fontSize: 20),
),
],
),
onPressed: () {
takePhoto(ImageSource.camera);
Navigator.pop(context);
},
color: Colors.white,
),
),
const SizedBox(
height: 10,
),
Material(
elevation: 4,
child: DialogButton(
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: const [
Icon(Icons.image),
Text(
"Gallery",
style: TextStyle(
color: Colors.black, fontSize: 20),
),
],
),
color: Colors.white,
onPressed: () {
takePhoto(ImageSource.gallery);
Navigator.pop(context);
}),
),
],
),
buttons: [],
).show();
},
child: const CircleAvatar(
backgroundColor: Color(0xFF13192F),
child: Icon(
Icons.add,
color: Colors.white,
),
),
),
),
],
),
SizedBox(height: 10.0),
Text(
Provider.of<TaskData>(context).userName,
style: TextStyle(fontSize: 30.0, fontWeight: FontWeight.w600),
),
SizedBox(
height: 10.0,
),
Padding(
padding: EdgeInsets.all(30.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
//crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
MultiDropdownField(
'Select your position', _position, positions, (value) {
setState(() {
selectPositions = value;
_position = '';
selectPositions.forEach((element) {
setState(() {
if (_position != '') {
_position = _position + ', ' + element.toString();
} else {
_position = element.toString();
}
});
});
if (_position == '') {
setState(() {
_position = ' Select Your Position';
});
}
});
}),
SizedBox(
height: 10.0,
),
DropdownField(_dropDownValue, items, (value) {
setState(() {
_dropDownValue = value;
});
}),
SizedBox(
height: 10.0,
),
InputField2("Add Bio", false, (value) {
setState(() {
bio = value;
});
}),
SizedBox(
height: 10.0,
),
InputField2('Mobile Number', false, (value) {
setState(() {
mobile = value;
});
}),
SizedBox(
height: 10.0,
),
GestureDetector(
onTap: selectFile,
child: Container(
width: screenWidth,
padding: EdgeInsets.symmetric(vertical: 12.0, horizontal: 20.0),
decoration: BoxDecoration(
border: Border.all(
color: Color(0xFF13192F), width: 2.0),
color: Color(0xFF13192F),
borderRadius: BorderRadius.circular(15.0),
),
child: Text(
fileName,
style: TextStyle(
color: Colors.white, fontSize: 16.0),
overflow: TextOverflow.ellipsis,
),
),
)
],
),
)
],
),
),
),
);
}
Future selectFile() async {
final result = await FilePicker.platform.pickFiles(allowMultiple: false);
if (result == null) return;
final path = result.files.single.path!;
setState(() {
file = File(path);
});
}
Future uploadFile() async {
String email = Provider.of<TaskData>(context, listen: false).userEmail;
if(file == null)return;
final fileName = file!.path.split('/').last;
final destination = 'teacherRoutine/$email/$fileName';
try{
final ref = FirebaseStorage.instance.ref(destination);
ref.putFile(file!).whenComplete(()async{
await ref.getDownloadURL().then((value){
routineRef.add({'url': value,'email':email, 'fileName': fileName});
}
);
});
}
catch(e){
return null;
}
}
@override
void initState(){
super.initState();
routineRef = FirebaseFirestore.instance.collection('routineURLs');
}
}
| 0 |
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/screens/login-varification.dart | import 'dart:async';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'group-screen.dart';
class LoginVarification extends StatefulWidget {
static String id = 'login-verification';
@override
_LoginVarificationState createState() => _LoginVarificationState();
}
class _LoginVarificationState extends State<LoginVarification> {
bool isVarified = false;
bool canResendEmail = true;
Timer? timer;
Color color = Color(0xFF808080);
String sent = "A verification email has been sent to your email.";
@override
void initState(){
super.initState();
isVarified = FirebaseAuth.instance.currentUser!.emailVerified;
if(!isVarified) {
sendVarificationEmail();
timer = Timer.periodic(Duration(seconds: 5), (_){
checkEmailVarified();
});
}
}
@override
void dispose(){
timer?.cancel();
super.dispose();
}
Future checkEmailVarified()async{
await FirebaseAuth.instance.currentUser!.reload();
setState(() {
isVarified = FirebaseAuth.instance.currentUser!.emailVerified;
});
if(isVarified)timer?.cancel();
}
Future sendVarificationEmail() async{
setState(() {
color = Color(0xFF808080);
canResendEmail = false;
});
final user = FirebaseAuth.instance.currentUser!;
await user.sendEmailVerification();
await Future.delayed(Duration(seconds: 5));
setState(() {
canResendEmail = true;
color = Color(0xFF13192F);
});
}
Widget build(BuildContext context) {
if(isVarified) {
return Groups();
} else {
return Scaffold(
appBar: AppBar(
title: const Text(
'User Verification',
),
backgroundColor: Color(0xFF13192F),
),
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(sent, style: TextStyle(fontSize: 20.0),
textAlign: TextAlign.center,),
const SizedBox(height: 10.0,),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 100.0),
child: TextButton(
style: TextButton.styleFrom(
backgroundColor: color,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: const [
Icon(Icons.mail, size: 24.0, color: Colors.white,),
SizedBox(width: 10.0,),
Text('Resend',
style: TextStyle(fontSize: 24.0, color: Colors.white),),
],
),
onPressed: (){
canResendEmail?
setState(() {
sent = "A verification email has been resent to your email.";
sendVarificationEmail();
}):null;
}
,
),
)
],
),
);
}
}
}
| 0 |
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/screens/logreg-page.dart | import 'dart:ui';
import 'package:cms/screens/login.dart';
import 'package:cms/screens/register.dart';
import 'package:cms/student-screens/student-login.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class LogRegPage extends StatelessWidget {
static String id="second-page";
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
backgroundColor: Color(0xFF13192F),
body: SafeArea(
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: EdgeInsets.only(bottom: 50.0),
child: CircleAvatar(
radius: 85.0,
backgroundImage: AssetImage('images/CMS-Logo.png'),
),
),
GestureDetector(
onTap: (){
Navigator.pushNamed(context, Login.id);
},
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
'Login as Teacher',
style: TextStyle(
fontSize: 30.0,
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
),
),
Padding(
padding: EdgeInsets.all(8.0),
child: Text(
'or',
style: TextStyle(
fontSize: 24.0,
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
),
GestureDetector(
onTap: (){
Navigator.pushNamed(context, StudentLogin.id);
},
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
'Login as Student',
style: TextStyle(
fontSize: 30.0,
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
),
),
],
),
),
),
),
);
}
} | 0 |
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/screens/group-info.dart | import 'dart:ui';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:cms/components/navigation.dart';
import 'package:cms/components/task-data.dart';
import 'package:cms/screens/add-class-work.dart';
import 'package:cms/screens/classwork.dart';
import 'package:cms/screens/resource.dart';
import 'package:cms/student-screens/quiz.dart';
import 'package:colorful_safe_area/colorful_safe_area.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../student-screens/student-resources.dart';
class GroupInfo extends StatefulWidget {
static String id="group-info";
@override
State<GroupInfo> createState() => _GroupInfoState();
}
class _GroupInfoState extends State<GroupInfo> {
@override
void initState() {
// TODO: implement initState
super.initState();
getData();
}
int participate = 0;
getData()async{
await FirebaseFirestore.instance.collection('studentGroups').where(
'classCode', isEqualTo: Provider.of<TaskData>(context, listen: false).courseCode).get().then((value) {
setState(() {
participate = participate + 1;
});
});
}
@override
Widget build(BuildContext context) {
String email = Provider.of<TaskData>(context, listen: false).userEmail;
String name = Provider.of<TaskData>(context, listen: false).userName;
String code = Provider.of<TaskData>(context, listen: false).courseCode;
String batch = Provider.of<TaskData>(context, listen: false).courseBatch;
String section = Provider.of<TaskData>(context, listen: false).courseSection;
return MaterialApp(
home: Scaffold(
body: ColorfulSafeArea(
color: Color(0xFF13192F),
child: Column(
children: [
CustomNavigation("Group Info",(value){
}),
Container(
child: Row(
children: [
Padding(
padding: const EdgeInsets.all(28.0),
child: CircleAvatar(
backgroundColor: Color(0xFF13192F),
radius: 55.0,
child: CircleAvatar(
child: Column(
mainAxisAlignment:
MainAxisAlignment.center,
children: [
Text(
batch +'(' + section + ')',
style: TextStyle(
color: Color(0xFF13192F),fontSize: 32,fontWeight: FontWeight.w500),
),
]),
backgroundColor: Colors.white,
radius: 50.0,
),
),
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"$code-$batch($section)",
style: TextStyle(
fontSize: 30.0,
color: Color(0xFF13192F),
),
),
Text(
"$participate Participants",
style: TextStyle(
fontSize: 20.0,
color: Color(0xFF13192F),
),
),
],
),
],
),
),
Row(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(left: 28.0),
child: Text(
'Welcome to my Course',
style: TextStyle(
fontSize: 27.0,
color: Color(0xFF13192F),
fontWeight: FontWeight.bold,
),
),
),
Padding(
padding: const EdgeInsets.only(left: 28.0, bottom: 20.0),
child: Text(
'Created by You, 8/16/2022',
style: TextStyle(
fontSize: 20.0,
color: Color(0xFF13192F),
fontWeight: FontWeight.bold,
),
),
),
],
),
],
),
Expanded(
child: Row(
children: [
Expanded(
child: Padding(
padding: const EdgeInsets.only(left: 10.0),
child: ReusableCard('Class Work',(value){
Navigator.pushNamed(context, Classwork.id);
}),
),
),
Expanded(child:
Padding(
padding: const EdgeInsets.only(right: 10.0),
child: ReusableCard('Resources',(value){
Navigator.pushNamed(context, StudentResources.id);
}),
),
),
],
),
),
Expanded(
child: Row(
children: [
Expanded(
child: Padding(
padding: const EdgeInsets.only(left: 10.0),
child: ReusableCard('Result',(){}),
),
),
Expanded(child:
Padding(
padding: const EdgeInsets.only(right: 10.0),
child:ReusableCard('Quiz',(value){
Navigator.pushNamed(context, Quiz.id);
}),
),
),
],
),
),
],
),
),
),
);
}
}
class ReusableCard extends StatelessWidget {
const ReusableCard(this.text,this.onChangeCallback);
final String text;
final Function onChangeCallback;
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: (){
onChangeCallback(true);
},
child: Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
text,
style: TextStyle(
fontSize: 28.0,
fontWeight: FontWeight.bold,
color: Colors.white
),
),
],
),
margin: EdgeInsets.all(15.0),
decoration: BoxDecoration(
color: Color(0xFF1D1E33),
borderRadius: BorderRadius.circular(20.0),
),
),
);
}
} | 0 |
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/screens/subgroup-screen.dart | import 'dart:ui';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:cms/components/custom-drawer.dart';
import 'package:cms/components/task-data.dart';
import 'package:cms/screens/resource.dart';
import 'package:flutter/material.dart';
import 'package:colorful_safe_area/colorful_safe_area.dart';
import 'package:provider/provider.dart';
import '../components/navigation.dart';
import 'add-group.dart';
import 'dart:math' as math;
import 'chat-screen.dart';
class SubGroups extends StatefulWidget {
static String id = 'sub-group';
@override
_SubGroupsState createState() => _SubGroupsState();
}
class _SubGroupsState extends State<SubGroups> {
final _firestore = FirebaseFirestore.instance;
final GlobalKey<ScaffoldState> _globalKey = GlobalKey<ScaffoldState>();
String lastMessage = "Welcome to our group";
@override
Widget build(BuildContext context) {
String email = Provider.of<TaskData>(context,listen: false).userEmail;
String courseCode = Provider.of<TaskData>(context,
listen: false)
.courseCode;
String courseBatch = Provider.of<TaskData>(context,
listen: false)
.courseBatch;
return Scaffold(
key: _globalKey,
drawer: CustomDrawer(),
floatingActionButton: FloatingActionButton.extended(
onPressed: () {
Navigator.pushNamed(context, AddGroup.id);
},
label: Text(
"Add Sub-Groups",
textAlign: TextAlign.center,
),
backgroundColor: Color(0xFF13192F),
),
backgroundColor: Colors.white,
body: ColorfulSafeArea(
color: Color(0xFF13192F),
child: Column(
children: [
CustomNavigation("Groups",(value){
_globalKey.currentState?.openDrawer();
}),
Container(
child: Stack(
children: [
Container(
height: 28.0,
margin: EdgeInsets.only(right: 50.0),
color: Color(0xFF13192F),
),
Container(
height: 35.0,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30.0))),
),
Positioned(
child: GestureDetector(
child: Padding(
padding: EdgeInsets.only(top: 10.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
child: Padding(
padding: EdgeInsets.only(left: 20.0,right: 20.0,bottom: 7.0),
child: Text(
"Groups",
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.w500,
),
),
),
decoration: BoxDecoration(
border: Border(
bottom:BorderSide(color: Colors.black,width: 3.0),
),
),
),
SizedBox(
width: 50.0,
),
GestureDetector(
onTap: (){
Navigator.pushNamed(context, Resources.id);
},
child: Container(
child: Padding(
padding: EdgeInsets.only(left: 20.0,right: 20.0,bottom: 5.0),
child: Text(
"Resources",
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.w500,
),
),
),
),
),
],
),
),
),
),
],
),
),
SizedBox(
height: 20.0,
),
StreamBuilder<QuerySnapshot>(
stream: _firestore.collection('subGroups').where('email', isEqualTo: email).where('groupName', isEqualTo: courseCode).where('groupBatch', isEqualTo: courseBatch).snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData)
return LinearProgressIndicator();
else {
final docs = snapshot.data!.docs;
return Expanded(
child: SizedBox(
height: 500.0,
child: ListView.builder(
itemCount: docs.length,
itemBuilder: (context, i) {
final data = docs[i];
_firestore.collection("messages-${data['classCode']}").orderBy('messageTime', descending: true).get().then((value){
lastMessage = "Welcome to our group";
if(value.docs.length > 0) {
lastMessage = value.docs[0]['text'];
}
});
return Padding(
padding: EdgeInsets.symmetric(
vertical: 5.0, horizontal: 15.0),
child: Padding(
padding: EdgeInsets.only(bottom: 5.0),
child: Row(
mainAxisAlignment:
MainAxisAlignment.start,
children: [
CircleAvatar(
child: Column(
mainAxisAlignment:
MainAxisAlignment.center,
children: [
Text(
data['groupBatch'] +'(' + data['groupSection'] + ')',
style: TextStyle(
color: Colors.white,fontSize: 17,fontWeight: FontWeight.w500),
),
]),
radius: 28,
backgroundColor: Color((math
.Random()
.nextDouble() *
0xFFFF55)
.toInt())
.withOpacity(0.6),
),
SizedBox(
width: 10.0,
),
GestureDetector(
onTap: (){
Provider.of<TaskData>(context,listen:false).getSubGroup(data['groupSection'],data['classCode'],data['email']);
Navigator.pushNamed(context, ChatScreen.id);
},
child: Container(
width: MediaQuery.of(context).size.width - 100,
padding: EdgeInsets.only(bottom: 8.0),
decoration: BoxDecoration(
border: Border(
bottom:
BorderSide(color: Color(0xFF808080).withOpacity(0.6)),
),
),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
data['groupName'] + '-' + data['groupBatch'] + '(' + data['groupSection'] + ')',
style: TextStyle(
fontSize: 19.0,
fontWeight:
FontWeight.w600),
),
SizedBox(height: 2.0,),
Text(
lastMessage,
style: TextStyle(
fontSize: 16.0,
fontWeight:
FontWeight.w400,
color: Colors.grey),
),
]),
),
),
]),
),
);
}
),
),
);
}
}),
],
)));
}
}
| 0 |
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/screens/forgot-password.dart | import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/cupertino.dart';
import 'package:email_validator/email_validator.dart';
import 'package:flutter/material.dart';
class ForgotPassword extends StatefulWidget {
static String id = "forgot-password";
@override
_ForgotPasswordState createState() => _ForgotPasswordState();
}
class _ForgotPasswordState extends State<ForgotPassword> {
final formKey = GlobalKey<FormState>();
final emailController = TextEditingController();
void dispose() {
emailController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Color(0xFF13192F),
title: Text('Reset Password'),
),
body: Padding(
padding: EdgeInsets.all(16.0),
child: Form(
key: formKey,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'Receive an email to\nreset your password',
textAlign: TextAlign.center,
style: TextStyle(fontSize: 24),
),
SizedBox(
height: 20.0,
),
TextFormField(
controller: emailController,
cursorColor: Color(0xFF13192F),
textInputAction: TextInputAction.done,
decoration: InputDecoration(
labelText: 'Email',
labelStyle: TextStyle(color: Color(0xFF13192F)),
hoverColor: Color(0xFF13192F),
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Color(0xFF13192F)),
borderRadius: BorderRadius.circular(25.7),
),
),
autovalidateMode: AutovalidateMode.onUserInteraction,
validator: (email) =>
email != null && !EmailValidator.validate(email)
? 'Enter a valid email'
: null,
),
SizedBox(
height: 20.0,
),
ElevatedButton.icon(
style: ElevatedButton.styleFrom(
minimumSize: Size.fromHeight(50),
primary: Color(0xFF13192F)),
onPressed: resetPassword,
icon: Icon(Icons.email_outlined),
label: Text(
'Reset Password',
style: TextStyle(fontSize: 24),
))
],
),
),
),
);
}
Future resetPassword() async {
try{
await FirebaseAuth.instance
.sendPasswordResetEmail(email: emailController.text.trim());
Navigator.pop(context);
}on Exception catch(e){
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(e.toString()),));
}
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text("Password resend email has been sent"),));
}
}
| 0 |
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/screens/profile-settings.dart | import 'dart:ui';
import 'package:cms/screens/teacher-profile-update.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../components/task-data.dart';
import '../student-screens/stundet-edit-profile.dart';
import 'teacher-edit-profile.dart';
class ProfileSettings extends StatefulWidget {
static String id = "settings";
@override
_ProfileSettingsState createState() => _ProfileSettingsState();
}
class _ProfileSettingsState extends State<ProfileSettings> {
@override
Widget build(BuildContext context) {
bool stud = Provider.of<TaskData>(context).isStudent;
print(stud);
return Scaffold(
appBar: AppBar(
title: Text("Settings"),
backgroundColor: Color(0xFF13192F),
),
body: Padding(
padding: EdgeInsets.all(15.0),
child: Column(
children: [
GestureDetector(
onTap: (){
String nextPage;
stud ? nextPage = StudentEditProfile.id : nextPage = TeacherEditProfile.id;
Navigator.pushNamed(context, nextPage);
},
child: Container(
color: Color(0xFF13192F).withOpacity(.95),
padding: EdgeInsets.all(10.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text("Edit Profile",style: TextStyle(fontSize: 18.0,color: Colors.white),),
Icon(Icons.arrow_forward_ios_outlined,color: Colors.white,)
],
),
),
)
],
),
),
);
}
}
| 0 |
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/screens/add-class-work.dart | import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:cms/components/task-data.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
class AddClassWork extends StatefulWidget {
static String id = 'add-classwork';
@override
State<AddClassWork> createState() => _AddClassWorkState();
}
class _AddClassWorkState extends State<AddClassWork> {
late String classworkName = "";
@override
Widget build(BuildContext context) {
String code = Provider.of<TaskData>(context).classCode;
return Container(
decoration: BoxDecoration(
border: Border.all(width: 0.0, color: const Color(0xFF757575)),
color: const Color(0xFF757575),
),
child: Container(
padding: const EdgeInsets.all(20.0),
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(20.0), topRight: Radius.circular(20.0)),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const Text(
'Add Classwork',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 30.0,
fontWeight: FontWeight.bold,
color: Color(0xFF13192F)),
),
TextField(
autofocus: true,
cursorColor: Color(0xFF13192F),
textAlign: TextAlign.center,
style: const TextStyle(fontSize: 18.0,color: Color(0xFF13192F)),
onChanged: (value) {
classworkName = value;
},
),
FlatButton(
color: Color(0xFF13192F),
child: const Text(
'Add',
style: TextStyle(color: Colors.white, fontSize: 20.0),
),
onPressed: () {
String time = DateFormat.Hms().format(DateTime.now()).toString();
FirebaseFirestore.instance.collection("classwork-$code").doc(time).set({
'classwork' : classworkName,
'classworkSerial': time,
'classworkTime': DateFormat.yMd().format(DateTime.now()).toString(),
});
Navigator.pop(context);
},
)
],
),
),
);
}
}
| 0 |
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/screens/onboarding-screen.dart | import 'dart:ui';
import 'package:cms/screens/welcome-page.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:smooth_page_indicator/smooth_page_indicator.dart';
class OnBoardingScreen extends StatefulWidget {
static String id="onboarding_screen";
@override
State<OnBoardingScreen> createState() => _OnBoardingScreenState();
}
class _OnBoardingScreenState extends State<OnBoardingScreen> {
PageController _controller = PageController();
bool onLastPage = false;
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
children: [
PageView(
controller: _controller,
onPageChanged: (index) {
setState(() {
onLastPage = (index == 2);
});
},
children: [
Container(
color: Colors.white,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
child: Text(
'Easy To Organise your Classroom',
textAlign: TextAlign.center,
style: TextStyle(
color: Color(0xFF145DA0),
fontSize: 30.0,
fontWeight: FontWeight.bold,
),
),
),
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Image(image: AssetImage('images/seven.webp'),),
),
],
),
),
Container(
color: Colors.white,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: const [
Text(
'Upload Files',
style: TextStyle(
color: Color(0xFF145DA0),
fontSize: 30.0,
fontWeight: FontWeight.bold,
),
),
Padding(
padding: EdgeInsets.only(top: 35.0, bottom: 18.0),
child: Image(image: AssetImage('images/second.webp'),),
),
Padding(
padding: const EdgeInsets.only(left: 35.0, right: 35.0,top: 18.0),
child: Text(
'No need to upload same file for multiple class. In one tap you can share all groups together',
textAlign: TextAlign.center,
style: TextStyle(
color: Color(0xFF145DA0),
fontSize: 18.0,
),
),
),
],
),
),
Container(
color: Colors.white,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'Add Classwork',
style: TextStyle(
color: Color(0xFF145DA0),
fontSize: 30.0,
fontWeight: FontWeight.bold,
),
),
Padding(
padding: const EdgeInsets.only(top: 30.0, bottom: 18.0),
child: Image(image: AssetImage('images/third.webp'),),
),
Padding(
padding: const EdgeInsets.only(left: 35.0, right: 35.0,top: 18.0),
child: Text(
"You can add classwork for any sub groups as reminder and can delete the classwork when it's done.",
textAlign: TextAlign.center,
style: TextStyle(
color: Color(0xFF145DA0),
fontSize: 18.0,
),
),
),
],
),
),
],
),
Container(
alignment: Alignment(0, 0.92),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
GestureDetector(
onTap: () {
_controller.nextPage(
duration: Duration(milliseconds: 500),
curve: Curves.easeIn,
);
},
child: Padding(
padding: const EdgeInsets.only (left: 28.0),
child: Text(
'Skip',
style: TextStyle(
color: Color(0xFF145DA0),
fontSize: 18.0,
),
),
),
),
SmoothPageIndicator(
controller: _controller,
count: 3,
effect: WormEffect(
dotColor: Colors.black54,
activeDotColor: Color(0xFF145DA0)
),
),
onLastPage ?
GestureDetector(
onTap: (){
Navigator.pushNamed(context, WelcomePage.id);
},
child: Padding(
padding: const EdgeInsets.only(right: 28.0),
child: Text(
'Done',
style: TextStyle(
color: Color(0xFF145DA0),
fontSize: 18.0,
),
),
),
)
: GestureDetector(
onTap: () {
_controller.nextPage(
duration: Duration(milliseconds: 500),
curve: Curves.easeIn,
);
},
child: Padding(
padding: const EdgeInsets.only(right: 28.0),
child: Text(
'Next',
style: TextStyle(
color: Color(0xFF145DA0),
fontSize: 18.0,
),
),
),
),
],
),
),
],
),
);
}
}
| 0 |
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/screens/image-resource.dart | import 'dart:convert';
import 'dart:io';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:transparent_image/transparent_image.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:cms/components/custom-drawer.dart';
import 'package:cms/components/navigation.dart';
import 'package:cms/components/task-data.dart';
import 'package:cms/screens/add-group.dart';
import 'package:cms/screens/add-image.dart';
import 'package:colorful_safe_area/colorful_safe_area.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class ImageResources extends StatefulWidget {
static String id = 'image-resources';
@override
_ImageResourcesState createState() => _ImageResourcesState();
}
class _ImageResourcesState extends State<ImageResources> {
final GlobalKey<ScaffoldState> _globalKey = GlobalKey<ScaffoldState>();
List<String> imgRef = [];
@override
Widget build(BuildContext context) {
String email = Provider.of<TaskData>(context, listen: false).userEmail;
String code = Provider.of<TaskData>(context, listen: false).courseCode;
String batch = Provider.of<TaskData>(context, listen: false).courseBatch;
return Scaffold(
key: _globalKey,
drawer: CustomDrawer(),
floatingActionButton: FloatingActionButton(
backgroundColor: Color(0xFF13192F),
onPressed: () {
Navigator.pushNamed(context, AddImage.id);
},
child: Icon(Icons.upload_rounded),
),
body: ColorfulSafeArea(
color: Color(0xFF13192F),
child: Column(
children: [
CustomNavigation("Images",(value) {
_globalKey.currentState?.openDrawer();
}),
StreamBuilder<QuerySnapshot>(
stream: FirebaseFirestore.instance
.collection('imageURLs').where('courseCode', isEqualTo:code).where('courseBatch', isEqualTo: batch)
.snapshots(),
builder: (context, snapshot) {
return !snapshot.hasData
?Center(
child: SpinKitDoubleBounce(
color: Color(0xFF13192F),
size: 50.0,
),
)
: Container(
padding: EdgeInsets.all(4.0),
child: GridView.builder(
scrollDirection: Axis.vertical,
shrinkWrap: true,
itemCount: snapshot.data?.docs.length,
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3),
itemBuilder: (context, index) {
final data = snapshot.data!.docs[index];
return Container(
margin: EdgeInsets.all(3.0),
child: FadeInImage.assetNetwork(
fadeInDuration: Duration(seconds: 1),
fadeInCurve: Curves.bounceIn,
fit: BoxFit.cover,
image: data['url'],
placeholder: 'images/loading.gif'),
);
}));
},
)
// FutureBuilder(
// future: listFiles(),
// builder: (BuildContext context, AsyncSnapshot<ListResult> snapshot){
// if(snapshot.connectionState == ConnectionState.done && snapshot.hasData){
// return Container(
// // child: ListView.builder(
// // shrinkWrap: true,
// // itemCount: snapshot.data!.items.length,
// // itemBuilder: (BuildContext context, int index){
// // Future<String> link = downloadURL(snapshot.data!.items[index].name) ;
// // return Container(
// // child: Text(link.toString()),
// // //Text(,style: TextStyle(color: Colors.black)),
// // );
// // }
// // ),
// );
// }
// if(snapshot.connectionState == ConnectionState.waiting || !snapshot.hasData){
// return CircularProgressIndicator();
// }
// return Container();
// },
// )
],
)));
}
// Future<String> downloadURL(imageName) async{
// print('ba;');
// String email = Provider.of<TaskData>(context, listen: false).userEmail;
// String code = Provider.of<TaskData>(context, listen: false).courseCode;
// String batch = Provider.of<TaskData>(context, listen: false).courseBatch;
// print('url;' + code + email+ batch);
// String down = '';
// String downloadURL = await FirebaseStorage.instance.ref('imageResources/$email/$code-$batch/$imageName').getDownloadURL().then((value) {
// setState(() {
// imgRef.add(value);
// });
// return "";
// }
// );
// return "";
// }
//
// Future<ListResult> listFiles()async{
// String email = Provider.of<TaskData>(context, listen: false).userEmail;
// String code = Provider.of<TaskData>(context, listen: false).courseCode;
// String batch = Provider.of<TaskData>(context, listen: false).courseBatch;
// ListResult results = await FirebaseStorage.instance.ref('imageResources/$email/$code-$batch').listAll();
// return results;
// }
//
// Future selectFiles() async {
// FilePickerResult? results = (await FilePicker.platform.pickFiles(allowMultiple: true,type: FileType.image));
// if (results == null) return;
// List<PlatformFile> files = results.files;
// files.forEach((element) {
// uploadFiles(File(element.path!));
// });
//
// }
// Future uploadFiles(fileName) async{
// String email = Provider.of<TaskData>(context, listen: false).userEmail;
// String code = Provider.of<TaskData>(context, listen: false).courseCode;
// String batch = Provider.of<TaskData>(context, listen: false).courseBatch;
// String newFileName = fileName.toString().split('/').last;
// final destination = 'imageResources/$email/$code-$batch/$newFileName';
// try{
// final ref = FirebaseStorage.instance.ref(destination);
// ref.putFile(fileName!);
// }
// catch(e){
// return null;
// }
// }
}
| 0 |
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/screens/teacher-profile.dart | import 'dart:io';
import 'dart:ui';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:cms/components/navigation.dart';
import 'package:cms/components/task-data.dart';
import 'package:colorful_safe_area/colorful_safe_area.dart';
import 'package:dio/dio.dart';
import 'package:firebase_storage/firebase_storage.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:gallery_saver/gallery_saver.dart';
import 'package:path_provider/path_provider.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../components/custom-drawer.dart';
class TeacherProfile extends StatefulWidget {
static String id = "teacher-profile";
@override
State<TeacherProfile> createState() => _TeacherProfileState();
}
class _TeacherProfileState extends State<TeacherProfile> {
final GlobalKey<ScaffoldState> _globalKey = GlobalKey<ScaffoldState>();
final _firestore = FirebaseFirestore.instance;
double downloadProgress = 0.0;
bool alreadyDisplayed = false;
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
key: _globalKey,
drawer: CustomDrawer(),
body: ColorfulSafeArea(
color: Color(0xFF13192F),
child: StreamBuilder<QuerySnapshot>(
stream: _firestore.collection('teacherProfile').where('email', isEqualTo:Provider.of<TaskData>(context).userEmail).snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData)
return LinearProgressIndicator();
else {
final docs = snapshot.data!.docs;
return ListView.builder(
scrollDirection: Axis.vertical,
itemCount: docs.length,
shrinkWrap: true,
itemBuilder: (context, i) {
if (docs[i].exists &&
!alreadyDisplayed) {
alreadyDisplayed = true;
final data = docs[i];
return Column(
children: [
CustomNavigation("Profile",(value) {
_globalKey.currentState?.openDrawer();
}),
Container(
child: Stack(
children: [
Container(
height: 28.0,
margin:
EdgeInsets.only(right: 50.0, bottom: 1.0),
color: Color(0xFF13192F),
),
Container(
height: 35.0,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30.0))),
),
],
),
),
Container(
child: Column(
children: [
Padding(
padding: EdgeInsets.all(28.0),
child: Material(
borderRadius: BorderRadius.circular(100.0),
elevation: 3.0,
child: CircleAvatar(
backgroundColor: Color(0xFF13192F),
radius: 78.0,
child: CircleAvatar(
backgroundImage: Provider.of<TaskData>(
context)
.userPhoto ==
''
? NetworkImage(
'https://cdn.pixabay.com/photo/2015/10/05/22/37/blank-profile-picture-973460_1280.png')
: NetworkImage(Provider.of<
TaskData>(context)
.userPhoto),
radius: 75.0,
),
),
),
),
],
),
),
Column(
children: [
Text(
Provider.of<TaskData>(context).userName,
style: TextStyle(
fontSize: 27.0,
color: Color(0xFF13192F),
fontWeight: FontWeight.bold,
),
),
Text(
data['position'],
style: TextStyle(
fontSize: 20.0,
color: Color(0xFF13192F),
fontWeight: FontWeight.bold,
),
),
Text(
'Department of ' + data['dept'],
style: TextStyle(
fontSize: 20.0,
color: Color(0xFF13192F),
fontWeight: FontWeight.bold,
),
),
],
),
Row(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 30.0,
),
Padding(
padding: const EdgeInsets.only(
left: 25.0, bottom: 20.0),
child: SizedBox(
width: MediaQuery.of(context).size.width - 25.0,
child: Text(
data['bio'],
style: TextStyle(
fontSize: 20.0,
color: Color(0xFF13192F),
fontWeight: FontWeight.bold,
),
),
),
),
],
),
],
),
Row(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(
left: 25.0, top: 20.0),
child: Text(
'Phone: ' + data['mobile'],
style: TextStyle(
fontSize: 20.0,
color: Color(0xFF13192F),
),
),
),
],
),
],
),
Row(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(
left: 25.0, top: 20.0),
child: Text(
'Email: ' +
Provider.of<TaskData>(context)
.userEmail,
style: TextStyle(
fontSize: 20.0,
color: Color(0xFF13192F),
),
),
),
SizedBox(
height: 40.0,
),
],
),
],
),
StreamBuilder<QuerySnapshot>(
stream: FirebaseFirestore.instance
.collection('routineURLs')
.snapshots(),
builder: (context, snapshot) {
return !snapshot.hasData
? Center(
child:
CircularProgressIndicator(
backgroundColor: Colors.black,
),
)
: ListView.builder(
shrinkWrap: true,
itemCount: snapshot.data?.docs.length,
itemBuilder: (context, index) {
final data = snapshot.data!.docs[index];
final url = data['url'];
String email = Provider.of<TaskData>(
context).userEmail;
if (data['email'] == email) {
return Padding(
padding: EdgeInsets.symmetric(horizontal: 12.0),
child: GestureDetector(
onTap: (){
downloadFile(url, data['fileName']);
},
child: ListTile(
title: Text('Download Routine',style: TextStyle(fontSize: 18.0,color: Color(0xFF13192F)),),
trailing: IconButton(
onPressed: (){
downloadFile(url, data['fileName']);
},
icon: Icon(Icons.download_sharp),
),
),
),
);
}
else return Container();
});
})
],
);
} else {
return Container();
}
},
);
}
}),
),
);
}
Future downloadFile(final url, String fileName) async {
final tempDir = await getTemporaryDirectory();
final path = '${tempDir.path}/$fileName';
await Dio().download(url, path);
if(url.contains('.jpg') || url.contains('.png') || url.contains('.jpeg')){
await GallerySaver.saveImage(path,toDcim: true);
}
if(url.contains('.mp4')){
await GallerySaver.saveVideo(path,toDcim: true);
}
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text("Download Completed"),));
}
}
| 0 |
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/screens/chat-screen.dart | import 'dart:ui';
import 'package:cms/components/navigation2.dart';
import 'package:cms/components/task-data.dart';
import 'package:cms/screens/group-info.dart';
import 'package:colorful_safe_area/colorful_safe_area.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:intl/intl.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:provider/provider.dart';
import 'dart:math' as math;
import '../student-screens/teacher-profile-2.dart';
import 'group-screen.dart';
final messageTextController = TextEditingController();
final _firestore = FirebaseFirestore.instance;
late String messageText;
class ChatScreen extends StatefulWidget {
static const String id = 'chat_screen';
@override
State<ChatScreen> createState() => _ChatScreenState();
}
class _ChatScreenState extends State<ChatScreen> {
@override
Widget build(BuildContext context) {
String email = Provider.of<TaskData>(context, listen: false).userEmail;
String name = Provider.of<TaskData>(context, listen: false).userName;
String code = Provider.of<TaskData>(context, listen: false).courseCode;
String batch = Provider.of<TaskData>(context, listen: false).courseBatch;
String section = Provider.of<TaskData>(context, listen: false).courseSection;
String classCode = Provider.of<TaskData>(context, listen: false).classCode;
return Scaffold(
body: ColorfulSafeArea(
color: Color(0xFF13192F),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Container(
padding: EdgeInsets.symmetric(horizontal: 20.0),
decoration: BoxDecoration(
borderRadius:
BorderRadius.only(bottomRight: Radius.circular(30.0)),
color: Color(0xFF13192F),
),
child: Row(
children: [
SizedBox(
width: 10.0,
),
Padding(
padding: EdgeInsets.symmetric(vertical: 7.0),
child: CircleAvatar(
child: Column(
mainAxisAlignment:
MainAxisAlignment.center,
children: [
Text(
batch +'(' + section + ')',
style: TextStyle(
color: Colors.white,fontSize: 17,fontWeight: FontWeight.w500),
),
]),
radius: 24,
backgroundColor: Color((math.Random().nextDouble()*0xFFFF55).toInt()).withOpacity(0.6),
),
),
Padding(
padding: EdgeInsets.symmetric(vertical: 10.0),
child: Padding(
padding: EdgeInsets.all(7.0),
child: Text(code + '-' + batch + '(' + section + ')',
style: TextStyle(fontSize: 20.0,color: Colors.white, fontWeight: FontWeight.bold),),
)
),
Expanded(
child: Row(
//crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisAlignment: MainAxisAlignment.end,
children: [
Icon(
Icons.search,
color: Colors.white,
size: 30.0,
),
SizedBox(
width: 10.0,
),
PopupMenuButton(
icon: Icon(Icons.more_vert_outlined,color: Colors.white,),
itemBuilder: (context) => [
PopupMenuItem(
child: TextButton(
child: Text('Group Info',textAlign: TextAlign.left,style: TextStyle(color: Color(0xFF13192F),fontSize: 18.0,fontWeight: FontWeight.normal),),
onPressed: ()=> Navigator.pushNamed(context, GroupInfo.id),
),
),
PopupMenuItem(
child: TextButton(
child: Text('Teacher Profile',textAlign: TextAlign.left,style: TextStyle(color: Color(0xFF13192F),fontSize: 18.0,fontWeight: FontWeight.normal),),
onPressed: ()=> Navigator.pushNamed(context, TeacherProfile2.id),
),
),
PopupMenuItem(
child: Padding(padding:EdgeInsets.only(left: 7.0),child: Text('Classroom Code')),
onTap: () {
Future.delayed(
const Duration(seconds: 0),
() => showDialog(
context: context,
builder: (context) => AlertDialog(
title: Text('This Classroom Code',textAlign: TextAlign.left,style: TextStyle(color: Color(0xFF13192F),fontSize: 18.0,fontWeight: FontWeight.normal)),
content: Padding(
padding:
EdgeInsets.symmetric(horizontal: 0.0),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceAround,
children: [
Text(
classCode,
style: TextStyle(
color: Color(0xFF13192F),
fontSize: 18.0),
),
IconButton(
icon: Icon(
Icons.copy,
color: Color(0xFF13192F),
size: 18.0,
),
onPressed: () {
Clipboard.setData(ClipboardData(text: classCode));
},
),
],
),
),
actions: [
TextButton(
child: Text('Ok',style: TextStyle(color: Color(0xFF13192F)),),
onPressed: () => Navigator.pop(context),
)
],
),
));
},
)
],
),
],
),
)
],
),
),
MessagesStream(),
Container(
padding: EdgeInsets.only(bottom: 7.0,left: 5.0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Expanded(
child: TextField(
style: TextStyle(fontSize: 18.0),
cursorColor: Color(0xFF13192F),
controller: messageTextController,
onChanged: (value) {
messageText = value;
},
decoration: InputDecoration(
hintText: 'Type your message here..',
contentPadding:
EdgeInsets.symmetric(vertical: 0.0, horizontal: 20.0),
border: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(32.0)),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: Color(0xFF13192F), width: 1.5),
borderRadius: BorderRadius.all(Radius.circular(32.0)),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: Color(0xFF13192F), width: 2.5),
borderRadius: BorderRadius.all(Radius.circular(32.0)),
),
),
),
),
Container(
padding: EdgeInsets.only(right: 7.0,bottom: 7.0),
child: IconButton(
onPressed: () {
messageTextController.clear();
_firestore.collection('messages-$classCode').add({
'text': messageText,
'sender': email,
'name': name,
'messageSerial': DateTime.now().toString(),
'messageTime': DateFormat.jm().format(DateTime.now()).toString(),
});
},
icon: Icon(
Icons.send,
color: Color(0xFF13192F),
size: 38.0,
),
),
),
],
),
),
],
),
),
);
}
PopupMenuItem _buildPopupMenuItem(String title) {
return PopupMenuItem(
child: Text(title),
onTap: () {
openDialog();
},
);
}
Future openDialog() => showDialog(
context: context,
builder: (context) => AlertDialog(
title: Text('Class Not Found'),
content: Text('Sorry the given code is not valid!!'),
actions: [
TextButton(
onPressed: () {},
child: Text('Ok'),
)
],
),
);
}
class MessagesStream extends StatelessWidget {
@override
Widget build(BuildContext context) {
String classCode = Provider.of<TaskData>(context, listen: false).classCode;
return StreamBuilder<QuerySnapshot>(
stream: _firestore
.collection('messages-$classCode')
.orderBy('messageSerial', descending: true)
.snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData) {
return Center(
child: CircularProgressIndicator(
backgroundColor: Color(0xFF13192F),
),
);
}
final messages = snapshot.data?.docs;
List<MessageBubble> messageBubbles = [];
for (var message in messages!) {
final messageText = message['text'];
final messageSender = message['name'];
final senderEmail = message['sender'];
final messageTime = message['messageTime'];
final currentUser = Provider.of<TaskData>(context, listen: false).userEmail;
final messageBubble = MessageBubble(
sender: messageSender,
text: messageText,
time: messageTime,
isMe: currentUser == senderEmail,
);
messageBubbles.add(messageBubble);
}
return Expanded(
child: ListView(
reverse: true,
padding: EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0),
children: messageBubbles,
),
);
},
);
}
}
class MessageBubble extends StatelessWidget {
MessageBubble(
{required this.sender,
required this.text,
required this.time,
required this.isMe});
final String sender;
final String text;
final String time;
final bool isMe;
@override
Widget build(BuildContext context) {
return Padding(
padding: EdgeInsets.symmetric(horizontal: 10.0,vertical: 5.0),
child: Column(
crossAxisAlignment:
isMe ? CrossAxisAlignment.end : CrossAxisAlignment.start,
children: <Widget>[
Material(
borderRadius: isMe
? BorderRadius.only(
topLeft: Radius.circular(30.0),
bottomLeft: Radius.circular(30.0),
bottomRight: Radius.circular(30.0))
: BorderRadius.only(
bottomLeft: Radius.circular(30.0),
bottomRight: Radius.circular(30.0),
topRight: Radius.circular(30.0),
),
elevation: 5.0,
color: isMe ? Color(0xFF13192F) : Colors.white,
child: Padding(
padding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 20.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children:[
Text(
isMe ? '' : sender,
textAlign: TextAlign.left,
style: TextStyle(
fontSize: isMe ? 0 : 14.0,
color: Colors.black54,
),
),
Text(
text,
style: TextStyle(
color: isMe ? Colors.white : Colors.black,
fontSize: 18.0,
),
),
Text(
time,
textAlign: TextAlign.end,
style: TextStyle(
fontSize: 11.0,
color:isMe ? Colors.white : Colors.black54,
),
),
]
),
),
),
],
),
);
}
}
| 0 |
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/screens/classwork.dart | import 'dart:ui';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:cms/components/navigation.dart';
import 'package:cms/screens/add-class-work.dart';
import 'package:colorful_safe_area/colorful_safe_area.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:rflutter_alert/rflutter_alert.dart';
import 'dart:math' as math;
import '../components/custom-drawer.dart';
import '../components/task-data.dart';
class Classwork extends StatefulWidget {
static String id = 'class-work';
const Classwork({Key? key}) : super(key: key);
@override
_ClassworkState createState() => _ClassworkState();
}
class _ClassworkState extends State<Classwork> {
final GlobalKey<ScaffoldState> _globalKey = GlobalKey<ScaffoldState>();
final _firestore = FirebaseFirestore.instance;
@override
Widget build(BuildContext context) {
String code = Provider.of<TaskData>(context).classCode;
return Scaffold(
key: _globalKey,
drawer: CustomDrawer(),
floatingActionButton: FloatingActionButton.extended(
backgroundColor: Color(0xFF13192F),
onPressed: () {
showModalBottomSheet<void>(
context: context, builder: (context) => AddClassWork());
}, label: Text('Add Classwork'),
),
body: ColorfulSafeArea(
color: Color(0xFF13192F),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
CustomNavigation("Classwork",(value) {
_globalKey.currentState?.openDrawer();
}),
StreamBuilder<QuerySnapshot>(
stream: _firestore.collection("classwork-$code").snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData)
return LinearProgressIndicator();
else {
final docs = snapshot.data!.docs;
return Expanded(
child: SizedBox(
height: 500.0,
child: ListView.builder(
itemCount: docs.length,
itemBuilder: (context, i) {
final data = docs[i];
return GestureDetector(
onLongPress: (){
Alert(
context: context,
type: AlertType.warning,
title: "Confirm Delete",
desc: "Are you sure you wanna delete this task?",
buttons: [
DialogButton(
child:const Text(
"Delete",
style: TextStyle(color: Colors.white, fontSize: 20),
),
onPressed: () {
_firestore.collection("classwork-$code").doc(data['classworkSerial']).delete();
Navigator.pop(context);
},
color: Colors.red,
),
DialogButton(
child:const Text(
"Cancel",
style: TextStyle(color: Colors.white, fontSize: 20),
),
color: Colors.green,
onPressed: () => Navigator.pop(context),
),
],
).show();
},
child: SizedBox(
width: double.infinity,
child: Container(
margin: EdgeInsets.only(
top: 10.0, left: 10.0, right: 10.0),
color: Color((math.Random().nextDouble() *
0xFFFFFF)
.toInt())
.withOpacity(0.6),
child: Container(
margin: EdgeInsets.only(left: 10.0),
padding: EdgeInsets.symmetric(
vertical: 15.0, horizontal: 20.0),
color: Color(0xFF13192F),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
"Date: ${data['classworkTime']}",
style:
TextStyle(color: Colors.white),
),
Text(
data['classwork'],
style: TextStyle(
color: Colors.white,
fontSize: 20.0),
),
]),
)),
),
);
}),
));
}
}),
],
),
),
);
}
}
| 0 |
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/screens/add-video.dart | import 'dart:io';
import 'dart:ui';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:cms/components/task-data.dart';
import 'package:colorful_safe_area/colorful_safe_area.dart';
import 'package:file_picker/file_picker.dart';
import 'package:firebase_storage/firebase_storage.dart';
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
import 'package:provider/provider.dart';
import 'package:video_player/video_player.dart';
class AddVideo extends StatefulWidget {
static String id = 'add-video';
@override
_AddVideoState createState() => _AddVideoState();
}
class _AddVideoState extends State<AddVideo> {
List<File> _video = [];
final picker = ImagePicker();
late VideoPlayerController _videoPlayerController;
late CollectionReference videoRef;
late Reference ref;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Add Videos'),
backgroundColor: Color(0xFF13192F),
actions: [
FlatButton(
onPressed: (){
uploadFile();
Navigator.pop(context);
},
child: Text('Upload',style: TextStyle(color: Colors.white),),
)
],
),
body: ColorfulSafeArea(
color: Color(0xFF13192F),
child: GridView.builder(
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3),
itemCount: _video.length + 1,
itemBuilder: (context, index) {
if(index >0)
_videoPlayerController = VideoPlayerController.file(_video[index-1])..initialize().then((value) {
setState(() {
});
_videoPlayerController.play();
});
return index == 0
? Center(
child: IconButton(
icon: Icon(Icons.video_call_outlined), onPressed: selectFiles),
)
: Container(
margin: EdgeInsets.all(3.0),
child: AspectRatio(
aspectRatio: _videoPlayerController.value.aspectRatio,
child: VideoPlayer(_videoPlayerController),
),
);
},
),
),);
}
// selectFiles() async {
// FilePickerResult? result = (await FilePicker.platform.pickFiles(allowMultiple: false,type: FileType.video));
// if (result == null) return;
// List<PlatformFile> files = result.files;
// files.forEach((element) {
// setState(() {
// _video.add(File(element.path!));
// });
// });
// }
selectFiles() async {
final pickedImage = await picker.getVideo(source: ImageSource.gallery);
setState(() {
_video.add(File(pickedImage!.path));
});
}
Future uploadFile()async{
String email = Provider.of<TaskData>(context, listen: false).userEmail;
String code = Provider.of<TaskData>(context, listen: false).courseCode;
String batch = Provider.of<TaskData>(context, listen: false).courseBatch;
for(var video in _video){
String newFileName = video.path.toString().split('/').last;
ref = FirebaseStorage.instance.ref().child('videoResources/$email/$code-$batch/$newFileName');
await ref.putFile(video).whenComplete(()async{
await ref.getDownloadURL().then((value){
videoRef.add({'url': value,'email':email, 'courseCode':code, 'courseBatch': batch});
}
);
});
}
}
@override
void initState(){
super.initState();
videoRef = FirebaseFirestore.instance.collection('videoURLs');
}
}
| 0 |
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/screens/login.dart | import 'package:cms/components/error-message.dart';
import 'package:cms/components/task-data.dart';
import 'package:cms/screens/group-screen.dart';
import 'package:cms/screens/register.dart';
import 'package:cms/screens/varification.dart';
import 'package:flutter/material.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:provider/provider.dart';
import '../components/input-field.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'forgot-password.dart';
import 'login-varification.dart';
class Login extends StatefulWidget {
static String id = 'login';
@override
_LoginState createState() => _LoginState();
}
class _LoginState extends State<Login> {
final _auth = FirebaseAuth.instance;
late String email;
late String password;
late String errorMessage = '';
late bool spinner = false;
@override
Widget build(BuildContext context) {
return Scaffold(
body: spinner
? const Center(
child: SpinKitDoubleBounce(
color: Color(0xFF13192F),
size: 50.0,
),
)
: Padding(
padding: const EdgeInsets.symmetric(horizontal: 30.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Center(
child: Material(
borderRadius: BorderRadius.circular(100),
elevation: 5.0,
child: CircleAvatar(
backgroundColor: Color(0xFF13192F),
radius: 73.0,
child: CircleAvatar(
radius: 70.0,
backgroundImage: AssetImage('images/CMS-Logo.png'),
),
),
),
),
SizedBox(
height: 30.0,
),
Text("Login as Teacher",textAlign: TextAlign.center ,style: TextStyle(color: Color(0xFF13192F),fontSize: 20.0,fontWeight: FontWeight.bold),),
SizedBox(
height: 30.0,
),
InputField('Enter your email', false, (value) {
email = value;
}),
const SizedBox(
height: 10.0,
),
InputField('Enter your password', true, (value) {
password = value;
}),
const SizedBox(
height: 10.0,
),
ErrorMessage(errorMessage),
Padding(
padding: const EdgeInsets.symmetric(vertical: 16.0),
child: Material(
borderRadius: const BorderRadius.all(
Radius.circular(32.0),
),
color: Color(0xFF13192F),
elevation: 5.0,
child: MaterialButton(
onPressed: () async {
try {
setState(() {
spinner = true;
});
await Firebase.initializeApp();
final user = await _auth.signInWithEmailAndPassword(
email: email, password: password);
if (user != null) {
Provider.of<TaskData>(context,listen:false).getUser();
Navigator.pushNamed(context, LoginVarification.id);
}
setState(() {
spinner = false;
});
} catch (e) {
setState(() {
spinner = false;
errorMessage = e.toString();
});
}
},
child: const Text(
'Login',
style: TextStyle(color: Colors.white),
),
),
),
),
TextButton(
onPressed: () {
Navigator.pushNamed(context, ForgotPassword.id);
},
style: TextButton.styleFrom(
primary: Color(0xFF13192F), // Text Color
),
child: const Text(
'Forgot password?',
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 16.0),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text('You don\'t have an account?'),
TextButton(
onPressed: () {
Navigator.pushNamed(context, Register.id);
},
style: TextButton.styleFrom(
primary: Color(0xFF13192F), // Text Color
),
child: const Text(
'Register Now',
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 16.0),
),
)
],
),
],
),
),
);
}
}
| 0 |
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/screens/add-image.dart | import 'dart:io';
import 'dart:ui';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:cms/components/task-data.dart';
import 'package:colorful_safe_area/colorful_safe_area.dart';
import 'package:firebase_storage/firebase_storage.dart';
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
import 'package:provider/provider.dart';
class AddImage extends StatefulWidget {
static String id = 'add-image';
@override
_AddImageState createState() => _AddImageState();
}
class _AddImageState extends State<AddImage> {
List<File> _image = [];
final picker = ImagePicker();
late CollectionReference imgRef;
late Reference ref;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Add Images'),
backgroundColor: Color(0xFF13192F),
actions: [
FlatButton(
onPressed: (){
uploadFile();
Navigator.pop(context);
},
child: Text('Upload',style: TextStyle(color: Colors.white),),
)
],
),
body: ColorfulSafeArea(
color: Color(0xFF13192F),
child: GridView.builder(
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3),
itemCount: _image.length + 1,
itemBuilder: (context, index) {
return index == 0
? Center(
child: IconButton(
icon: Icon(Icons.add_a_photo_outlined), onPressed: selectFiles),
)
: Container(
margin: EdgeInsets.all(3.0),
decoration: BoxDecoration(
image: DecorationImage(
image: FileImage(_image[index - 1]),
fit: BoxFit.cover)),
);
},
),
),);
}
selectFiles() async {
final pickedImage = await picker.getImage(source: ImageSource.gallery);
setState(() {
_image.add(File(pickedImage!.path));
});
}
Future uploadFile()async{
String email = Provider.of<TaskData>(context, listen: false).userEmail;
String code = Provider.of<TaskData>(context, listen: false).courseCode;
String batch = Provider.of<TaskData>(context, listen: false).courseBatch;
for(var img in _image){
String newFileName = img.path.toString().split('/').last;
ref = FirebaseStorage.instance.ref().child('imageResources/$newFileName');
await ref.putFile(img).whenComplete(()async{
await ref.getDownloadURL().then((value){
imgRef.add({'url': value,'email':email, 'courseCode':code, 'courseBatch': batch});
}
);
});
}
}
@override
void initState(){
super.initState();
imgRef = FirebaseFirestore.instance.collection('imageURLs');
}
}
| 0 |
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/screens/varification.dart | import 'dart:async';
import 'package:cms/screens/teacher-profile-update.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
class Varification extends StatefulWidget {
static String id = 'verification';
@override
_VarificationState createState() => _VarificationState();
}
class _VarificationState extends State<Varification> {
bool isVarified = false;
bool canResendEmail = true;
Timer? timer;
Color color = Color(0xFF808080);
String sent = "A verification email has been sent to your email.";
@override
void initState(){
super.initState();
isVarified = FirebaseAuth.instance.currentUser!.emailVerified;
if(!isVarified) {
sendVarificationEmail();
timer = Timer.periodic(Duration(seconds: 5), (_){
checkEmailVarified();
});
}
}
@override
void dispose(){
timer?.cancel();
super.dispose();
}
Future checkEmailVarified()async{
await FirebaseAuth.instance.currentUser!.reload();
setState(() {
isVarified = FirebaseAuth.instance.currentUser!.emailVerified;
});
if(isVarified)timer?.cancel();
}
Future sendVarificationEmail() async{
setState(() {
color = Color(0xFF808080);
canResendEmail = false;
});
final user = FirebaseAuth.instance.currentUser!;
await user.sendEmailVerification();
await Future.delayed(Duration(seconds: 5));
setState(() {
canResendEmail = true;
color = Color(0xFF13192F);
});
}
Widget build(BuildContext context) {
if(isVarified) {
return TeacherProfileUpdate();
} else {
return Scaffold(
appBar: AppBar(
title: const Text(
'User Verification',
),
backgroundColor: Color(0xFF13192F),
),
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(sent, style: TextStyle(fontSize: 20.0),
textAlign: TextAlign.center,),
const SizedBox(height: 10.0,),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 100.0),
child: TextButton(
style: TextButton.styleFrom(
backgroundColor: color,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: const [
Icon(Icons.mail, size: 24.0, color: Colors.white,),
SizedBox(width: 10.0,),
Text('Resend',
style: TextStyle(fontSize: 24.0, color: Colors.white),),
],
),
onPressed: (){
canResendEmail?
setState(() {
sent = "A verification email has been resent to your email.";
sendVarificationEmail();
}):null;
}
,
),
)
],
),
);
}
}
}
| 0 |
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/screens/add-group.dart | import 'dart:math';
import 'dart:ui';
import 'package:cms/components/custom-drawer.dart';
import 'package:cms/components/dropdown-field.dart';
import 'package:cms/components/input-field2.dart';
import 'package:cms/components/navigation.dart';
import 'package:cms/components/task-data.dart';
import 'package:cms/screens/group-screen.dart';
import 'package:colorful_safe_area/colorful_safe_area.dart';
import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:provider/provider.dart';
import '../components/multi-dropdown-field.dart';
class AddGroup extends StatefulWidget {
static String id = 'add-group';
@override
_AddGroupState createState() => _AddGroupState();
}
class _AddGroupState extends State<AddGroup> {
final _firestore = FirebaseFirestore.instance;
final GlobalKey<ScaffoldState> _globalKey = GlobalKey<ScaffoldState>();
List<String> deptName = [
'Select Department',
'CSE',
'EEE',
'Civil Engineering',
'Business Administration',
'LAW',
'English',
'Architecture',
'Islamic Study',
'Public Health',
'Tourism and Hospitality Management',
'Bangla'
];
String _deptValue = 'Select Department';
List<String> sectionName = ['A', 'B', 'C', 'D', 'E', 'F', 'G'];
List<Object?> selectSectionList = [];
String _sectionValue = 'Select Section';
late String courseCode;
late String batchNo;
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
key: _globalKey,
drawer: CustomDrawer(),
body: ColorfulSafeArea(
color: Color(0xFF13192F),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
CustomNavigation("Add Groups",(value) {
_globalKey.currentState?.openDrawer();
}),
Container(
child: Stack(
children: [
Container(
height: 28.0,
margin: EdgeInsets.only(right: 50.0),
color: Color(0xFF13192F),
),
Container(
height: 35.0,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30.0))),
),
],
),
),
Padding(
padding: EdgeInsets.only(left: 32.0,bottom: 10.0),
child: Text(
"Create Your Customize Groups",
style: TextStyle(
fontSize: 22.0,
fontWeight: FontWeight.w600,
color: Color(0xFF13192F)),
textAlign: TextAlign.left,
)),
Padding(
padding:
EdgeInsets.symmetric(horizontal: 30.0, vertical: 10.0),
child: Column(
children: [
DropdownField(_deptValue, deptName, (value) {
setState(() {
_deptValue = value;
});
}),
SizedBox(
height: 15.0,
),
InputField2("Enter Course Code", false, (value) {
courseCode = value;
}),
SizedBox(
height: 15.0,
),
InputField2("Enter Batch", false, (value) {
batchNo = value;
}),
SizedBox(
height: 15.0,
),
MultiDropdownField(
'Select Sections',
_sectionValue,
sectionName,
(values) {
selectSectionList = values;
_sectionValue = '';
selectSectionList.forEach((element) {
setState(() {
_sectionValue =
_sectionValue + ' ' + element.toString();
});
});
if (_sectionValue == '') {
setState(() {
_sectionValue = 'Select Section';
});
}
},
),
SizedBox(
height: 15.0,
),
Material(
color: Color(0xFF13192F),
borderRadius: BorderRadius.all(Radius.circular(10.0)),
child: MaterialButton(
child: const Padding(
padding: EdgeInsets.symmetric(
vertical: 15.0, horizontal: 20.0),
child: Text(
"Create Group",
style: TextStyle(
color: Colors.white, fontSize: 16.0),
),
),
onPressed: () {
_firestore.collection('groups').add({
'groupName': courseCode.toUpperCase(),
'groupBatch': batchNo,
'email':
Provider.of<TaskData>(context, listen: false)
.userEmail
});
final sections = _sectionValue.split(' ');
sections.forEach((element) {
if (element != '') {
String classCode = getClassCode();
_firestore.collection('subGroups').add({
'groupName': courseCode.toUpperCase(),
'groupBatch': batchNo,
'groupSection': element,
'email': Provider.of<TaskData>(context,
listen: false)
.userEmail,
'classCode': classCode
});
}
});
Navigator.pushNamed(context, Groups.id);
},
),
),
],
),
)
],
)));
}
String getClassCode() {
String uppercaseLetter = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
String lowercaseLetter = "abcdefghijklmnopqrstuvwxyz";
String digits = "0123456789";
String char = '';
String str = '';
char += "$uppercaseLetter$lowercaseLetter$digits";
str += List.generate(8, (index) {
final indexRandom = Random().nextInt(char.length);
return char[indexRandom];
}).join('');
return str;
}
}
| 0 |
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/screens/welcome-page.dart |
import 'package:flutter/material.dart';
import 'logreg-page.dart';
class WelcomePage extends StatelessWidget {
static String id="welcome-page";
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
backgroundColor: Color(0xFF13192F),
body: SafeArea(
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Padding(
padding: EdgeInsets.only(bottom: 40.0),
child: Text(
'WELCOME TO',
style: TextStyle(
fontSize: 30.0,
color: Colors.white,
letterSpacing: 2.5,
fontWeight: FontWeight.bold,
),
),
),
GestureDetector(
onTap: (){
Navigator.pushNamed(context, LogRegPage.id);
},
child: CircleAvatar(
radius: 90.0,
backgroundImage: AssetImage('images/CMS-Logo.png'),
),
),
Container(
height: 300,
child: Column(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.end,
children: [
Padding(
padding: EdgeInsets.only(top: 100.0,bottom: 50.0),
child: Material(
borderRadius: const BorderRadius.all(
Radius.circular(40.0),
),
color: Colors.white,
elevation: 10.0,
child: MaterialButton(
onPressed: () {
Navigator.pushNamed(context, LogRegPage.id);
},
child: Padding(
padding: EdgeInsets.all(15.0),
child: Text(
'Get Started',
style: TextStyle(color: Color(0xFF13192F),fontSize: 20.0),
),
),
),
),
),
],
),
)
],
),
),
),
),
);
}
} | 0 |
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/screens/group-screen.dart | import 'dart:ui';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:cms/components/custom-drawer.dart';
import 'package:cms/components/task-data.dart';
import 'package:cms/screens/subgroup-screen.dart';
import 'package:flutter/material.dart';
import 'package:colorful_safe_area/colorful_safe_area.dart';
import 'package:provider/provider.dart';
import 'package:rflutter_alert/rflutter_alert.dart';
import '../components/navigation.dart';
import 'add-group.dart';
import 'dart:math' as math;
class Groups extends StatefulWidget {
static String id = 'group';
@override
_GroupsState createState() => _GroupsState();
}
class _GroupsState extends State<Groups> {
final _firestore = FirebaseFirestore.instance;
final GlobalKey<ScaffoldState> _globalKey = GlobalKey<ScaffoldState>();
@override
void initState() {
// TODO: implement initState
super.initState();
setState(() {});
}
@override
Widget build(BuildContext context) {
String email = Provider.of<TaskData>(context, listen: false).userEmail;
String code = Provider.of<TaskData>(context, listen: false).courseCode;
String batch = Provider.of<TaskData>(context, listen: false).courseBatch;
return Scaffold(
key: _globalKey,
drawer: CustomDrawer(),
floatingActionButton: FloatingActionButton.extended(
onPressed: () {
Navigator.pushNamed(context, AddGroup.id);
},
label: Text(
"Add Groups",
textAlign: TextAlign.center,
),
backgroundColor: Color(0xFF13192F),
),
backgroundColor: Colors.white,
body: ColorfulSafeArea(
color: Color(0xFF13192F),
child: Column(
children: [
CustomNavigation("CMS",(value){
_globalKey.currentState?.openDrawer();
}),
Container(
child: Stack(
children: [
Container(
height: 28.0,
margin: EdgeInsets.only(right: 50.0),
color: Color(0xFF13192F),
),
Container(
height: 35.0,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30.0))),
),
Positioned(
child: GestureDetector(
child: Padding(
padding: EdgeInsets.only(top: 10.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
child: Padding(
padding: EdgeInsets.only(left: 20.0,right: 20.0,bottom: 7.0),
child: Text(
"Groups",
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.w500,
),
),
),
decoration: BoxDecoration(
border: Border(
bottom:BorderSide(color: Colors.black,width: 3.0),
),
),
),
SizedBox(
width: 50.0,
),
Container(
child: GestureDetector(
onTap: (){
//Navigator.pushNamed(context, Resources.id);
},
child: Padding(
padding: EdgeInsets.only(left: 20.0,right: 20.0,bottom: 5.0),
child: Text(
"Notifications",
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.w500,
),
),
),
),
),
],
),
),
),
),
],
),
),
SizedBox(
height: 20.0,
),
StreamBuilder<QuerySnapshot>(
stream: _firestore.collection('groups').where('email', isEqualTo: Provider.of<TaskData>(context,listen: false).userEmail).snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData)
return LinearProgressIndicator();
else {
final docs = snapshot.data!.docs;
return Expanded(
child: SizedBox(
height: 500.0,
child: ListView.builder(
itemCount: docs.length,
itemBuilder: (context, i) {
final data = docs[i];
String courseStr = "";
String courseNo = "";
String courseCode = data['groupName'];
for (int j = 0; j < courseCode.length; j++) {
if (courseCode[j]
.contains(new RegExp(r'[0-9]'))) {
courseNo += courseCode[j];
} else if (courseCode[j]
.contains(new RegExp(r'[A-z]'))) {
courseStr += courseCode[j];
}
}
return Padding(
padding: EdgeInsets.symmetric(
vertical: 5.0, horizontal: 15.0),
child: Padding(
padding: EdgeInsets.only(bottom: 5.0),
child: Row(
mainAxisAlignment:
MainAxisAlignment.start,
children: [
CircleAvatar(
child: Column(
mainAxisAlignment:
MainAxisAlignment.center,
children: [
Text(
courseStr,
style: TextStyle(
color: Colors.white,fontSize: 17,fontWeight: FontWeight.w500),
),
Text(
courseNo,
style: TextStyle(
color: Colors.white,fontSize: 14,fontWeight: FontWeight.w500),
),
]),
radius: 28,
backgroundColor: Color((math
.Random()
.nextDouble() *
0xFFFFFF)
.toInt())
.withOpacity(0.6),
),
SizedBox(
width: 10.0,
),
GestureDetector(
onTap: (){
Provider.of<TaskData>(context,listen:false).getGroup(data['groupName'], data['groupBatch']);
Navigator.pushNamed(context, SubGroups.id);
},
onLongPress: ()async{
Alert(
context: context,
type: AlertType.warning,
title: "Confirm Delete",
desc: "Are you sure you wanna delete this Group?",
buttons: [
DialogButton(
child:const Text(
"Delete",
style: TextStyle(color: Colors.white, fontSize: 20),
),
onPressed: () async{
await FirebaseFirestore.instance.collection('subGroups').where('email', isEqualTo: email).where('groupName', isEqualTo: data['groupName']).where('groupBatch', isEqualTo: data['groupBatch']).get().then((value)async {
await FirebaseFirestore.instance.runTransaction((Transaction myTransaction) async {
for(i=0;i<value.docs.length;i++){
await myTransaction.delete(value.docs[i].reference);
}
});
});
await FirebaseFirestore.instance.runTransaction((Transaction myTransaction) async {
await myTransaction.delete(snapshot.data!.docs[i].reference);
});
Navigator.pop(context);
},
color: Color(0xFFE94560),
),
DialogButton(
child:const Text(
"Cancel",
style: TextStyle(color: Colors.white, fontSize: 20),
),
color: Color(0xFF53BF9D),
onPressed: () => Navigator.pop(context),
),
],
).show();
},
child: Container(
width: MediaQuery.of(context).size.width - 100,
padding: EdgeInsets.only(bottom: 8.0),
decoration: BoxDecoration(
border: Border(
bottom:
BorderSide(color: Color(0xFF808080).withOpacity(0.6)),
),
),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
data['groupName'],
style: TextStyle(
fontSize: 19.0,
fontWeight:
FontWeight.w600),
),
Text(
'Batch '+data['groupBatch'],
style: TextStyle(
fontSize: 16.0,
fontWeight:
FontWeight.w400),
),
]),
)
),
]),
),
);
}
),
),
);
}
}),
],
)));
}
}
| 0 |
mirrored_repositories/CMS/lib | mirrored_repositories/CMS/lib/screens/resource.dart | import 'package:cms/components/custom-drawer.dart';
import 'package:cms/components/navigation.dart';
import 'package:cms/screens/group-screen.dart';
import 'package:cms/screens/subgroup-screen.dart';
import 'package:cms/screens/video.resource.dart';
import 'package:colorful_safe_area/colorful_safe_area.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'image-resource.dart';
class Resources extends StatefulWidget {
static String id="resources";
@override
State<Resources> createState() => _ResourcesState();
}
class _ResourcesState extends State<Resources> {
final GlobalKey<ScaffoldState> _globalKey = GlobalKey<ScaffoldState>();
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
key: _globalKey,
drawer:CustomDrawer() ,
body: ColorfulSafeArea(
color: Color(0xFF13192F),
child: Column(
children: [
CustomNavigation("Resources",(value){
_globalKey.currentState?.openDrawer();
}),
Container(
child: Stack(
children: [
Container(
height: 28.0,
margin: EdgeInsets.only(right: 50.0),
color: Color(0xFF13192F),
),
Container(
height: 35.0,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30.0))),
),
Positioned(
child: GestureDetector(
child: Padding(
padding: EdgeInsets.only(top: 10.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
child: GestureDetector(
onTap: (){
Navigator.pushNamed(context, SubGroups.id);
},
child: Padding(
padding: EdgeInsets.only(left: 20.0,right: 20.0,bottom: 7.0),
child: Text(
"Groups",
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.w500,
),
),
),
),
),
SizedBox(
width: 50.0,
),
Container(
child: Padding(
padding: EdgeInsets.only(left: 20.0,right: 20.0,bottom: 5.0),
child: Text(
"Resources",
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.w500,
),
),
),
decoration: BoxDecoration(
border: Border(
bottom:BorderSide(color: Colors.black,width: 3.0),
),
),
),
],
),
),
),
),
],
),
),
Expanded(
child: Row(
children: [
Expanded(
child: Padding(
padding: const EdgeInsets.only(left: 10.0, top: 45.0),
child: GestureDetector(
onTap: (){
Navigator.pushNamed(context, ImageResources.id);
},
child: Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'Images',
style: TextStyle(
fontSize: 30.0,
fontWeight: FontWeight.bold,
),
),
],
),
margin: EdgeInsets.all(15.0),
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.2),
spreadRadius: 3,
blurRadius: 3,
offset: Offset(0, 2),
),
],
color: Colors.white,
borderRadius: BorderRadius.circular(20.0),
),
),
),
),
),
Expanded(child:
Padding(
padding: const EdgeInsets.only(right: 10.0, top: 45.0),
child: GestureDetector(
onTap: (){
Navigator.pushNamed(context, VideoResources.id);
},
child: Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'Videos',
style: TextStyle(
fontSize: 30.0,
fontWeight: FontWeight.bold,
),
),
],
),
margin: EdgeInsets.all(15.0),
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.2),
spreadRadius: 3,
blurRadius: 3,
offset: Offset(0, 2),
),
],
color: Colors.white,
borderRadius: BorderRadius.circular(20.0),
),
),
),
),
),
],
),
),
Expanded(
child: Row(
children: [
Expanded(
child: Padding(
padding: const EdgeInsets.only(left: 10.0, bottom: 45.0),
child: GestureDetector(
onTap: (){
Navigator.pushNamed(context, ImageResources.id);
},
child: Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'Pdfs',
style: TextStyle(
fontSize: 30.0,
fontWeight: FontWeight.bold,
),
),
],
),
margin: EdgeInsets.all(15.0),
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.2),
spreadRadius: 3,
blurRadius: 3,
offset: Offset(0, 2),
),
],
color: Colors.white,
borderRadius: BorderRadius.circular(20.0),
),
),
),
),
),
Expanded(child:
Padding(
padding: const EdgeInsets.only(right: 10.0, bottom: 45.0),
child: Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'Links',
style: TextStyle(
fontSize: 30.0,
fontWeight: FontWeight.bold,
),
),
],
),
margin: EdgeInsets.all(15.0),
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.2),
spreadRadius: 3,
blurRadius: 3,
offset: Offset(0, 2),
),
],
color: Colors.white,
borderRadius: BorderRadius.circular(20.0),
),
),
),
),
],
),
),
],
),
),
);
}
} | 0 |
mirrored_repositories/CMS | mirrored_repositories/CMS/test/widget_test.dart | // This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility that Flutter provides. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:cms/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(const MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}
| 0 |
mirrored_repositories/Cendekia_app | mirrored_repositories/Cendekia_app/lib/constants.dart | import 'package:flutter/material.dart';
// Colors that we use in our app
const kPrimaryColor = Color(0xFF0C9869);
const kTextColor = Color(0xFF3C4046);
const kBackgroundColor = Color(0xFFF9F8FD);
const kSecondaryColor = Color(0xFF8B94BC);
const kGreenColor = Color(0xFF6AC259);
const kRedColor = Color(0xFFE92E30);
const kGrayColor = Color(0xFFC1C1C1);
const kBlackColor = Color(0xFF101010);
const kPrimaryGradient = LinearGradient(
//colors: [Color(0xFF46A0AE), Color(0xFF00FFCB)],
colors: [Color.fromRGBO(3, 132, 161, 1), Color.fromRGBO(121, 225, 247, 1)],
begin: Alignment.centerLeft,
end: Alignment.centerRight,
);
const double kDefaultPadding = 20.0;
| 0 |
mirrored_repositories/Cendekia_app | mirrored_repositories/Cendekia_app/lib/main.dart | import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/services.dart';
import 'package:project_premmob/screens/mainmenu/home.dart';
import 'package:project_premmob/restApi/Loading.dart';
import 'package:get/get_navigation/src/root/get_material_app.dart';
import 'package:project_premmob/screens/splashScreen/splashscreen.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
]);
await Firebase.initializeApp();
runApp(MyApp());
}
FirebaseAuth _auth = FirebaseAuth.instance;
Stream<User?> get streamAuthStatus => _auth.authStateChanges();
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return StreamBuilder<User?>(
stream: streamAuthStatus,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.active) {
print(snapshot.data);
return GetMaterialApp(
debugShowCheckedModeBanner: false,
home: snapshot.data != null && snapshot.data!.emailVerified == true
? Home()
: SplashScreen(),
);
}
return Loading();
},
);
}
}
| 0 |
mirrored_repositories/Cendekia_app/lib | mirrored_repositories/Cendekia_app/lib/restApi/detail_berita.dart | import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
import 'package:project_premmob/models/model_beritanew.dart';
class Detail extends StatelessWidget {
final List list;
final int index;
const Detail({required this.index, required this.list});
@override
Widget build(BuildContext context) {
final String font = 'Baloo 2';
return StreamBuilder<QuerySnapshot<Map<String, dynamic>>>(
stream: FirebaseFirestore.instance.collection('berita').snapshots(),
builder: (context, snapshot) {
if (snapshot.hasData) {
var berita =
snapshot.data!.docs.map((e) => Berita.fromSnapshot(e)).toList();
return Scaffold(
appBar: PreferredSize(
preferredSize: Size.fromHeight(60.0),
child: AppBar(
flexibleSpace: Container(
decoration:
BoxDecoration(borderRadius: BorderRadius.circular(15)),
),
backgroundColor: Color.fromRGBO(1, 180, 220, 1),
elevation: 3,
title: Text(
"Berita",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w700,
fontSize: 30.0,
fontFamily: font,
),
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(
bottom: Radius.circular(10),
),
),
),
),
body: ListView(
children: [
Container(
margin: EdgeInsets.only(
left: 15,
top: 20,
right: 15,
),
child: Text(
berita[index].title,
//textAlign: TextAlign.center,
style: TextStyle(
fontFamily: font,
fontSize: 22,
fontWeight: FontWeight.w800),
),
),
Container(
margin: EdgeInsets.only(left: 15, right: 15, bottom: 10),
child: Row(
children: [
Container(
child: Row(
children: [
Container(
child: Icon(
Icons.access_time,
size: 15,
),
),
SizedBox(
width: 5,
),
Text(
'Nov 22 2022',
style:
TextStyle(fontFamily: font, fontSize: 12),
)
],
),
),
SizedBox(
width: 15,
),
Container(
child: Row(
children: [
Container(
child: Icon(
Icons.person_outline,
size: 15,
),
),
SizedBox(
width: 5,
),
Text(
'Setya Novanto',
style:
TextStyle(fontFamily: font, fontSize: 12),
)
],
),
),
],
),
),
Container(
margin: EdgeInsets.only(right: 15, left: 15),
child: Image.network(berita[index].image),
),
Row(
children: [
Container(
margin: EdgeInsets.only(right: 15, top: 10, left: 15),
child: Text(
berita[index].name,
style: TextStyle(
fontFamily: font,
fontSize: 18,
fontWeight: FontWeight.w600,
),
),
),
],
),
Container(
margin: EdgeInsets.only(right: 15, left: 15),
child: Text(
berita[index].text,
textAlign: TextAlign.justify,
style: TextStyle(fontFamily: font, fontSize: 15),
),
),
],
),
);
}
return const Center(
child: CircularProgressIndicator(),
);
});
}
}
| 0 |
mirrored_repositories/Cendekia_app/lib | mirrored_repositories/Cendekia_app/lib/restApi/berita_new.dart | import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
import 'package:project_premmob/restApi/detail_berita.dart';
import 'package:project_premmob/models/model_beritanew.dart';
import '../constants.dart';
class Berita_new extends StatefulWidget {
const Berita_new({super.key});
@override
State<Berita_new> createState() => _Berita_newState();
}
class _Berita_newState extends State<Berita_new> {
@override
Widget build(BuildContext context) {
return StreamBuilder<QuerySnapshot<Map<String, dynamic>>>(
stream: FirebaseFirestore.instance.collection('berita').snapshots(),
builder: (context, snapshot) {
if (snapshot.hasData) {
var berita =
snapshot.data!.docs.map((e) => Berita.fromSnapshot(e)).toList();
return Container(
height: 280,
//margin: EdgeInsets.only(right: 17, left: 17),
child: ListView.separated(
scrollDirection: Axis.horizontal,
itemBuilder: (context, index) {
return GestureDetector(
// onTap: () {
// return print(index);
// },
onTap: () {
Navigator.of(context).push(new MaterialPageRoute(
builder: (BuildContext context) => new Detail(
list: berita,
index: index,
)));
},
child: Card(
elevation: 5,
margin: EdgeInsets.only(
right: kDefaultPadding,
top: kDefaultPadding / 2,
bottom: kDefaultPadding / 2,
),
shape: RoundedRectangleBorder(
borderRadius: const BorderRadius.all(
Radius.circular(8.0),
),
),
child: Column(
children: [
ClipRRect(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(10),
topRight: Radius.circular(10)),
child: Image.network(
berita[index].image,
width: 250,
height: 150,
fit: BoxFit.cover,
),
),
Container(
width: 220,
padding: EdgeInsets.only(top: 5),
alignment: Alignment.centerLeft,
child: Text(
berita[index].name,
textAlign: TextAlign.left,
style: TextStyle(
fontFamily: 'Baloo 2',
fontSize: 18,
fontWeight: FontWeight.w600),
),
),
Container(
width: 220,
margin: EdgeInsets.only(right: 5, left: 5),
alignment: Alignment.centerLeft,
child: Text(
berita[index].text,
maxLines: 3,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.left,
style: TextStyle(
fontFamily: 'Baloo 2',
fontSize: 13,
),
),
)
],
)),
);
},
separatorBuilder: (context, index) {
return Divider();
},
itemCount: berita.length),
);
}
return const Center(
child: CircularProgressIndicator(),
);
},
);
}
}
| 0 |
mirrored_repositories/Cendekia_app/lib | mirrored_repositories/Cendekia_app/lib/restApi/Loading.dart | import 'package:flutter/material.dart';
class Loading extends StatelessWidget {
const Loading({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Center(child: CircularProgressIndicator()),
),
);
}
}
| 0 |
mirrored_repositories/Cendekia_app/lib | mirrored_repositories/Cendekia_app/lib/controllers/question_controller.dart | // ignore_for_file: deprecated_member_use
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:get/get.dart';
import 'package:project_premmob/models/Questions.dart';
import 'package:project_premmob/screens/mainmenu/page_menu/soal/score/score_screen.dart';
// We use get package for our state management
class QuestionController extends GetxController
with SingleGetTickerProviderMixin {
// Lets animated our progress bar
late AnimationController _animationController;
late Animation _animation;
// so that we can access our animation outside
Animation get animation => this._animation;
late PageController _pageController;
PageController get pageController => this._pageController;
List<Question> _questions = sample_data
.map(
(question) => Question(
id: question['id'],
question: question['question'],
options: question['options'],
answer: question['answer_index']),
)
.toList();
List<Question> get questions => this._questions;
bool _isAnswered = false;
bool get isAnswered => this._isAnswered;
late int _correctAns;
int get correctAns => this._correctAns;
late int _selectedAns;
int get selectedAns => this._selectedAns;
// for more about obs please check documentation
RxInt _questionNumber = 1.obs;
RxInt get questionNumber => this._questionNumber;
int _numOfCorrectAns = 0;
int get numOfCorrectAns => this._numOfCorrectAns;
// called immediately after the widget is allocated memory
@override
void onInit() {
// Our animation duration is 60 s
// so our plan is to fill the progress bar within 60s
_animationController =
AnimationController(duration: Duration(seconds: 5), vsync: this);
_animation = Tween<double>(begin: 0, end: 1).animate(_animationController)
..addListener(() {
// update like setState
update();
});
// start our animation
// Once 60s is completed go to the next qn
_animationController.forward().whenComplete(nextQuestion);
_pageController = PageController();
super.onInit();
}
// // called just before the Controller is deleted from memory
@override
void onClose() {
super.onClose();
_animationController.dispose();
_pageController.dispose();
}
void checkAns(Question question, int selectedIndex) {
// because once user press any option then it will run
_isAnswered = true;
_correctAns = question.answer;
_selectedAns = selectedIndex;
print(_selectedAns);
if (_correctAns == _selectedAns) _numOfCorrectAns++;
print('Hasilnya $_numOfCorrectAns');
// It will stop the counter
_animationController.stop();
update();
//Once user select an ans after 3s it will go to the next qn
Future.delayed(Duration(seconds: 1), () {
nextQuestion();
});
}
void nextQuestion() {
if (_questionNumber.value != _questions.length) {
_isAnswered = false;
_pageController.nextPage(
duration: Duration(milliseconds: 250), curve: Curves.ease);
// Reset the counter
_animationController.reset();
// Then start it again
// Once timer is finish go to the next qn
_animationController.forward().whenComplete(nextQuestion);
} else {
// Get package provide us simple way to naviigate another page
Get.to(ScoreScreen());
}
}
void updateTheQnNum(int index) {
_questionNumber.value = index + 1;
}
}
| 0 |
mirrored_repositories/Cendekia_app/lib | mirrored_repositories/Cendekia_app/lib/models/Questions.dart | // ignore: file_names
class Question {
final int id, answer;
final String question;
final List<String> options;
Question(
{required this.id,
required this.question,
required this.answer,
required this.options});
}
const List sample_data = [
{
"id": 1,
"question":
"Flutter is an open-source UI software development kit created by ______",
"options": ['Apple', 'Google', 'Facebook', 'Microsoft'],
"answer_index": 1,
},
{
"id": 2,
"question": "When google release Flutter.",
"options": ['Jun 2017', 'Jun 2017', 'May 2017', 'May 2018'],
"answer_index": 2,
},
{
"id": 3,
"question": "A memory location that holds a single letter or number.",
"options": ['Double', 'Int', 'Char', 'Word'],
"answer_index": 2,
},
{
"id": 4,
"question": "What command do you use to output data to the screen?",
"options": ['Cin', 'Count>>', 'Cout', 'Output>>'],
"answer_index": 2,
},
];
| 0 |
mirrored_repositories/Cendekia_app/lib | mirrored_repositories/Cendekia_app/lib/models/model_beritanew.dart | import 'package:cloud_firestore/cloud_firestore.dart';
class Berita {
String name;
String image;
String text;
String title;
Timestamp time;
Berita(
{required this.image,
required this.text,
required this.title,
required this.name,
required Timestamp this.time});
Map<String, dynamic> tojson() {
return {
'image': image,
'name': name,
'text': text,
'title': title,
'time': time,
};
}
factory Berita.fromSnapshot(
QueryDocumentSnapshot<Map<String, dynamic>> json) {
return Berita(
image: json['image'],
text: json['text'],
name: json['name'],
title: json['title'],
time: json['time']);
}
}
| 0 |
mirrored_repositories/Cendekia_app/lib/screens | mirrored_repositories/Cendekia_app/lib/screens/splashScreen/page_awal.dart | import 'package:flutter/material.dart';
import 'package:project_premmob/screens/sign_InUp/page_login.dart';
import 'package:project_premmob/screens/sign_InUp/page_register.dart';
class PageAwal extends StatelessWidget {
const PageAwal({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
margin: EdgeInsets.only(bottom: 80, top: 50),
child: Text(
"Cendekia",
style: TextStyle(
color: Color.fromRGBO(1, 180, 220, 1),
fontWeight: FontWeight.w700,
fontSize: 40.0,
fontFamily: 'Baloo 2',
),
),
),
Container(
height: 275,
width: 247.67,
child: Image.asset(
"assets/images/gambar_home.png",
fit: BoxFit.cover,
)),
Container(
padding: EdgeInsets.only(bottom: 30),
margin: EdgeInsets.all(40),
child: Text(
"Tempat Belajar dan Diskusi mengenai segala hal yang berkaitan dengan sekolah",
style: TextStyle(
fontSize: 15,
),
textAlign: TextAlign.center,
),
),
Container(
width: 300,
height: 50,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Color.fromRGBO(1, 180, 220, 1),
elevation: 3,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20))),
onPressed: () {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) {
return Login1();
},
),
);
},
child: Text(
"Daftar",
style: TextStyle(
fontFamily: "Baloo 2", fontSize: 20, color: Colors.white),
),
),
),
Container(
margin: EdgeInsets.all(15),
width: 300,
height: 50,
child: ElevatedButton(
onPressed: () {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) {
return LoginScreen();
},
),
);
},
style: ElevatedButton.styleFrom(
primary: Colors.white,
elevation: 3,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20))),
child: Text(
"Masuk",
style: TextStyle(
fontFamily: "Baloo 2",
fontSize: 20,
color: Color.fromRGBO(1, 180, 220, 1)),
),
),
)
],
),
);
}
}
| 0 |
mirrored_repositories/Cendekia_app/lib/screens | mirrored_repositories/Cendekia_app/lib/screens/splashScreen/berita_new.dart | import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
import 'package:project_premmob/models/model_beritanew.dart';
class Berita_new extends StatefulWidget {
const Berita_new({super.key});
@override
State<Berita_new> createState() => _Berita_newState();
}
class _Berita_newState extends State<Berita_new> {
@override
Widget build(BuildContext context) {
return StreamBuilder<QuerySnapshot<Map<String, dynamic>>>(
stream: FirebaseFirestore.instance.collection('berita').snapshots(),
builder: (context, snapshot) {
if (snapshot.hasData) {
var berita =
snapshot.data!.docs.map((e) => Berita.fromSnapshot(e)).toList();
//UI di masukkan dibawah
return Scaffold();
}
return const Center(
child: CircularProgressIndicator(),
);
},
);
}
}
| 0 |
mirrored_repositories/Cendekia_app/lib/screens | mirrored_repositories/Cendekia_app/lib/screens/splashScreen/splashscreen.dart | import 'package:flutter/material.dart';
import 'dart:async';
import 'package:project_premmob/screens/splashScreen/page_awal.dart';
class SplashScreen extends StatefulWidget {
const SplashScreen({super.key});
@override
State<SplashScreen> createState() => _SplashScreenState();
}
class _SplashScreenState extends State<SplashScreen> {
void initState() {
super.initState();
splashscreenStart();
}
splashscreenStart() async {
var duration = const Duration(seconds: 3);
return Timer(duration, () {
Navigator.pushReplacement(
context,
MaterialPageRoute(builder: (context) => PageAwal()),
);
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Color.fromRGBO(1, 180, 220, 1),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Text(
"Cendekia",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w700,
fontSize: 40.0,
fontFamily: 'Baloo 2',
),
),
],
),
),
);
}
}
| 0 |
mirrored_repositories/Cendekia_app/lib/screens | mirrored_repositories/Cendekia_app/lib/screens/mainmenu/home.dart | import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:project_premmob/screens/mainmenu/components/nav-drawer.dart';
import 'package:project_premmob/screens/mainmenu/components/menu.dart';
import 'package:flutter_image_slideshow/flutter_image_slideshow.dart';
import 'package:project_premmob/screens/mainmenu/page_menu/diskusi.dart';
import 'package:project_premmob/screens/mainmenu/page_menu/komunitas.dart';
import 'package:project_premmob/restApi/berita_new.dart';
import 'package:project_premmob/screens/mainmenu/page_menu/soal/quiz_screen.dart';
import 'page_menu/belajar/belajarNew.dart';
class Home extends StatefulWidget {
const Home({super.key});
@override
State<Home> createState() => _HomeState();
}
class _HomeState extends State<Home> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: DetailPage(),
);
}
}
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
class DetailPage extends StatelessWidget {
const DetailPage({
Key? key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
final String font = 'Baloo 2';
return Scaffold(
backgroundColor: Color.fromRGBO(217, 217, 217, 0.9),
appBar: PreferredSize(
preferredSize: Size.fromHeight(60.0),
key: _scaffoldKey,
child: AppBar(
flexibleSpace: Container(
decoration: BoxDecoration(borderRadius: BorderRadius.circular(15)),
),
backgroundColor: Color.fromRGBO(255, 36, 206, 1),
elevation: 3,
title: Text(
" Cendekia",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w700,
fontSize: 30.0,
fontFamily: font,
),
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(
bottom: Radius.circular(10),
),
),
),
),
endDrawer: DrawerWidget(),
body: SingleChildScrollView(
child: Column(
children: [
Container(
margin: EdgeInsets.only(top: 5, bottom: 5),
child: ImageSlideshow(
indicatorColor: Color.fromARGB(255, 255, 255, 255),
onPageChanged: (value) {
debugPrint('Page changed: $value');
},
autoPlayInterval: 50000,
isLoop: true,
children: [
Image.asset(
'assets/images/Rectangle9.png',
fit: BoxFit.cover,
),
Image.asset(
'assets/images/Rectangle1.png',
fit: BoxFit.cover,
),
Image.asset(
'assets/images/Rectangle2.png',
fit: BoxFit.cover,
),
],
),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),
),
),
Container(
//height: 900,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(20)),
),
child: Column(children: <Widget>[
Container(
height: 150,
decoration: BoxDecoration(
color: Color.fromRGBO(1, 180, 220, 1),
borderRadius: BorderRadius.vertical(
top: Radius.circular(15), bottom: Radius.circular(15)),
),
child: Column(
children: <Widget>[
Flexible(
flex: 3,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Flexible(
flex: 3,
child: Container(
margin: EdgeInsets.all(10),
child: Menu(
title: "Belajar",
gambar: "assets/images/icon_book.png",
press: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return Belajarku();
},
),
);
},
),
),
),
Flexible(
flex: 3,
child: Container(
margin: EdgeInsets.all(10),
child: Menu(
title: "Diskusi",
gambar: "assets/images/icon_message.png",
press: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return Diskusi();
},
),
);
},
),
),
),
Flexible(
flex: 3,
child: Container(
margin: EdgeInsets.all(10),
child: Menu(
title: "Komunitas",
gambar: "assets/images/icon_people.png",
press: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return Discord();
},
),
);
},
),
),
),
Flexible(
flex: 3,
child: Container(
margin: EdgeInsets.all(10),
child: Menu(
title: "Soal",
gambar: "assets/images/icon_book_open.png",
press: () => Get.to(QuizScreen()),
),
),
),
],
),
),
],
),
),
Container(
height: 110,
margin: EdgeInsets.only(top: 5),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(15)),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Row(
children: [
Container(
alignment: Alignment.topLeft,
margin: EdgeInsets.only(
top: 14, left: 17, right: 150),
child: Text(
"Event Terbaru",
style: TextStyle(
color: Color.fromRGBO(1, 180, 220, 1),
fontFamily: font,
fontSize: 20,
fontWeight: FontWeight.w600),
)),
Container(
width: 70,
height: 25,
margin: EdgeInsets.only(top: 14),
child: ElevatedButton(
onPressed: () {
showAlertDialog(context);
},
child: Text(
'Lihat',
style: TextStyle(
color: Colors.white,
fontFamily: font,
fontSize: 13,
fontWeight: FontWeight.w600),
),
style: ElevatedButton.styleFrom(
primary: Color.fromRGBO(1, 180, 220, 1),
elevation: 1,
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(15))),
),
)
],
),
Container(
alignment: Alignment.topLeft,
margin: EdgeInsets.only(left: 17, right: 17),
child: Text(
'Berbagai informasi tentang event-event menarik yang bisa kamu ikuti!',
style: TextStyle(
fontFamily: font,
fontSize: 14,
fontWeight: FontWeight.w600),
)),
],
)),
Container(
margin: EdgeInsets.only(top: 5),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(15)),
child: Column(
//mainAxisAlignment: MainAxisAlignment.start,
children: [
Container(
alignment: Alignment.topLeft,
margin: EdgeInsets.only(top: 14, left: 17),
child: Text(
"Beritaku",
style: TextStyle(
color: Color.fromRGBO(1, 180, 220, 1),
fontFamily: font,
fontSize: 20,
fontWeight: FontWeight.w600),
)),
Container(
alignment: Alignment.topLeft,
margin: EdgeInsets.only(left: 17),
child: Text(
'Berita menarik untuk menambah wawasanmu',
style: TextStyle(
fontFamily: font,
fontSize: 14,
fontWeight: FontWeight.w600),
)),
Berita_new()
],
),
),
Container(
margin: EdgeInsets.only(top: 8, bottom: 8),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"Build By ",
style: TextStyle(
fontFamily: font,
fontSize: 15,
),
),
Text(
"Cendekia",
style: TextStyle(
fontFamily: font,
fontSize: 15,
fontWeight: FontWeight.w600,
color: Color.fromRGBO(1, 180, 220, 1)),
),
],
),
),
]),
),
],
),
),
);
}
}
showAlertDialog(BuildContext context) {
// set up the button
Widget okButton = TextButton(
child: Text(
"OK",
style: TextStyle(
color: Color.fromRGBO(1, 180, 220, 1),
fontSize: 16,
fontFamily: font,
fontWeight: FontWeight.w800),
),
onPressed: () {
Navigator.of(context).pop(false);
},
);
// set up the AlertDialog
AlertDialog alert = AlertDialog(
shape: RoundedRectangleBorder(borderRadius: new BorderRadius.circular(15)),
// title: Text("My title"),
content: Container(
width: 200,
height: 200,
child: Row(
children: [
Container(
// height: 280,
width: 130,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
alignment: Alignment.topLeft,
child: Text(
'Mohon maaf kami sedang berupaya untuk menyediakan fitur ini!',
style: TextStyle(
fontSize: 16,
fontFamily: font,
fontWeight: FontWeight.w800),
)),
Container(
alignment: Alignment.topLeft,
margin: EdgeInsets.only(top: 20),
child: Text(
"Cendekia",
style: TextStyle(
color: Color.fromRGBO(1, 180, 220, 1),
fontSize: 16,
fontFamily: font,
fontWeight: FontWeight.w800),
),
),
],
),
),
Container(
child: Image.network(
'https://firebasestorage.googleapis.com/v0/b/projectpremmob.appspot.com/o/alert.png?alt=media&token=8d6b6140-7316-4e59-b014-9eb514d4dc00',
width: 100,
height: 200,
),
)
],
),
),
actions: [
okButton,
],
);
// show the dialog
showDialog(
context: context,
builder: (BuildContext context) {
return alert;
},
);
}
| 0 |
mirrored_repositories/Cendekia_app/lib/screens/mainmenu | mirrored_repositories/Cendekia_app/lib/screens/mainmenu/page_menu/soal.dart | import 'package:flutter/material.dart';
class RegistrationScreen extends StatefulWidget {
const RegistrationScreen({super.key});
@override
State<RegistrationScreen> createState() => _RegistrationScreenState();
}
class _RegistrationScreenState extends State<RegistrationScreen> {
@override
Widget build(BuildContext context) {
return Container();
}
}
| 0 |
mirrored_repositories/Cendekia_app/lib/screens/mainmenu | mirrored_repositories/Cendekia_app/lib/screens/mainmenu/page_menu/komunitas.dart | import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';
class Discord extends StatelessWidget {
const Discord({super.key});
@override
Widget build(BuildContext context) {
final String font = 'Baloo 2';
return Scaffold(
appBar: PreferredSize(
preferredSize: Size.fromHeight(100), // Set this height
child: Container(
margin: EdgeInsets.only(top: 50),
alignment: Alignment.center,
color: Colors.white,
child: Text("Cendekia",
style: TextStyle(
color: Color.fromRGBO(1, 180, 220, 1),
fontWeight: FontWeight.w700,
fontSize: 40.0,
fontFamily: 'Baloo 2',
)),
),
),
body: WebView(
initialUrl: "https://discord.com/invite/xkkRJ4Ed",
javascriptMode: JavascriptMode.unrestricted,
),
);
}
}
| 0 |
mirrored_repositories/Cendekia_app/lib/screens/mainmenu | mirrored_repositories/Cendekia_app/lib/screens/mainmenu/page_menu/diskusi.dart | import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';
class Diskusi extends StatelessWidget {
const Diskusi({super.key});
@override
Widget build(BuildContext context) {
final String font = 'Baloo 2';
return Scaffold(
appBar: PreferredSize(
preferredSize: Size.fromHeight(60.0),
child: AppBar(
flexibleSpace: Container(
decoration: BoxDecoration(borderRadius: BorderRadius.circular(15)),
),
backgroundColor: Color.fromRGBO(1, 180, 220, 1),
elevation: 3,
title: Text(
"Diskusi",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w700,
fontSize: 30.0,
fontFamily: font,
),
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(
bottom: Radius.circular(10),
),
),
),
),
body: WebView(
initialUrl:
"https://web.telegram.org/z/#?tgaddr=tg%3A%2F%2Fjoin%3Finvite%3Dye0k30lCgoY4MzNl",
javascriptMode: JavascriptMode.unrestricted,
),
);
;
}
}
| 0 |
mirrored_repositories/Cendekia_app/lib/screens/mainmenu/page_menu | mirrored_repositories/Cendekia_app/lib/screens/mainmenu/page_menu/soal/quiz_screen.dart | import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:project_premmob/controllers/question_controller.dart';
import 'components/body.dart';
class QuizScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
QuestionController _controller = Get.put(QuestionController());
return Scaffold(
extendBodyBehindAppBar: true,
backgroundColor: Color.fromRGBO(1, 180, 220, 1),
appBar: AppBar(
// Fluttter show the back button automatically
backgroundColor: Colors.transparent,
elevation: 0,
actions: [
MaterialButton(
onPressed: _controller.nextQuestion, child: Text("Skip")),
],
),
body: Body(),
);
}
}
| 0 |
mirrored_repositories/Cendekia_app/lib/screens/mainmenu/page_menu/soal | mirrored_repositories/Cendekia_app/lib/screens/mainmenu/page_menu/soal/components/question_card.dart | import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:project_premmob/controllers/question_controller.dart';
import 'package:project_premmob/models/Questions.dart';
import '../../../../../constants.dart';
import 'option.dart';
class QuestionCard extends StatelessWidget {
const QuestionCard({
Key? key,
// it means we have to pass this
required this.question,
}) : super(key: key);
final Question question;
@override
Widget build(BuildContext context) {
final font = "Baloo 2";
QuestionController _controller = Get.put(QuestionController());
return Container(
margin: EdgeInsets.symmetric(horizontal: kDefaultPadding),
padding: EdgeInsets.all(kDefaultPadding),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(25),
),
child: Column(
children: [
Text(
question.question,
style: TextStyle(
fontFamily: font,
fontSize: 20,
),
),
SizedBox(height: kDefaultPadding / 2),
...List.generate(
question.options.length,
(index) => Option(
index: index,
text: question.options[index],
press: () => _controller.checkAns(question, index),
),
),
],
),
);
}
}
| 0 |
mirrored_repositories/Cendekia_app/lib/screens/mainmenu/page_menu/soal | mirrored_repositories/Cendekia_app/lib/screens/mainmenu/page_menu/soal/components/option.dart | import 'package:flutter/material.dart';
import 'package:get/get_state_manager/get_state_manager.dart';
import 'package:project_premmob/controllers/question_controller.dart';
import '../../../../../constants.dart';
class Option extends StatelessWidget {
const Option({
Key? key,
required this.text,
required this.index,
required this.press,
}) : super(key: key);
final String text;
final int index;
final VoidCallback press;
@override
Widget build(BuildContext context) {
return GetBuilder<QuestionController>(
init: QuestionController(),
builder: (qnController) {
Color getTheRightColor() {
if (qnController.isAnswered) {
if (index == qnController.correctAns) {
return kGreenColor;
} else if (index == qnController.selectedAns &&
qnController.selectedAns != qnController.correctAns) {
return kRedColor;
}
}
return kGrayColor;
}
IconData getTheRightIcon() {
return getTheRightColor() == kRedColor ? Icons.close : Icons.done;
}
return InkWell(
onTap: press,
child: Container(
margin: EdgeInsets.only(top: kDefaultPadding),
padding: EdgeInsets.all(kDefaultPadding),
decoration: BoxDecoration(
border: Border.all(color: getTheRightColor()),
borderRadius: BorderRadius.circular(15),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"${index + 1}. $text",
style: TextStyle(color: getTheRightColor(), fontSize: 16),
),
Container(
height: 26,
width: 26,
decoration: BoxDecoration(
color: getTheRightColor() == kGrayColor
? Colors.transparent
: getTheRightColor(),
borderRadius: BorderRadius.circular(50),
border: Border.all(color: getTheRightColor()),
),
child: getTheRightColor() == kGrayColor
? null
: Icon(getTheRightIcon(), size: 16),
)
],
),
),
);
});
}
}
| 0 |
mirrored_repositories/Cendekia_app/lib/screens/mainmenu/page_menu/soal | mirrored_repositories/Cendekia_app/lib/screens/mainmenu/page_menu/soal/components/progress_bar.dart | import 'package:flutter/material.dart';
import 'package:get/get_state_manager/get_state_manager.dart';
import 'package:project_premmob/controllers/question_controller.dart';
import 'package:project_premmob/screens/mainmenu/components/nav-drawer.dart';
import '../../../../../constants.dart';
class ProgressBar extends StatelessWidget {
const ProgressBar({
Key? key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
width: double.infinity,
height: 35,
decoration: BoxDecoration(
border: Border.all(color: Colors.white, width: 2),
borderRadius: BorderRadius.circular(50),
),
child: GetBuilder<QuestionController>(
init: QuestionController(),
builder: (controller) {
return Stack(
children: [
// LayoutBuilder provide us the available space for the conatiner
// constraints.maxWidth needed for our animation
LayoutBuilder(
builder: (context, constraints) => Container(
// from 0 to 1 it takes 60s
width: constraints.maxWidth * controller.animation.value,
decoration: BoxDecoration(
gradient: kPrimaryGradient,
borderRadius: BorderRadius.circular(50),
),
),
),
Positioned.fill(
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: kDefaultPadding / 2),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"${(controller.animation.value * 5).round()} sec",
style: TextStyle(
fontFamily: font,
color: Colors.white,
fontSize: 15),
),
//SvgPicture.asset("assets/icons/clock.svg"),
Icon(
Icons.access_time_sharp,
color: Colors.white,
)
],
),
),
),
],
);
},
),
);
}
}
| 0 |
mirrored_repositories/Cendekia_app/lib/screens/mainmenu/page_menu/soal | mirrored_repositories/Cendekia_app/lib/screens/mainmenu/page_menu/soal/components/body.dart | import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:project_premmob/constants.dart';
import 'package:project_premmob/controllers/question_controller.dart';
import 'progress_bar.dart';
import 'question_card.dart';
class Body extends StatelessWidget {
@override
Widget build(BuildContext context) {
// So that we have acccess our controller
QuestionController _questionController = Get.put(QuestionController());
final font = 'Baloo 2';
return Stack(
children: [
SafeArea(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding:
const EdgeInsets.symmetric(horizontal: kDefaultPadding),
child: ProgressBar(),
),
SizedBox(height: kDefaultPadding),
Padding(
padding:
const EdgeInsets.symmetric(horizontal: kDefaultPadding),
child: Obx(
() => Text.rich(
TextSpan(
text:
"Question ${_questionController.questionNumber.value}",
// style: Theme.of(context)
// .textTheme
// .headline4!
// .copyWith(color: kSecondaryColor),
style: TextStyle(
fontFamily: font,
fontSize: 28,
fontWeight: FontWeight.w600,
color: Colors.white70),
children: [
TextSpan(
text: "/${_questionController.questions.length}",
style: TextStyle(
fontFamily: font,
fontSize: 28,
fontWeight: FontWeight.w600,
color: Colors.white70),
),
],
),
),
),
),
Divider(thickness: 1.5),
SizedBox(height: kDefaultPadding),
Expanded(
child: PageView.builder(
// Block swipe to next qn
physics: NeverScrollableScrollPhysics(),
controller: _questionController.pageController,
onPageChanged: _questionController.updateTheQnNum,
itemCount: _questionController.questions.length,
itemBuilder: (context, index) => QuestionCard(
question: _questionController.questions[index]),
),
),
],
),
)
],
);
}
}
| 0 |
mirrored_repositories/Cendekia_app/lib/screens/mainmenu/page_menu/soal | mirrored_repositories/Cendekia_app/lib/screens/mainmenu/page_menu/soal/score/score_screen.dart | import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:project_premmob/constants.dart';
import 'package:project_premmob/controllers/question_controller.dart';
import 'package:flutter_svg/svg.dart';
class ScoreScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
QuestionController _qnController = Get.put(QuestionController());
return Scaffold(
body: Stack(
fit: StackFit.expand,
children: [
//SvgPicture.asset("assets/icons/bg.svg", fit: BoxFit.fill),
Column(
children: [
Spacer(flex: 3),
Text(
"Score",
style: Theme.of(context)
.textTheme
.headline3!
.copyWith(color: kSecondaryColor),
),
Spacer(),
Text(
"${_qnController.numOfCorrectAns * 10}/${_qnController.questions.length * 10}",
style: Theme.of(context)
.textTheme
.headline4!
.copyWith(color: kSecondaryColor),
),
Spacer(flex: 3),
],
)
],
),
);
}
}
| 0 |
mirrored_repositories/Cendekia_app/lib/screens/mainmenu/page_menu | mirrored_repositories/Cendekia_app/lib/screens/mainmenu/page_menu/belajar/belajarnew.dart | import 'dart:ui' as ui;
import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:project_premmob/screens/mainmenu/page_menu/belajar/belajar_model.dart';
import 'package:project_premmob/screens/mainmenu/page_menu/belajar/detail_belajar.dart';
import 'package:project_premmob/screens/mainmenu/page_menu/belajar/rating.dart';
class Belajarku extends StatefulWidget {
const Belajarku({super.key});
@override
State<Belajarku> createState() => _BelajarkuState();
}
class _BelajarkuState extends State<Belajarku> {
final double _borderRadius = 24;
final font = 'Baloo 2';
@override
Widget build(BuildContext context) {
return StreamBuilder<QuerySnapshot<Map<String, dynamic>>>(
stream: FirebaseFirestore.instance.collection('belajar').snapshots(),
builder: (context, snapshot) {
if (snapshot.hasData) {
var belajar =
snapshot.data!.docs.map((e) => Belajar.fromSnapshot(e)).toList();
return Scaffold(
appBar: PreferredSize(
preferredSize: Size.fromHeight(100), // Set this height
child: Container(
margin: EdgeInsets.only(top: 50),
alignment: Alignment.center,
child: Text("Cendekia",
style: TextStyle(
color: Color.fromRGBO(1, 180, 220, 1),
fontWeight: FontWeight.w700,
fontSize: 40.0,
fontFamily: 'Baloo 2',
)),
),
),
body: ListView.separated(
itemBuilder: (context, index) {
return GestureDetector(
onTap: () {
print(index);
Navigator.of(context).push(new MaterialPageRoute(
builder: (BuildContext context) => new DetailBelajar(
list: belajar,
index: index,
)));
},
child: Center(
child: Padding(
padding: const EdgeInsets.only(
right: 16.0, left: 16.0, top: 10),
child: Stack(
children: <Widget>[
Container(
height: 150,
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(_borderRadius),
gradient: LinearGradient(
colors: [
Color.fromRGBO(1, 180, 220, 1),
Color.fromRGBO(138, 233, 239, 1),
],
begin: Alignment.topLeft,
end: Alignment.bottomRight),
boxShadow: [
BoxShadow(
color: Color.fromRGBO(138, 233, 239, 1),
blurRadius: 12,
offset: Offset(0, 3),
),
],
),
),
Positioned(
right: 0,
bottom: 0,
top: 0,
child: CustomPaint(
size: Size(100, 150),
painter: CustomCardShapePainter(
_borderRadius,
Color.fromRGBO(1, 180, 220, 1),
Color.fromRGBO(138, 233, 239, 1),
),
),
),
Positioned.fill(
child: Row(
children: <Widget>[
Expanded(
child: Container(
margin: EdgeInsets.all(15),
child: ClipOval(
child: Image.network(
belajar[index].image,
),
),
),
flex: 2,
),
Expanded(
flex: 4,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
Text(
belajar[index].title,
style: TextStyle(
color: Colors.white,
fontFamily: font,
fontSize: 17,
fontWeight: FontWeight.w600),
),
Text(
belajar[index].text,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: Colors.white,
fontFamily: font,
),
),
SizedBox(height: 16),
Row(
children: <Widget>[
Icon(
Icons.person_outline_rounded,
color: Colors.white,
size: 16,
),
SizedBox(
width: 8,
),
Flexible(
child: Text(
belajar[index].author,
style: TextStyle(
color: Colors.white,
fontFamily: font,
),
),
),
],
),
],
),
),
Expanded(
flex: 2,
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text(
belajar[index].rating.toString(),
style: TextStyle(
color: Colors.white,
fontFamily: font,
fontSize: 18,
fontWeight: FontWeight.w700),
),
RatingBar(
rating: belajar[index].rating),
//const SizedBox(height: 8),
Text(
"Cendekia",
style: TextStyle(
color: Colors.white,
fontFamily: font,
fontSize: 15,
fontWeight: FontWeight.w800),
),
],
),
),
],
),
),
],
),
),
),
);
},
separatorBuilder: (context, index) {
return Divider();
},
itemCount: belajar.length),
);
}
return const Center(
child: CircularProgressIndicator(
backgroundColor: Colors.white,
value: 0.20,
),
);
},
);
}
}
class CustomCardShapePainter extends CustomPainter {
final double radius;
final Color startColor;
final Color endColor;
CustomCardShapePainter(this.radius, this.startColor, this.endColor);
@override
void paint(Canvas canvas, Size size) {
var radius = 24.0;
var paint = Paint();
paint.shader = ui.Gradient.linear(
Offset(0, 0), Offset(size.width, size.height), [
HSLColor.fromColor(startColor).withLightness(0.8).toColor(),
endColor
]);
var path = Path()
..moveTo(0, size.height)
..lineTo(size.width - radius, size.height)
..quadraticBezierTo(
size.width, size.height, size.width, size.height - radius)
..lineTo(size.width, radius)
..quadraticBezierTo(size.width, 0, size.width - radius, 0)
..lineTo(size.width - 1.5 * radius, 0)
..quadraticBezierTo(-radius, 2 * radius, 0, size.height)
..close();
canvas.drawPath(path, paint);
}
@override
bool shouldRepaint(CustomPainter oldDelegate) {
return true;
}
}
| 0 |
mirrored_repositories/Cendekia_app/lib/screens/mainmenu/page_menu | mirrored_repositories/Cendekia_app/lib/screens/mainmenu/page_menu/belajar/rating.dart | import 'package:flutter/material.dart';
class RatingBar extends StatelessWidget {
final double rating;
const RatingBar({Key? key, required this.rating}) : super(key: key);
@override
Widget build(BuildContext context) {
return Row(
mainAxisSize: MainAxisSize.min,
children: List.generate(rating.floor(), (index) {
return Icon(
Icons.star,
color: Colors.white,
size: 16,
);
}),
);
}
}
| 0 |
mirrored_repositories/Cendekia_app/lib/screens/mainmenu/page_menu | mirrored_repositories/Cendekia_app/lib/screens/mainmenu/page_menu/belajar/belajar_model.dart | import 'dart:ffi';
import 'package:cloud_firestore/cloud_firestore.dart';
class Belajar {
String author;
String image;
String text;
String title;
String yt;
String baner;
double rating;
// int startColor;
// int endColor;
Belajar({
required this.image,
required this.text,
required this.title,
required this.author,
required this.rating,
required this.yt,
required this.baner,
// required this.startColor,
// required this.endColor
});
Map<String, dynamic> tojson() {
return {
'image': image,
'name': author,
'text': text,
'title': title,
'star': rating,
'yt': yt,
'baner': baner,
// 'startColor': startColor,
// 'endColor': endColor,
};
}
factory Belajar.fromSnapshot(
QueryDocumentSnapshot<Map<String, dynamic>> json) {
return Belajar(
image: json['image'],
text: json['text'],
title: json['title'],
author: json['author'],
rating: json['rating'],
yt: json['yt'],
baner: json['baner'],
// startColor: json['startColor'],
// endColor: json['endColor']
);
}
}
| 0 |
mirrored_repositories/Cendekia_app/lib/screens/mainmenu/page_menu | mirrored_repositories/Cendekia_app/lib/screens/mainmenu/page_menu/belajar/detail_belajar.dart | import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
import 'package:youtube_player_flutter/youtube_player_flutter.dart';
import 'belajar_model.dart';
class DetailBelajar extends StatefulWidget {
final List list;
final int index;
const DetailBelajar({required this.index, required this.list});
@override
State<DetailBelajar> createState() => _DetailBelajarState();
}
class _DetailBelajarState extends State<DetailBelajar> {
late YoutubePlayerController _controller;
@override
Widget build(BuildContext context) {
bool _like = false;
final font = 'Baloo 2';
double width = MediaQuery.of(context).size.width;
double height = MediaQuery.of(context).size.height;
return StreamBuilder<QuerySnapshot<Map<String, dynamic>>>(
stream: FirebaseFirestore.instance.collection('belajar').snapshots(),
builder: (context, snapshot) {
if (snapshot.hasData) {
var belajar = snapshot.data!.docs
.map((e) => Belajar.fromSnapshot(e))
.toList();
final vidioID =
YoutubePlayer.convertUrlToId(belajar[widget.index].yt);
_controller = YoutubePlayerController(
initialVideoId: vidioID!,
flags: const YoutubePlayerFlags(autoPlay: false));
return Scaffold(
body: SingleChildScrollView(
child: Container(
width: width,
child: Stack(
children: <Widget>[
Container(
height: height * 0.30,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/python.png'),
fit: BoxFit.cover)),
child: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
Colors.black.withOpacity(0.9),
Colors.black.withOpacity(0.5),
Colors.black.withOpacity(0.0),
Colors.black.withOpacity(0.0),
Colors.black.withOpacity(0.5),
Colors.black.withOpacity(0.9),
],
begin: Alignment.topLeft,
end: Alignment.bottomRight)),
),
),
Container(
width: width,
//margin: EdgeInsets.only(top: height * 0.5),
margin: EdgeInsets.only(top: 230),
padding: EdgeInsets.all(30),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30),
topRight: Radius.circular(30)),
),
child: Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
child: Text(
belajar[widget.index].title,
//textAlign: TextAlign.center,
style: TextStyle(
fontFamily: font,
fontSize: 28,
fontWeight: FontWeight.w800),
),
),
Container(
margin: EdgeInsets.only(bottom: 10),
child: Row(
children: [
Container(
child: Row(
children: [
Container(
child: Icon(
Icons.access_time,
size: 15,
),
),
SizedBox(
width: 5,
),
Text(
'Nov 22 2022',
style: TextStyle(
fontFamily: font, fontSize: 12),
)
],
),
),
SizedBox(
width: 15,
),
Container(
child: Row(
children: [
Container(
child: Icon(
Icons.person_outline,
size: 15,
),
),
SizedBox(
width: 5,
),
Text(
belajar[widget.index].author,
style: TextStyle(
fontFamily: font, fontSize: 12),
)
],
),
),
],
),
),
YoutubePlayer(
controller: _controller,
showVideoProgressIndicator: true,
onReady: () => debugPrint('Ready'),
bottomActions: [
CurrentPosition(),
ProgressBar(
isExpanded: true,
colors: const ProgressBarColors(
playedColor: Colors.white,
handleColor: Colors.white),
)
],
),
// Row(
// children: [
// Container(
// margin: EdgeInsets.only(
// right: 15, top: 10, left: 15),
// child: Text(
// belajar[widget.index].title,
// style: TextStyle(
// fontFamily: font,
// fontSize: 18,
// fontWeight: FontWeight.w600,
// ),
// ),
// ),
// ],
// ),
SizedBox(
height: 10,
),
Container(
child: Text(
belajar[widget.index].text,
textAlign: TextAlign.justify,
style:
TextStyle(fontFamily: font, fontSize: 15),
),
),
SizedBox(
height: 10,
),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: <Widget>[
Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[],
),
],
)
],
),
),
),
// Positioned(
// left: 30,
// top: height * 0.02,
// child: GestureDetector(
// onTap: () {
// Navigator.pop(context);
// },
// child: Icon(
// Icons.backspace_outlined,
// size: 30,
// color: Colors.white,
// ),
// ),
// ),
// Positioned(
// right: 30,
// top: 10,
// child: GestureDetector(
// // onTap: () {
// // setState(() {
// // _like = !_like;
// // });
// // },
// child: Container(
// height: 70,
// width: 70,
// decoration: BoxDecoration(
// color: Colors.white,
// borderRadius: BorderRadius.circular(35),
// boxShadow: [
// BoxShadow(
// color: Colors.black.withOpacity(0.5),
// blurRadius: 5,
// spreadRadius: 1)
// ]),
// child: Icon(
// Icons.favorite,
// size: 45,
// color: (_like) ? Colors.red : Colors.grey[600],
// ),
// ),
// ),
// )
],
),
),
),
);
}
return const Center(
child: CircularProgressIndicator(),
);
});
}
}
| 0 |
mirrored_repositories/Cendekia_app/lib/screens/mainmenu | mirrored_repositories/Cendekia_app/lib/screens/mainmenu/components/menu.dart | import 'package:flutter/material.dart';
import 'package:project_premmob/screens/mainmenu/page_menu/komunitas.dart';
class Menu extends StatelessWidget {
final String title;
final String gambar;
final Function? press;
// ignore: use_key_in_widget_constructors
const Menu({required this.title, required this.gambar, this.press});
@override
Widget build(BuildContext context) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
//margin: EdgeInsets.only(right: 19, left: 19),
width: 65,
height: 65,
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15),
),
child: InkWell(
onTap: press as void Function()?,
splashColor: Color.fromRGBO(91, 213, 240, 1),
child: Center(
child: Image(
image: AssetImage(gambar),
height: 35,
width: 35,
))),
),
),
Container(
margin: EdgeInsets.only(top: 0.1, bottom: 5),
child: Text(
title,
style: TextStyle(
fontSize: 12,
color: Colors.white,
fontFamily: 'Baloo 2',
fontWeight: FontWeight.w500),
),
)
],
);
}
}
| 0 |
mirrored_repositories/Cendekia_app/lib/screens/mainmenu | mirrored_repositories/Cendekia_app/lib/screens/mainmenu/components/nav-drawer.dart | import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:project_premmob/screens/sign_InUp/components/user_model.dart';
import 'package:project_premmob/screens/sign_InUp/page_login.dart';
final String font = 'Baloo 2';
class DrawerWidget extends StatefulWidget {
const DrawerWidget({super.key});
@override
State<DrawerWidget> createState() => _DrawerWidgetState();
}
class _DrawerWidgetState extends State<DrawerWidget> {
User? user = FirebaseAuth.instance.currentUser;
UserModel loggedInUser = UserModel();
void initState() {
super.initState();
FirebaseFirestore.instance
.collection("users")
.doc(user!.uid)
.get()
.then((value) {
this.loggedInUser = UserModel.fromMap(value.data());
setState(() {});
});
}
@override
Widget build(BuildContext context) {
return Drawer(
backgroundColor: Color.fromRGBO(1, 180, 220, 1),
child: ListView(
padding: EdgeInsets.zero,
children: <Widget>[
_drawerHeader(),
const SizedBox(height: 15),
_drawerItem(
icon: Icons.person,
text: "${loggedInUser.name}",
),
_drawerItem(
icon: Icons.alternate_email,
text: "${loggedInUser.email}",
),
_drawerItem(
icon: Icons.alternate_email,
text: '${loggedInUser.username}',
),
_drawerItem(
icon: Icons.phone,
text: '${loggedInUser.no_telepone}',
),
_drawerItem(
icon: Icons.people,
text: '${loggedInUser.jenjang}',
),
_drawerItem(
icon: Icons.date_range,
text: '${loggedInUser.lahir}',
),
Divider(height: 50, thickness: 2),
Container(
margin: EdgeInsets.only(
left: 20,
right: 20,
),
height: 45,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.white,
elevation: 5,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20))),
onPressed: () {
logout(context);
},
child: Text(
"Keluar",
style: TextStyle(
fontFamily: "Baloo 2",
fontSize: 20,
color: Color.fromRGBO(0, 0, 0, 80),
),
),
),
),
const SizedBox(height: 20),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"Build By ",
style: TextStyle(
fontFamily: font,
fontSize: 15,
),
),
Text(
"Cendekia",
style: TextStyle(
fontFamily: font,
fontSize: 15,
fontWeight: FontWeight.w600,
color: Colors.white),
),
],
),
],
),
);
}
// the logout function
Future<void> logout(BuildContext context) async {
await FirebaseAuth.instance.signOut();
Navigator.of(context).pushReplacement(
MaterialPageRoute(builder: (context) => LoginScreen()));
}
}
Widget _drawerHeader() {
return Container(
alignment: Alignment.topCenter,
margin: EdgeInsets.only(top: 70),
child: Column(
children: [
Container(
//margin: EdgeInsets.only(top: 15),
child: Text(
'Cendekia',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w700,
fontSize: 30.0,
fontFamily: font,
),
),
),
Container(
margin: EdgeInsets.only(top: 15),
height: 90,
width: 90,
child: ClipOval(
// child: Image(
// image: NetworkImage(FirebaseAuth.instance.currentUser?.),
// fit: BoxFit.cover),
),
),
],
),
);
}
Widget _drawerItem({
required IconData icon,
required String text,
}) {
return Container(
child: Container(
margin: EdgeInsets.only(
left: 20,
top: 15,
right: 20,
),
height: 45,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: Colors.white,
),
child: Row(
children: [
Container(
margin: EdgeInsets.only(left: 20),
child: Icon(icon, color: Color.fromRGBO(1, 180, 220, 1)),
),
Container(
margin: EdgeInsets.only(left: 10),
child: Text(
text,
style: TextStyle(
fontFamily: font,
fontSize: 15,
color: Color.fromRGBO(0, 0, 0, 80),
),
),
),
],
),
),
);
}
| 0 |
mirrored_repositories/Cendekia_app/lib/screens | mirrored_repositories/Cendekia_app/lib/screens/sign_InUp/page_register.dart | import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:get/get.dart';
import 'package:project_premmob/screens/sign_InUp/components/accountcheck.dart';
import 'package:project_premmob/screens/sign_InUp/components/user_model.dart';
import 'package:project_premmob/screens/sign_InUp/page_login.dart';
import '../mainmenu/home.dart';
class Login1 extends StatefulWidget {
const Login1({Key? key}) : super(key: key);
@override
_Login1State createState() => _Login1State();
}
class _Login1State extends State<Login1> {
final _auth = FirebaseAuth.instance;
// string for displaying the error Message
String? errorMessage;
// editing Controller
final nameeditController = new TextEditingController();
final usernameeditController = new TextEditingController();
final emaileditController = new TextEditingController();
final no_teleponeeditController = new TextEditingController();
final passwordeditController = new TextEditingController();
final jenjangeditController = new TextEditingController();
final proveditController = new TextEditingController();
final kotaeditController = new TextEditingController();
final lahireditController = new TextEditingController();
//final confirmPasswordEditingController = new TextEditingController();
// our form key
final _formKey = GlobalKey<FormState>();
final textFieldFocusNode = FocusNode();
bool _obscured = false;
bool _checkBoxVal = false;
void _toggle() {
setState(() {
_obscured = !_obscured;
if (textFieldFocusNode.hasPrimaryFocus)
return; // If focus is on text field, dont unfocus
textFieldFocusNode.canRequestFocus = false;
});
}
final items = [
'Jenjang',
'SMP',
'SMA',
'SMK',
'UMUM',
];
int index = 0;
final String font = 'Baloo 2';
@override
Widget build(BuildContext context) {
return Scaffold(
body: ListView(
children: [
Container(
margin: EdgeInsets.only(top: 80),
alignment: Alignment.center,
child: Text("Cendekia",
style: TextStyle(
color: Color.fromRGBO(1, 180, 220, 1),
fontWeight: FontWeight.w700,
fontSize: 40.0,
fontFamily: 'Baloo 2',
)),
),
const SizedBox(height: 15),
Container(
child: Column(
children: <Widget>[
Text("Daftar",
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.w700,
fontSize: 25.0,
fontFamily: 'Baloo 2',
)),
Container(
padding: EdgeInsets.only(right: 50, left: 50),
child: Text(
"Buat akun Cendekia kamu untuk dapat menggunakan fitur Cendekia",
style: TextStyle(
color: Colors.black,
fontSize: 15.0,
fontFamily: 'Baloo 2',
),
textAlign: TextAlign.center,
),
)
],
)),
const SizedBox(height: 20),
// nama lengkap
Form(
key: _formKey,
child: Column(
children: <Widget>[
Container(
width: 325,
child: Material(
elevation: 3.0,
borderRadius: BorderRadius.circular(20),
child: TextFormField(
controller: nameeditController,
autofocus: false,
decoration: InputDecoration(
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(20),
borderSide: BorderSide(
color: Colors.white,
),
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(20),
borderSide: BorderSide(
color: Colors.white,
),
),
prefixIcon: Padding(
padding: EdgeInsets.all(8),
child: Icon(Icons.person,
color: Color.fromRGBO(1, 180, 220, 1)),
),
hintText: 'Nama Lengkap',
fillColor: Colors.white,
filled: true,
contentPadding:
EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0),
),
validator: (value) {
RegExp regex = new RegExp(r'^.{3,}$');
if (value!.isEmpty) {
return ("Name cannot be Empty");
}
if (!regex.hasMatch(value)) {
return ("Enter Valid name(Min. 3 Character)");
}
return null;
},
onSaved: (value) {
nameeditController.text = value!;
},
),
),
),
const SizedBox(height: 15),
// username
Container(
width: 325,
child: Material(
elevation: 3.0,
borderRadius: BorderRadius.circular(20),
child: TextFormField(
controller: usernameeditController,
autofocus: false,
decoration: InputDecoration(
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(20),
borderSide: BorderSide(
color: Colors.white,
),
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(20),
borderSide: BorderSide(
color: Colors.white,
),
),
prefixIcon: Padding(
padding: EdgeInsets.all(8),
child: Icon(Icons.alternate_email,
color: Color.fromRGBO(1, 180, 220, 1)),
),
hintText: 'Username',
fillColor: Colors.white,
filled: true,
contentPadding:
EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0),
),
validator: (value) {
RegExp regex = new RegExp(r'^.{3,}$');
if (value!.isEmpty) {
return ("Username cannot be Empty");
}
if (!regex.hasMatch(value)) {
return ("Enter Valid name(Min. 3 Character)");
}
return null;
},
onSaved: (value) {
usernameeditController.text = value!;
},
),
),
),
const SizedBox(height: 15),
// email
Container(
width: 325,
child: Material(
elevation: 3.0,
borderRadius: BorderRadius.circular(20),
child: TextFormField(
controller: emaileditController,
autofocus: false,
decoration: InputDecoration(
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(20),
borderSide: BorderSide(
color: Colors.white,
),
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(20),
borderSide: BorderSide(
color: Colors.white,
),
),
prefixIcon: Padding(
padding: EdgeInsets.all(8),
child: Icon(Icons.email,
color: Color.fromRGBO(1, 180, 220, 1)),
),
hintText: 'Email',
fillColor: Colors.white,
filled: true,
contentPadding:
EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0),
),
keyboardType: TextInputType.emailAddress,
validator: (value) {
if (value!.isEmpty) {
return ("Please Enter Your Email");
}
// reg expression for email validation
if (!RegExp("^[a-zA-Z0-9+_.-]+@[a-zA-Z0-9.-]+.[a-z]")
.hasMatch(value)) {
return ("Please Enter a valid email");
}
return null;
},
onSaved: (value) {
emaileditController.text = value!;
},
),
),
),
const SizedBox(height: 15),
// no telephone
Container(
width: 325,
child: Material(
elevation: 3.0,
borderRadius: BorderRadius.circular(20),
child: TextFormField(
autofocus: false,
decoration: InputDecoration(
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(20),
borderSide: BorderSide(
color: Colors.white,
),
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(20),
borderSide: BorderSide(
color: Colors.white,
),
),
prefixIcon: Padding(
padding: EdgeInsets.all(8),
child: Icon(Icons.phone,
color: Color.fromRGBO(1, 180, 220, 1)),
),
hintText: 'No. Telepon',
fillColor: Colors.white,
filled: true,
contentPadding:
EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0),
),
onSaved: (value) {
no_teleponeeditController.text = value!;
},
),
),
),
const SizedBox(height: 15),
// password
Container(
width: 325,
child: Material(
elevation: 2,
borderRadius: BorderRadius.circular(20),
child: TextFormField(
controller: passwordeditController,
autofocus: false,
decoration: InputDecoration(
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(20),
borderSide: BorderSide(
color: Colors.white,
),
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(20),
borderSide: BorderSide(
color: Colors.white,
),
),
prefixIcon: Padding(
padding: EdgeInsets.all(8),
child: Icon(
Icons.lock,
color: Color.fromRGBO(1, 180, 220, 1),
),
),
suffixIcon: Padding(
padding: const EdgeInsets.fromLTRB(0, 0, 4, 0),
child: GestureDetector(
onTap: _toggle,
child: Icon(
_obscured
? Icons.visibility_rounded
: Icons.visibility_off_rounded,
size: 24,
color: Color.fromRGBO(1, 180, 220, 1)),
),
),
hintText: 'Password',
fillColor: Colors.white,
filled: true,
contentPadding:
EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0),
),
obscureText: true,
validator: (value) {
RegExp regex = new RegExp(r'^.{6,}$');
if (value!.isEmpty) {
return ("Password is required for login");
}
if (!regex.hasMatch(value)) {
return ("Enter Valid Password(Min. 6 Character)");
}
},
onSaved: (value) {
passwordeditController.text = value!;
},
),
),
),
const SizedBox(height: 15),
// jenjang
Container(
width: 325,
child: Container(
width: 325,
child: GestureDetector(
child: TextField(
enabled: false,
textInputAction: TextInputAction.none,
autofocus: false,
decoration: InputDecoration(
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(20),
borderSide: BorderSide(
color: Colors.white,
),
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(20),
borderSide: BorderSide(
color: Colors.white,
),
),
prefixIcon: Padding(
padding: EdgeInsets.all(8),
child: Icon(Icons.people,
color: Color.fromRGBO(1, 180, 220, 1)),
),
hintText: items[index],
filled: true,
contentPadding:
EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0),
),
),
onTap: () {
showModalBottomSheet(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20.0),
),
context: context,
builder: (BuildContext context) {
return FractionallySizedBox(
heightFactor: 0.8,
child: Column(
children: [
Container(
margin: EdgeInsets.only(
top: 14, right: 18),
alignment: Alignment.centerRight,
child: TextButton(
onPressed: () {},
child: Text(
"Selesai",
style: TextStyle(
fontFamily: font,
fontWeight: FontWeight.w600,
fontSize: 18,
color: Color.fromRGBO(
1, 180, 220, 1)),
))),
SizedBox(
height: 300,
child: CupertinoPicker(
looping: true,
itemExtent: 64,
children: items
.map((item) => Center(
child: Text(
item,
style: TextStyle(
fontSize: 25,
fontFamily: font,
fontWeight:
FontWeight.w600,
color: Color.fromRGBO(
1, 180, 220, 1)),
),
))
.toList(),
onSelectedItemChanged: (index) {
setState(() => this.index = index);
final item = items[index];
jenjangeditController.text =
items[index];
//print(items[index]);
},
),
)
],
),
);
});
}),
),
),
const SizedBox(height: 15),
// asal provinsi
Container(
width: 325,
child: Material(
elevation: 3.0,
borderRadius: BorderRadius.circular(20),
child: TextFormField(
autofocus: false,
decoration: InputDecoration(
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(20),
borderSide: BorderSide(
color: Colors.white,
),
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(20),
borderSide: BorderSide(
color: Colors.white,
),
),
prefixIcon: Padding(
padding: EdgeInsets.all(8),
child: Icon(Icons.location_pin,
color: Color.fromRGBO(1, 180, 220, 1)),
),
hintText: 'Asal Provinsi',
fillColor: Colors.white,
filled: true,
contentPadding:
EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0),
),
onSaved: (value) {
proveditController.text = value!;
},
),
),
),
const SizedBox(height: 15),
// asal kota
Container(
width: 325,
child: Material(
elevation: 3.0,
borderRadius: BorderRadius.circular(20),
child: TextFormField(
autofocus: false,
decoration: InputDecoration(
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(20),
borderSide: BorderSide(
color: Colors.white,
),
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(20),
borderSide: BorderSide(
color: Colors.white,
),
),
prefixIcon: Padding(
padding: EdgeInsets.all(8),
child: Icon(Icons.location_pin,
color: Color.fromRGBO(1, 180, 220, 1)),
),
hintText: 'Asal Kota',
fillColor: Colors.white,
filled: true,
contentPadding:
EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0),
),
onSaved: (value) {
kotaeditController.text = value!;
},
),
),
),
const SizedBox(height: 15),
// tahun lahir
Container(
width: 325,
child: Material(
elevation: 3.0,
borderRadius: BorderRadius.circular(20),
child: TextFormField(
autofocus: false,
decoration: InputDecoration(
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(20),
borderSide: BorderSide(
color: Colors.white,
),
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(20),
borderSide: BorderSide(
color: Colors.white,
),
),
prefixIcon: Padding(
padding: EdgeInsets.all(8),
child: Icon(Icons.date_range,
color: Color.fromRGBO(1, 180, 220, 1)),
),
hintText: 'Tahun Lahir',
fillColor: Colors.white,
filled: true,
contentPadding:
EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0),
),
onSaved: (value) {
lahireditController.text = value!;
},
),
),
),
const SizedBox(height: 15),
//Check Box
Container(
width: 325,
child: Row(
children: <Widget>[
Checkbox(
value: _checkBoxVal,
onChanged: (value) {
_checkBoxVal = value!;
setState(() {});
},
),
Column(
children: <Widget>[
Row(
children: <Widget>[
Text(
"Saya telah menyetujui ",
style: const TextStyle(
fontFamily: "Baloo 2",
fontSize: 15,
),
),
GestureDetector(
onTap: () {},
child: Text(
"Syarat dan",
style: const TextStyle(
color: Color.fromRGBO(1, 180, 220, 1),
fontFamily: "Baloo 2",
fontSize: 15,
),
),
)
],
),
Container(
child: Row(
children: <Widget>[
GestureDetector(
onTap: () {},
child: Text(
"ketentuan ",
style: const TextStyle(
color: Color.fromRGBO(1, 180, 220, 1),
fontFamily: "Baloo 2",
fontSize: 15,
),
),
),
Text(
"yang berlaku",
style: const TextStyle(
fontFamily: "Baloo 2",
fontSize: 15,
),
),
],
),
)
],
)
],
),
),
const SizedBox(height: 15),
// tombol datar
Container(
width: 325,
height: 50,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Color.fromRGBO(1, 180, 220, 1),
elevation: 5,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20))),
onPressed: () {
signUp(emaileditController.text,
passwordeditController.text);
},
child: Text(
"Daftar",
style: TextStyle(
fontFamily: "Baloo 2",
fontSize: 20,
color: Colors.white),
),
),
),
const SizedBox(height: 20),
// auto cek
AccountCheck(
login: false,
press: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return LoginScreen();
},
),
);
},
),
const SizedBox(height: 21),
],
),
),
],
),
);
}
void signUp(String email, String password) async {
if (_formKey.currentState!.validate()) {
try {
UserCredential myUser = await _auth.createUserWithEmailAndPassword(
email: email, password: password);
// .then((value) => {postDetailsToFirestore()})
// .catchError((e) {
// Fluttertoast.showToast(msg: e!.message);
// });
await myUser.user!.sendEmailVerification();
Get.defaultDialog(
title: "Email Verifikasi",
middleText: "Kami telah mengirimkan email verifikasi ke $email",
onConfirm: () {
postDetailsToFirestore();
Get.back();
Get.back();
},
textConfirm: "Ya saya akan cek email");
} on FirebaseAuthException catch (error) {
switch (error.code) {
case "invalid-email":
errorMessage = "Your email address appears to be malformed.";
break;
case "wrong-password":
errorMessage = "Your password is wrong.";
break;
case "user-not-found":
errorMessage = "User with this email doesn't exist.";
break;
case "user-disabled":
errorMessage = "User with this email has been disabled.";
break;
case "too-many-requests":
errorMessage = "Too many requests";
break;
case "operation-not-allowed":
errorMessage = "Signing in with Email and Password is not enabled.";
break;
default:
errorMessage = "An undefined Error happened.";
}
Fluttertoast.showToast(msg: errorMessage!);
print(error.code);
}
}
}
postDetailsToFirestore() async {
// calling our firestore
// calling our user model
// sedning these values
FirebaseFirestore firebaseFirestore = FirebaseFirestore.instance;
User? user = _auth.currentUser;
UserModel userModel = UserModel();
// writing all the values
//userModel.uid = user?.uid;
userModel.uid = user?.uid;
userModel.name = nameeditController.text;
userModel.username = usernameeditController.text;
userModel.email = user!.email;
userModel.no_telepone = no_teleponeeditController.text;
userModel.password = passwordeditController.text;
userModel.jenjang = jenjangeditController.text;
userModel.prov = proveditController.text;
userModel.kota = kotaeditController.text;
userModel.lahir = lahireditController.text;
await firebaseFirestore
.collection("users")
.doc(user.uid)
.set(userModel.toMap());
Fluttertoast.showToast(msg: "Account created successfully :) ");
// Navigator.pushAndRemoveUntil(
// (context),
// MaterialPageRoute(builder: (context) => LoginScreen()),
// (route) => false);
}
}
| 0 |
mirrored_repositories/Cendekia_app/lib/screens | mirrored_repositories/Cendekia_app/lib/screens/sign_InUp/page_login.dart | import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:get/get.dart';
import 'package:project_premmob/screens/sign_InUp/components/accountcheck.dart';
import 'package:project_premmob/screens/sign_InUp/page_register.dart';
import '../mainmenu/home.dart';
class LoginScreen extends StatefulWidget {
const LoginScreen({Key? key}) : super(key: key);
@override
_LoginScreenState createState() => _LoginScreenState();
}
class _LoginScreenState extends State<LoginScreen> {
final textFieldFocusNode = FocusNode();
bool _obscured = false;
final _formKey = GlobalKey<FormState>();
final TextEditingController emailController =
new TextEditingController(text: "[email protected]");
final TextEditingController passwordController =
new TextEditingController(text: "kamal123");
final _auth = FirebaseAuth.instance;
String? errorMessage;
void _toggleObscured() {
setState(() {
_obscured = !_obscured;
if (textFieldFocusNode.hasPrimaryFocus) return;
textFieldFocusNode.canRequestFocus = false;
});
}
@override
Widget build(BuildContext context) {
//email field
final emailField = TextFormField(
autofocus: false,
controller: emailController,
keyboardType: TextInputType.emailAddress,
validator: (value) {
if (value!.isEmpty) {
return ("Please Enter Your Email");
}
// reg expression for email validation
if (!RegExp("^[a-zA-Z0-9+_.-]+@[a-zA-Z0-9.-]+.[a-z]")
.hasMatch(value)) {
return ("Please Enter a valid email");
}
return null;
},
onSaved: (value) {
emailController.text = value!;
},
textInputAction: TextInputAction.next,
decoration: InputDecoration(
prefixIcon: Padding(
padding: EdgeInsets.all(8),
child: Icon(Icons.person, color: Color.fromRGBO(1, 180, 220, 1)),
),
contentPadding: EdgeInsets.fromLTRB(20, 15, 20, 15),
hintText: "Username",
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(20),
borderSide: BorderSide(
color: Colors.white,
),
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(20),
),
));
//password field
final passwordField = TextFormField(
autofocus: false,
controller: passwordController,
obscureText: true,
decoration: InputDecoration(
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(20),
borderSide: BorderSide(
color: Colors.white,
),
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(20),
borderSide: BorderSide(
color: Colors.white,
),
),
prefixIcon: Padding(
padding: EdgeInsets.all(8),
child: Icon(
Icons.lock,
color: Color.fromRGBO(1, 180, 220, 1),
),
),
suffixIcon: Padding(
padding: const EdgeInsets.fromLTRB(0, 0, 4, 0),
child: GestureDetector(
onTap: _toggleObscured,
child: Icon(
_obscured
? Icons.visibility_rounded
: Icons.visibility_off_rounded,
size: 24,
color: Color.fromRGBO(1, 180, 220, 1)),
),
),
hintText: 'Password',
fillColor: Colors.white,
filled: true,
contentPadding: EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0),
),
validator: (value) {
RegExp regex = new RegExp(r'^.{6,}$');
if (value!.isEmpty) {
return ("Password is required for login");
}
if (!regex.hasMatch(value)) {
return ("Enter Valid Password(Min. 6 Character)");
}
return null;
},
onSaved: (value) {
passwordController.text = value!;
},
);
final loginButton = Material(
elevation: 5,
borderRadius: BorderRadius.circular(20),
color: Color.fromRGBO(1, 180, 220, 1),
child: MaterialButton(
padding: EdgeInsets.fromLTRB(20, 15, 20, 15),
minWidth: MediaQuery.of(context).size.width,
onPressed: () {
signIn(emailController.text, passwordController.text);
},
child: Text(
"Masuk",
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 20,
color: Colors.white,
),
)),
);
return Scaffold(
backgroundColor: Colors.white,
body: Center(
child: SingleChildScrollView(
child: Container(
color: Colors.white,
child: Padding(
padding: const EdgeInsets.only(left: 30.0, right: 30.0),
child: Form(
key: _formKey,
child: Column(
children: <Widget>[
Container(
//margin: EdgeInsets.only(top: 10),
alignment: Alignment.center,
child: Text("Cendekia",
style: TextStyle(
color: Color.fromRGBO(1, 180, 220, 1),
fontWeight: FontWeight.w700,
fontSize: 40.0,
fontFamily: 'Baloo 2',
)),
),
const SizedBox(height: 74),
Container(
child: Text("Masuk",
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.w700,
fontSize: 25.0,
fontFamily: 'Baloo 2',
)),
),
const SizedBox(height: 20),
Container(
child: Material(
elevation: 2,
child: emailField,
borderRadius: BorderRadius.circular(20),
),
),
SizedBox(height: 25),
Container(
child: Material(
elevation: 2,
child: passwordField,
borderRadius: BorderRadius.circular(20),
),
),
const SizedBox(height: 20),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
"Lupa Password ? ",
style: const TextStyle(
fontFamily: "Baloo 2",
fontSize: 15,
),
),
GestureDetector(
onTap: () {},
child: Text(
"Reset",
style: const TextStyle(
color: Color.fromRGBO(1, 180, 220, 1),
fontFamily: "Baloo 2",
fontSize: 15,
),
),
)
],
),
const SizedBox(height: 15),
loginButton,
const SizedBox(height: 15),
AccountCheck(
press: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return Login1();
},
),
);
},
),
],
),
),
),
),
),
),
);
}
// login function
void signIn(String email, String password) async {
if (_formKey.currentState!.validate()) {
try {
UserCredential myUser = await _auth.signInWithEmailAndPassword(
email: email, password: password);
// .then((uid) => {
// Fluttertoast.showToast(msg: "Login Successful"),
// Navigator.of(context).pushReplacement(
// MaterialPageRoute(builder: (context) => Home())),
// });
if (myUser.user!.emailVerified) {
Fluttertoast.showToast(msg: "Login Successful");
Navigator.of(context)
.pushReplacement(MaterialPageRoute(builder: (context) => Home()));
} else {
Get.defaultDialog(
title: "Email Verifikasi",
middleText: "$email belum terverifikasi",
);
}
} on FirebaseAuthException catch (error) {
switch (error.code) {
case "invalid-email":
errorMessage = "Your email address appears to be malformed.";
break;
case "wrong-password":
errorMessage = "Your password is wrong.";
break;
case "user-not-found":
errorMessage = "User with this email doesn't exist.";
break;
case "user-disabled":
errorMessage = "User with this email has been disabled.";
break;
case "too-many-requests":
errorMessage = "Too many requests";
break;
case "operation-not-allowed":
errorMessage = "Signing in with Email and Password is not enabled.";
break;
default:
errorMessage = "An undefined Error happened.";
}
Fluttertoast.showToast(msg: errorMessage!);
print(error.code);
}
}
}
}
| 0 |
mirrored_repositories/Cendekia_app/lib/screens/sign_InUp | mirrored_repositories/Cendekia_app/lib/screens/sign_InUp/components/accountcheck.dart | import 'package:flutter/material.dart';
class AccountCheck extends StatelessWidget {
final bool login;
final Function? press;
const AccountCheck({
Key? key,
this.login = true,
required this.press,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
login ? "Belum memiliki akun ? " : "Sudah Memiliki Akun ? ",
style: TextStyle(
fontFamily: "Baloo 2",
fontSize: 15,
),
),
GestureDetector(
onTap: press as void Function()?,
child: Text(
login ? "Daftar" : "Masuk",
style: const TextStyle(
color: Color.fromRGBO(1, 180, 220, 1),
fontFamily: "Baloo 2",
fontSize: 15,
),
),
)
],
);
}
}
| 0 |
mirrored_repositories/Cendekia_app/lib/screens/sign_InUp | mirrored_repositories/Cendekia_app/lib/screens/sign_InUp/components/user_model.dart | import 'package:cloud_firestore/cloud_firestore.dart';
class UserModel {
String? uid;
String? name;
String? username;
String? email;
String? no_telepone;
String? password;
String? jenjang;
String? prov;
String? kota;
String? lahir;
UserModel(
{this.uid,
this.name,
this.username,
this.email,
this.no_telepone,
this.password,
this.jenjang,
this.prov,
this.kota,
this.lahir});
// receiving data from server
factory UserModel.fromMap(map) {
return UserModel(
uid: map['uid'],
name: map['name'],
username: map['username'],
email: map['email'],
no_telepone: map['no_telepone'],
password: map['password'],
jenjang: map['jenjang'],
prov: map['prov'],
kota: map['kota'],
lahir: map['lahir'],
);
}
// sending data to our server
Map<String, dynamic> toMap() {
return {
'uid': uid,
'name': name,
'username': username,
'email': email,
'no_telepone': no_telepone,
'password': password,
'jenjang': jenjang,
'prov': prov,
'kota': kota,
'lahir': lahir,
};
}
// factory UserModel.fromSnapshot(
// QueryDocumentSnapshot<Map<String, dynamic>> json) {
// return UserModel(
// uid: json['uid'],
// name: json['name'],
// username: json['username'],
// email: json['email'],
// );
// }
}
| 0 |
mirrored_repositories/Cendekia_app | mirrored_repositories/Cendekia_app/test/widget_test.dart | // This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility in the flutter_test package. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:project_premmob/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}
| 0 |
mirrored_repositories/flutter_amazon_clone | mirrored_repositories/flutter_amazon_clone/lib/firebase_options.dart | // File generated by FlutterFire CLI.
// ignore_for_file: lines_longer_than_80_chars, avoid_classes_with_only_static_members
import 'package:firebase_core/firebase_core.dart' show FirebaseOptions;
import 'package:flutter/foundation.dart'
show defaultTargetPlatform, kIsWeb, TargetPlatform;
/// Default [FirebaseOptions] for use with your Firebase apps.
///
/// Example:
/// ```dart
/// import 'firebase_options.dart';
/// // ...
/// await Firebase.initializeApp(
/// options: DefaultFirebaseOptions.currentPlatform,
/// );
/// ```
class DefaultFirebaseOptions {
static FirebaseOptions get currentPlatform {
if (kIsWeb) {
return web;
}
switch (defaultTargetPlatform) {
case TargetPlatform.android:
return android;
case TargetPlatform.iOS:
return ios;
case TargetPlatform.macOS:
return macos;
case TargetPlatform.windows:
throw UnsupportedError(
'DefaultFirebaseOptions have not been configured for windows - '
'you can reconfigure this by running the FlutterFire CLI again.',
);
case TargetPlatform.linux:
throw UnsupportedError(
'DefaultFirebaseOptions have not been configured for linux - '
'you can reconfigure this by running the FlutterFire CLI again.',
);
default:
throw UnsupportedError(
'DefaultFirebaseOptions are not supported for this platform.',
);
}
}
static const FirebaseOptions web = FirebaseOptions(
apiKey: 'AIzaSyDXuHW8LEhdaDePvJ29TL4Qr2gv-Fx6y-A',
appId: '1:654822826830:web:55c63e2b34e1fa6476b41f',
messagingSenderId: '654822826830',
projectId: 'clone-4bbeb',
authDomain: 'clone-4bbeb.firebaseapp.com',
storageBucket: 'clone-4bbeb.appspot.com',
);
static const FirebaseOptions android = FirebaseOptions(
apiKey: 'AIzaSyDagz7lpxAEb6EUewQ5yTt0eUQVpgOL54s',
appId: '1:654822826830:android:a5e9aa93c5b65d6176b41f',
messagingSenderId: '654822826830',
projectId: 'clone-4bbeb',
storageBucket: 'clone-4bbeb.appspot.com',
);
static const FirebaseOptions ios = FirebaseOptions(
apiKey: 'AIzaSyBOjoI_spTBfjpa84LHcXaBrvNZR_6rU_Y',
appId: '1:654822826830:ios:07362cc6bdc2807076b41f',
messagingSenderId: '654822826830',
projectId: 'clone-4bbeb',
storageBucket: 'clone-4bbeb.appspot.com',
iosBundleId: 'farizaaa.app.amazonClone',
);
static const FirebaseOptions macos = FirebaseOptions(
apiKey: 'AIzaSyBOjoI_spTBfjpa84LHcXaBrvNZR_6rU_Y',
appId: '1:654822826830:ios:78c8e163c8cdb1f976b41f',
messagingSenderId: '654822826830',
projectId: 'clone-4bbeb',
storageBucket: 'clone-4bbeb.appspot.com',
iosBundleId: 'farizaaa.app.amazonClone.RunnerTests',
);
}
| 0 |
mirrored_repositories/flutter_amazon_clone | mirrored_repositories/flutter_amazon_clone/lib/main.dart | import 'package:amazon_clone/firebase_options.dart';
import 'package:amazon_clone/layout/screen_layout.dart';
import 'package:amazon_clone/providers/user_details_provider.dart';
import 'package:amazon_clone/screens/sign_in_screen.dart';
import 'package:amazon_clone/utils/color_theme.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
runApp(const AmazonClone());
}
class AmazonClone extends StatelessWidget {
const AmazonClone({super.key});
@override
Widget build(BuildContext context) {
return MultiProvider(
providers: [
ChangeNotifierProvider<UserDetailsProvider>(
create: (_) => UserDetailsProvider())
],
child: MaterialApp(
title: "Amazon Clone",
debugShowCheckedModeBanner: false,
theme: ThemeData.light()
.copyWith(scaffoldBackgroundColor: backgroundColor),
//stream builder constantly listens to the changes(data that chnages,Strems) that happen in the screen and rebuilds what in the
//so here every time the user log in nad out the widget is gonna rebuild
home: StreamBuilder(
stream: FirebaseAuth.instance.authStateChanges(),
builder: (context, AsyncSnapshot<User?> user) {
if (user.connectionState == ConnectionState.waiting) {
return const Center(
child: CircularProgressIndicator(
color: Colors.orange,
),
);
} else if (user.hasData) {
// return const ScreenLayout();
// print("uid:${FirebaseAuth.instance.currentUser!.uid}");
// return ElevatedButton(
// onPressed: () {
// FirebaseAuth.instance.signOut();
// },
// child: Text("Sign out"));
//return const Text("Signed In");
return const ScreenLayout();
} else {
return const SignInScreen();
}
}),
),
);
}
}
| 0 |
mirrored_repositories/flutter_amazon_clone/lib | mirrored_repositories/flutter_amazon_clone/lib/widgets/text_field_widget.dart | import 'package:flutter/material.dart';
class TextFieldWidget extends StatefulWidget {
final String title;
final TextEditingController controller;
final bool obscureText;
final String hintText;
const TextFieldWidget(
{super.key,
required this.title,
required this.controller,
required this.obscureText,
required this.hintText});
@override
State<TextFieldWidget> createState() => _TextFieldWidgetState();
}
class _TextFieldWidgetState extends State<TextFieldWidget> {
late FocusNode focusNode;
bool isInFocus = false;
@override
void initState() {
super.initState();
focusNode = FocusNode();
focusNode.addListener(() {
if (focusNode.hasFocus) {
setState(() {
isInFocus = true;
});
} else {
setState(() {
isInFocus = false;
});
}
});
}
@override
Widget build(BuildContext context) {
return Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(bottom: 10),
child: Text(
widget.title,
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 17),
),
),
Container(
decoration: BoxDecoration(boxShadow: [
isInFocus
? BoxShadow(
color: Colors.orange.withOpacity(0.4),
blurRadius: 8,
spreadRadius: 2)
: BoxShadow(
color: Colors.black.withOpacity(0.2),
blurRadius: 8,
spreadRadius: 2)
]),
child: TextField(
focusNode: focusNode,
obscureText: widget.obscureText,
controller: widget.controller,
maxLines: 1,
decoration: InputDecoration(
filled: true,
fillColor: Colors.white,
hintText: widget.hintText,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(3),
borderSide: BorderSide(
color: Colors.grey,
width: 1,
),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.orange, width: 1))),
),
)
],
);
}
}
| 0 |
mirrored_repositories/flutter_amazon_clone/lib | mirrored_repositories/flutter_amazon_clone/lib/widgets/category_widget.dart | import 'package:amazon_clone/screens/result_screen.dart';
import 'package:amazon_clone/utils/constants.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
class CategoryWidget extends StatelessWidget {
final int index;
const CategoryWidget({super.key, required this.index});
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ResulstScreen(query: categoriesList[index]),
),
);
},
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(7),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.3),
blurRadius: 8,
spreadRadius: 1,
)
]),
child: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Image.network(
categoryLogos[index],
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
categoriesList[index],
style: TextStyle(
fontWeight: FontWeight.w500, letterSpacing: 0.5),
),
)
],
),
),
),
);
}
}
| 0 |
mirrored_repositories/flutter_amazon_clone/lib | mirrored_repositories/flutter_amazon_clone/lib/widgets/search_bar_widget.dart | import 'package:amazon_clone/screens/result_screen.dart';
import 'package:amazon_clone/utils/color_theme.dart';
import 'package:amazon_clone/utils/constants.dart';
import 'package:amazon_clone/screens/search_screen.dart';
import 'package:flutter/material.dart';
class SearchBarWidget extends StatelessWidget implements PreferredSizeWidget {
final bool isReadOnly;
final bool hasBackButton;
SearchBarWidget(
{super.key,
prefferedSize,
required this.hasBackButton,
required this.isReadOnly});
@override
Size get preferredSize => const Size.fromHeight(kToolbarHeight);
//final Size prefferedSize=;
OutlineInputBorder border = OutlineInputBorder(
borderRadius: BorderRadius.circular(7),
borderSide: BorderSide(color: Colors.grey, width: 1));
@override
Widget build(BuildContext context) {
Size screenSize = MediaQuery.of(context).size;
return Container(
height: kAppBarHeight,
decoration: const BoxDecoration(
gradient: LinearGradient(
colors: backgroundGradient,
begin: Alignment.centerLeft,
end: Alignment.centerRight)),
child: Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [
hasBackButton
? IconButton(
onPressed: () {
Navigator.pop(context);
},
icon: const Icon(Icons.arrow_back))
: Container(),
SizedBox(
width: screenSize.width * 0.7,
height: 45,
child: Container(
decoration: BoxDecoration(boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.2),
blurRadius: 8,
spreadRadius: 1,
offset: const Offset(0, 5))
]),
child: TextField(
onSubmitted: (String query) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ResulstScreen(query: query)));
},
readOnly: isReadOnly,
onTap: () {
if (isReadOnly) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const SearchScreen()));
}
},
decoration: InputDecoration(
hintText: "Search for something in amazon",
fillColor: Colors.white,
filled: true,
border: border,
focusedBorder: border,
),
),
),
),
IconButton(onPressed: () {}, icon: const Icon(Icons.mic_none_outlined))
]),
);
}
}
| 0 |
mirrored_repositories/flutter_amazon_clone/lib | mirrored_repositories/flutter_amazon_clone/lib/widgets/simple_product_widget.dart | import 'package:amazon_clone/models/product_model.dart';
import 'package:amazon_clone/screens/product_screen.dart';
import 'package:flutter/material.dart';
class SimpleProductWidget extends StatelessWidget {
final ProductModel productModel;
const SimpleProductWidget({super.key, required this.productModel});
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ProductScreen(product: productModel)));
},
child: AspectRatio(
aspectRatio: 1 / 1,
child: Container(
//height: 20,
color: Colors.white,
child: Padding(
padding: const EdgeInsets.all(10),
child: Image.network(
productModel.url,
fit: BoxFit.cover,
),
),
),
),
);
}
}
| 0 |
mirrored_repositories/flutter_amazon_clone/lib | mirrored_repositories/flutter_amazon_clone/lib/widgets/products_showcase_list_view.dart | import 'package:amazon_clone/utils/color_theme.dart';
import 'package:flutter/material.dart';
class ProductsShowcaseListView extends StatelessWidget {
final String title;
final List<Widget> children;
const ProductsShowcaseListView(
{super.key, required this.title, required this.children});
@override
Widget build(BuildContext context) {
Size screenSize = MediaQuery.of(context).size;
double height = screenSize.height /4;
double width = screenSize.width;
double titleHeight = 25;
return Container(
margin: const EdgeInsets.all(8),
padding: const EdgeInsets.all(8),
height: height,
width: width,
color: Colors.white,
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
SizedBox(
height: titleHeight,
child: Row(
children: [
Text(
title,
style: const TextStyle(
fontSize: 17,
fontWeight: FontWeight.bold,
),
),
const Padding(
padding: EdgeInsets.only(left: 14),
child: Text(
"Show more",
style: TextStyle(color: activeCyanColor),
),
)
],
),
),
SizedBox(
height: height - (titleHeight + 26),
width: screenSize.width,
child: ListView(
scrollDirection: Axis.horizontal,
children: children,
),
)
],
),
);
}
}
| 0 |
mirrored_repositories/flutter_amazon_clone/lib | mirrored_repositories/flutter_amazon_clone/lib/widgets/cart_item_widget.dart | import 'package:amazon_clone/models/product_model.dart';
import 'package:amazon_clone/resources/cloudfirestore_methods.dart';
import 'package:amazon_clone/screens/product_screen.dart';
import 'package:amazon_clone/utils/color_theme.dart';
import 'package:amazon_clone/utils/utils.dart';
import 'package:amazon_clone/widgets/custom_simple_round_button.dart';
import 'package:amazon_clone/widgets/custom_square_button.dart';
import 'package:amazon_clone/widgets/product_information_widget.dart';
import 'package:flutter/material.dart';
class CartItemWidget extends StatelessWidget {
final ProductModel product;
const CartItemWidget({super.key, required this.product});
@override
Widget build(BuildContext context) {
Size screenSize = MediaQuery.of(context).size;
return Container(
padding: const EdgeInsets.all(20),
height: screenSize.height / 1.5,
width: screenSize.width,
decoration: const BoxDecoration(
color: backgroundColor,
border: Border(bottom: BorderSide(color: Colors.grey, width: 1))),
child: Column(
children: [
Expanded(
flex: 3,
child: GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ProductScreen(product: product),
),
);
},
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
SizedBox(
width: screenSize.width / 3,
child: Align(
alignment: Alignment.topCenter,
child: Center(
child: Image.network(product.url),
)),
),
SizedBox(
width: screenSize.width / 15,
),
ProductInformationWidget(
productName: product.productName,
cost: product.cost,
sellerName: product.sellerName)
],
),
)),
Expanded(
flex: 1,
child: Row(
children: [
CustomSquareButton(
onPressed: () {},
color: backgroundColor,
dimention: 40,
child: const Icon(Icons.remove)),
CustomSquareButton(
onPressed: () {},
color: Colors.white,
dimention: 40,
child: const Text(
"0",
style: TextStyle(color: activeCyanColor),
)),
CustomSquareButton(
child: const Icon(Icons.add),
onPressed: () async {
await CloudFirestoreClass().addProductToCart(
productModel: ProductModel(
url: product.url,
productName: product.productName,
cost: product.cost,
discount: product.discount,
uid: Utils().getUid(),
sellerName: product.sellerName,
sellerUid: product.sellerUid,
rating: product.rating,
noOfRating: product.noOfRating));
},
color: backgroundColor,
dimention: 40)
],
)),
Expanded(
flex: 1,
child: Padding(
padding: const EdgeInsets.only(top: 9),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Row(
children: [
CustomSimpleRoundButton(
onPressed: () async {
CloudFirestoreClass()
.deleteProductFromCart(uid: product.uid);
},
text: "Delete"),
const SizedBox(
width: 7,
),
CustomSimpleRoundButton(
onPressed: () {}, text: "Save for later"),
],
),
const Padding(
padding: EdgeInsets.only(top: 3),
child: Align(
alignment: Alignment.centerLeft,
child: Text(
"See more like this",
style:
TextStyle(color: activeCyanColor, fontSize: 15),
),
),
)
],
),
))
],
),
);
}
}
| 0 |
mirrored_repositories/flutter_amazon_clone/lib | mirrored_repositories/flutter_amazon_clone/lib/widgets/review_widget.dart | import 'package:amazon_clone/models/review_model.dart';
import 'package:amazon_clone/utils/constants.dart';
import 'package:amazon_clone/widgets/rating_star_widget.dart';
import 'package:flutter/material.dart';
class ReviewWidget extends StatelessWidget {
final ReviewModel review;
const ReviewWidget({super.key, required this.review});
@override
Widget build(BuildContext context) {
Size screenSize = MediaQuery.of(context).size;
return Padding(
padding: const EdgeInsets.symmetric(vertical: 15.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
review.senderName,
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 6.0),
child: Row(
children: [
Padding(
padding: const EdgeInsets.only(right: 10.0),
child: SizedBox(
width: screenSize.width / 4,
child: FittedBox(
child: RatingStar(rating: review.rating),
),
),
),
Text(
keyOfRating[review.rating - 1],
style: TextStyle(fontWeight: FontWeight.bold),
),
],
),
),
Text(
review.description,
maxLines: 3,
overflow: TextOverflow.ellipsis,
)
],
),
);
}
}
| 0 |
mirrored_repositories/flutter_amazon_clone/lib | mirrored_repositories/flutter_amazon_clone/lib/widgets/user_details_bar.dart | import 'package:amazon_clone/models/user_details_model.dart';
import 'package:amazon_clone/providers/user_details_provider.dart';
import 'package:amazon_clone/utils/color_theme.dart';
import 'package:amazon_clone/utils/constants.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class UserDetailsBar extends StatelessWidget {
final double offset;
const UserDetailsBar({
super.key,
required this.offset,
});
@override
Widget build(BuildContext context) {
Size screenSize = MediaQuery.of(context).size;
UserDetailsModel? userDetailss = Provider.of<UserDetailsProvider>(
context,
listen: true,
).userDetails!;
//print(userDetailss.name);
return Positioned(
top: -offset / 3,
child: Container(
height: kAppBarHeight / 2,
width: screenSize.width,
decoration: const BoxDecoration(
gradient: LinearGradient(
colors: lightBackgroundaGradient,
begin: Alignment.centerLeft,
end: Alignment.centerRight)),
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 3,
horizontal: 20,
),
child: Row(
children: [
Padding(
padding: const EdgeInsets.only(right: 8.0),
child: Icon(
Icons.location_on_outlined,
color: Colors.grey[900],
),
),
SizedBox(
width: screenSize.width * 0.7,
child: Text(
"Deliver to ${userDetailss.name} - ${userDetailss.address}",
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(color: Colors.grey[900]),
),
)
],
),
),
),
);
}
}
| 0 |
mirrored_repositories/flutter_amazon_clone/lib | mirrored_repositories/flutter_amazon_clone/lib/widgets/loading_widget.dart | import 'package:flutter/material.dart';
class LoadingWidget extends StatelessWidget {
const LoadingWidget({super.key});
@override
Widget build(BuildContext context) {
return const Center(
child: CircularProgressIndicator(
color: Colors.orange,
),
);
}
}
| 0 |
mirrored_repositories/flutter_amazon_clone/lib | mirrored_repositories/flutter_amazon_clone/lib/widgets/results_widget.dart | import 'package:amazon_clone/models/product_model.dart';
import 'package:amazon_clone/screens/product_screen.dart';
import 'package:amazon_clone/utils/color_theme.dart';
import 'package:amazon_clone/widgets/cost_widget.dart';
import 'package:amazon_clone/widgets/rating_star_widget.dart';
import 'package:flutter/material.dart';
class ResultWidget extends StatelessWidget {
final ProductModel product;
const ResultWidget({super.key, required this.product});
@override
Widget build(BuildContext context) {
Size screenSize = MediaQuery.of(context).size;
return GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ProductScreen(product: product)));
},
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 10.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
width: screenSize.width / 3, child: Image.network(product.url)),
Padding(
padding: const EdgeInsets.only(bottom: 5.0),
child: Text(
product.productName,
maxLines: 3,
overflow: TextOverflow.ellipsis,
),
),
Padding(
padding: const EdgeInsets.only(bottom: 5.0),
child: Row(
children: [
SizedBox(
width: screenSize.width / 5,
child:
FittedBox(child: RatingStar(rating: product.rating))),
Padding(
padding: const EdgeInsets.only(left: 10.0),
child: Text(
product.noOfRating.toString(),
style: const TextStyle(color: activeCyanColor),
),
)
],
),
),
SizedBox(
height: 20,
child: FittedBox(
child: CostWidget(
color: Color.fromARGB(255, 92, 9, 3),
cost: product.cost)))
],
),
),
);
}
}
| 0 |
mirrored_repositories/flutter_amazon_clone/lib | mirrored_repositories/flutter_amazon_clone/lib/widgets/product_information_widget.dart | import 'package:amazon_clone/utils/color_theme.dart';
import 'package:amazon_clone/widgets/cost_widget.dart';
import 'package:flutter/material.dart';
class ProductInformationWidget extends StatelessWidget {
final String productName;
final double cost;
final String sellerName;
const ProductInformationWidget(
{super.key,
required this.productName,
required this.cost,
required this.sellerName});
@override
Widget build(BuildContext context) {
SizedBox spaceThing = const SizedBox(
height: 7,
);
Size screenSize = MediaQuery.of(context).size;
return SizedBox(
width: screenSize.width / 2,
child: Column(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Align(
alignment: Alignment.centerLeft,
child: Text(
productName,
maxLines: 2,
style: const TextStyle(
fontWeight: FontWeight.w500,
fontSize: 16,
letterSpacing: 0.9,
overflow: TextOverflow.ellipsis),
),
),
spaceThing,
Align(
alignment: Alignment.centerLeft,
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 7),
child: CostWidget(color: Colors.black, cost: cost),
),
),
spaceThing,
Align(
alignment: Alignment.centerLeft,
child: RichText(
text: TextSpan(children: [
TextSpan(
text: "Sold by ",
style: TextStyle(color: Colors.grey[700], fontSize: 14)),
TextSpan(
text: sellerName,
style: TextStyle(color: activeCyanColor, fontSize: 14))
])),
)
],
),
);
}
}
| 0 |
mirrored_repositories/flutter_amazon_clone/lib | mirrored_repositories/flutter_amazon_clone/lib/widgets/banner_add_widget.dart | import 'package:amazon_clone/utils/color_theme.dart';
import 'package:amazon_clone/utils/constants.dart';
import 'package:flutter/material.dart';
class BannerAddWidget extends StatefulWidget {
const BannerAddWidget({super.key});
@override
State<BannerAddWidget> createState() => _BannerAddWidgetState();
}
class _BannerAddWidgetState extends State<BannerAddWidget> {
int currentAd = 0;
@override
Widget build(BuildContext context) {
Size scrrenSize = MediaQuery.of(context).size;
double smallHeight = scrrenSize.width / 5;
return GestureDetector(
onHorizontalDragEnd: (_) {
if (currentAd == largeAds.length - 1) {
currentAd = -1;
}
setState(() {
currentAd++;
});
},
child: Column(
children: [
//image with gradient
Stack(
children: [
Image.network(
largeAds[currentAd],
width: double.infinity,
),
Positioned(
bottom: 0,
child: Container(
width: scrrenSize.width,
height: 200,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.bottomCenter,
end: Alignment.topCenter,
colors: [
backgroundColor,
backgroundColor.withOpacity(0)
])),
),
)
],
),
Container(
width: scrrenSize.width,
height: smallHeight,
decoration: BoxDecoration(
border: Border.all(width: 0, color: backgroundColor),
color: backgroundColor,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
getSmallAdsFromIndex(0, smallHeight),
getSmallAdsFromIndex(1, smallHeight),
getSmallAdsFromIndex(2, smallHeight),
getSmallAdsFromIndex(3, smallHeight),
],
),
)
],
),
);
}
Widget getSmallAdsFromIndex(int index, double height) {
return Container(
height: height,
width: height,
decoration: ShapeDecoration(
color: Colors.white,
shadows: [
BoxShadow(
color: Colors.black.withOpacity(0.2),
blurRadius: 5,
spreadRadius: 1)
],
shape: RoundedRectangleBorder(
borderRadius: BorderRadiusDirectional.circular(20))),
child: Center(
child: Column(
children: [
Image.network(smallAds[index]),
const SizedBox(
height: 5,
),
Text(adItemNames[index])
],
)));
}
}
| 0 |
mirrored_repositories/flutter_amazon_clone/lib | mirrored_repositories/flutter_amazon_clone/lib/widgets/review_dialog.dart | import 'package:amazon_clone/models/review_model.dart';
import 'package:amazon_clone/providers/user_details_provider.dart';
import 'package:amazon_clone/resources/cloudfirestore_methods.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:rating_dialog/rating_dialog.dart';
class RiviewDialog extends StatelessWidget {
final String productUid;
const RiviewDialog({super.key, required this.productUid});
@override
Widget build(BuildContext context) {
return RatingDialog(
initialRating: 0.0,
// your app's name?
title: const Text(
'Type a review for this product',
textAlign: TextAlign.center,
style: TextStyle(
//color: Colors.grey,
fontSize: 25,
fontWeight: FontWeight.bold,
),
),
submitButtonText: 'Submit',
submitButtonTextStyle: TextStyle(color: Colors.orange),
commentHint: 'Type here',
onCancelled: () => print('cancelled'),
onSubmitted: (RatingDialogResponse res) async {
CloudFirestoreClass().uploadReviewToDatabase(
productUid: productUid,
model: ReviewModel(
senderName:
Provider.of<UserDetailsProvider>(context, listen: false)
.userDetails!
.name,
description: res.comment,
rating: res.rating.toInt()));
print(res.comment);
print(res.rating);
},
);
}
}
| 0 |
mirrored_repositories/flutter_amazon_clone/lib | mirrored_repositories/flutter_amazon_clone/lib/widgets/custom_square_button.dart | import 'package:flutter/material.dart';
class CustomSquareButton extends StatelessWidget {
final Widget child;
final Color color;
final VoidCallback onPressed;
final double dimention;
const CustomSquareButton(
{super.key,
required this.child,
required this.onPressed,
required this.color,
required this.dimention});
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: onPressed,
child: Container(
height: dimention,
width: dimention,
decoration: ShapeDecoration(
color: color,
shape: RoundedRectangleBorder(
side: const BorderSide(color: Colors.grey, width: 1),
borderRadius: BorderRadius.circular(2))),
child: Center(child: child),
),
);
}
}
| 0 |
mirrored_repositories/flutter_amazon_clone/lib | mirrored_repositories/flutter_amazon_clone/lib/widgets/rating_star_widget.dart | import 'package:flutter/material.dart';
class RatingStar extends StatelessWidget {
final int rating;
const RatingStar({super.key, required this.rating});
@override
Widget build(BuildContext context) {
List<Widget> children = [];
for (int i = 0; i < 5; i++) {
children.add(i < rating
? const Icon(
Icons.star,
color: Colors.orange,
)
: const Icon(
Icons.star_border,
color: Colors.orange,
));
print(rating);
}
return Row(
children: children,
);
}
}
| 0 |