repo_id
stringlengths 21
168
| file_path
stringlengths 36
210
| content
stringlengths 1
9.98M
| __index_level_0__
int64 0
0
|
|---|---|---|---|
mirrored_repositories/RestaurantAppUIKit/lib
|
mirrored_repositories/RestaurantAppUIKit/lib/screens/profile.dart
|
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:restaurant_ui_kit/providers/app_provider.dart';
import 'package:restaurant_ui_kit/screens/splash.dart';
import 'package:restaurant_ui_kit/util/const.dart';
class Profile extends StatefulWidget {
@override
_ProfileState createState() => _ProfileState();
}
class _ProfileState extends State<Profile> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Padding(
padding: EdgeInsets.fromLTRB(10.0,0,10.0,0),
child: ListView(
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Padding(
padding: EdgeInsets.only(left: 10.0, right: 10.0),
child: Image.asset(
"assets/cm4.jpeg",
fit: BoxFit.cover,
width: 100.0,
height: 100.0,
),
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
"Jane Doe",
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.bold,
),
),
],
),
SizedBox(height: 5.0),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
"jane@doefamily.com",
style: TextStyle(
fontSize: 14.0,
fontWeight: FontWeight.bold,
),
),
],
),
SizedBox(height: 20.0),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
InkWell(
onTap: (){
Navigator.of(context).push(
MaterialPageRoute(
builder: (BuildContext context){
return SplashScreen();
},
),
);
},
child: Text("Logout",
style: TextStyle(
fontSize: 13.0,
fontWeight: FontWeight.w400,
color: Theme.of(context).accentColor,
),
overflow: TextOverflow.ellipsis,
),
),
],
),
],
),
flex: 3,
),
],
),
Divider(),
Container(height: 15.0),
Padding(
padding: EdgeInsets.all(5.0),
child: Text(
"Account Information".toUpperCase(),
style: TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.bold,
),
),
),
ListTile(
title: Text(
"Full Name",
style: TextStyle(
fontSize: 17,
fontWeight: FontWeight.w700,
),
),
subtitle: Text(
"Jane Mary Doe",
),
trailing: IconButton(
icon: Icon(
Icons.edit,
size: 20.0,
),
onPressed: (){
},
tooltip: "Edit",
),
),
ListTile(
title: Text(
"Email",
style: TextStyle(
fontSize: 17,
fontWeight: FontWeight.w700,
),
),
subtitle: Text(
"jane@doefamily.com",
),
),
ListTile(
title: Text(
"Phone",
style: TextStyle(
fontSize: 17,
fontWeight: FontWeight.w700,
),
),
subtitle: Text(
"+1 816-926-6241",
),
),
ListTile(
title: Text(
"Address",
style: TextStyle(
fontSize: 17,
fontWeight: FontWeight.w700,
),
),
subtitle: Text(
"1278 Loving Acres RoadKansas City, MO 64110",
),
),
ListTile(
title: Text(
"Gender",
style: TextStyle(
fontSize: 17,
fontWeight: FontWeight.w700,
),
),
subtitle: Text(
"Female",
),
),
ListTile(
title: Text(
"Date of Birth",
style: TextStyle(
fontSize: 17,
fontWeight: FontWeight.w700,
),
),
subtitle: Text(
"April 9, 1995",
),
),
MediaQuery.of(context).platformBrightness == Brightness.dark
? SizedBox()
: ListTile(
title: Text(
"Dark Theme",
style: TextStyle(
fontSize: 17,
fontWeight: FontWeight.w700,
),
),
trailing: Switch(
value: Provider.of<AppProvider>(context).theme == Constants.lightTheme
? false
: true,
onChanged: (v) async{
if (v) {
Provider.of<AppProvider>(context, listen: false)
.setTheme(Constants.darkTheme, "dark");
} else {
Provider.of<AppProvider>(context, listen: false)
.setTheme(Constants.lightTheme, "light");
}
},
activeColor: Theme.of(context).accentColor,
),
),
],
),
),
);
}
}
| 0
|
mirrored_repositories/RestaurantAppUIKit/lib
|
mirrored_repositories/RestaurantAppUIKit/lib/screens/checkout.dart
|
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:restaurant_ui_kit/util/foods.dart';
import 'package:restaurant_ui_kit/widgets/cart_item.dart';
class Checkout extends StatefulWidget {
@override
_CheckoutState createState() => _CheckoutState();
}
class _CheckoutState extends State<Checkout> {
final TextEditingController _couponlControl = new TextEditingController();
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
automaticallyImplyLeading: false,
title: Text(
"Checkout",
style: TextStyle(
fontSize: 23,
fontWeight: FontWeight.w800,
),
),
elevation: 0.0,
actions: <Widget>[
IconButton(
tooltip: "Back",
icon: Icon(
Icons.clear,
color: Theme.of(context).accentColor,
),
onPressed: ()=>Navigator.pop(context),
),
],
),
body: Padding(
padding: EdgeInsets.fromLTRB(10.0,0,10.0,130),
child: ListView(
children: <Widget>[
SizedBox(height: 10.0),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
"Shipping Address",
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.w400,
),
),
IconButton(
onPressed: (){},
icon: Icon(
Icons.edit,
),
),
],
),
SizedBox(height: 10.0),
ListTile(
title: Text(
"John Doe",
style: TextStyle(
// fontSize: 15,
fontWeight: FontWeight.w900,
),
),
subtitle: Text("1278 Loving Acres Road Kansas City, MO 64110"),
),
SizedBox(height: 10.0),
Text(
"Payment Method",
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.w400,
),
),
Card(
elevation: 4.0,
child: ListTile(
title: Text("John Doe"),
subtitle: Text(
"5506 7744 8610 9638",
style: TextStyle(
fontSize: 13,
fontWeight: FontWeight.w900,
),
),
leading: Icon(
FontAwesomeIcons.creditCard,
size: 50.0,
color: Theme.of(context).accentColor,
),
trailing: IconButton(
onPressed: (){},
icon: Icon(
Icons.keyboard_arrow_down,
),
),
),
),
SizedBox(height: 20.0),
Text(
"Items",
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.w400,
),
),
ListView.builder(
primary: false,
shrinkWrap: true,
itemCount: foods == null ? 0 :foods.length,
itemBuilder: (BuildContext context, int index) {
// Food food = Food.fromJson(foods[index]);
Map food = foods[index];
// print(foods);
// print(foods.length);
return CartItem(
img: food['img'],
isFav: false,
name: food['name'],
rating: 5.0,
raters: 23,
);
},
),
],
),
),
bottomSheet: Card(
elevation: 4.0,
child: Container(
child: ListView(
physics: NeverScrollableScrollPhysics(),
children: <Widget>[
Padding(
padding: EdgeInsets.all(10),
child: Container(
decoration: BoxDecoration(
color: Colors.grey[200],
borderRadius: BorderRadius.all(
Radius.circular(5.0),
),
),
child: TextField(
style: TextStyle(
fontSize: 15.0,
color: Colors.black,
),
decoration: InputDecoration(
contentPadding: EdgeInsets.all(10.0),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(5.0),
borderSide: BorderSide(color: Colors.grey[200],),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.grey[200],),
borderRadius: BorderRadius.circular(5.0),
),
hintText: "Coupon Code",
prefixIcon: Icon(
Icons.redeem,
color: Theme.of(context).accentColor,
),
hintStyle: TextStyle(
fontSize: 15.0,
color: Colors.black,
),
),
maxLines: 1,
controller: _couponlControl,
),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Padding(
padding: EdgeInsets.fromLTRB(10,5,5,5),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
"Total",
style: TextStyle(
fontSize: 13,
fontWeight: FontWeight.w400,
),
),
Text(
r"$ 212",
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.w900,
color: Theme.of(context).accentColor,
),
),
Text(
"Delivery charges included",
style: TextStyle(
fontSize: 11,
fontWeight: FontWeight.w400,
),
),
],
),
),
Container(
padding: EdgeInsets.fromLTRB(5,5,10,5),
width: 150.0,
height: 50.0,
child: FlatButton(
color: Theme.of(context).accentColor,
child: Text(
"Place Order".toUpperCase(),
style: TextStyle(
color: Colors.white,
),
),
onPressed: (){},
),
),
],
),
],
),
height: 130,
),
),
);
}
}
| 0
|
mirrored_repositories/RestaurantAppUIKit/lib
|
mirrored_repositories/RestaurantAppUIKit/lib/screens/cart.dart
|
import 'package:flutter/material.dart';
import 'package:restaurant_ui_kit/screens/checkout.dart';
import 'package:restaurant_ui_kit/util/foods.dart';
import 'package:restaurant_ui_kit/widgets/cart_item.dart';
class CartScreen extends StatefulWidget {
@override
_CartScreenState createState() => _CartScreenState();
}
class _CartScreenState extends State<CartScreen> with AutomaticKeepAliveClientMixin<CartScreen >{
@override
Widget build(BuildContext context) {
super.build(context);
return Scaffold(
body: Padding(
padding: EdgeInsets.fromLTRB(10.0,0,10.0,0),
child: ListView.builder(
itemCount: foods == null ? 0 :foods.length,
itemBuilder: (BuildContext context, int index) {
// Food food = Food.fromJson(foods[index]);
Map food = foods[index];
// print(foods);
// print(foods.length);
return CartItem(
img: food['img'],
isFav: false,
name: food['name'],
rating: 5.0,
raters: 23,
);
},
),
),
floatingActionButton: FloatingActionButton(
tooltip: "Checkout",
onPressed: (){
Navigator.of(context).push(
MaterialPageRoute(
builder: (BuildContext context){
return Checkout();
},
),
);
},
child: Icon(
Icons.arrow_forward,
),
heroTag: Object(),
),
);
}
@override
bool get wantKeepAlive => true;
}
| 0
|
mirrored_repositories/RestaurantAppUIKit/lib
|
mirrored_repositories/RestaurantAppUIKit/lib/screens/notifications.dart
|
import 'package:flutter/material.dart';
class Notifications extends StatefulWidget {
@override
_NotificationsState createState() => _NotificationsState();
}
class _NotificationsState extends State<Notifications> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
automaticallyImplyLeading: false,
leading: IconButton(
icon: Icon(
Icons.keyboard_backspace,
),
onPressed: ()=>Navigator.pop(context),
),
centerTitle: true,
title: Text(
"Notifications",
),
elevation: 0.0,
),
body: Padding(
padding: EdgeInsets.fromLTRB(10.0,0,10.0,0),
child: ListView(
children: <Widget>[
ListTile(
leading: CircleAvatar(
backgroundColor: Colors.green,
child: Icon(
Icons.check,
color: Colors.white,
),
),
title: Text("Your Order has been delivered successfully"),
onTap: (){},
),
Divider(),
ListTile(
leading: CircleAvatar(
backgroundColor: Colors.red,
child: Icon(
Icons.clear,
color: Colors.white,
),
),
title: Text("Error processing your order"),
onTap: (){},
),
Divider(),
ListTile(
leading: CircleAvatar(
backgroundColor: Colors.orange,
child: Icon(
Icons.directions_bike,
color: Colors.white,
),
),
title: Text("You order has been processed and will be delivered shortly"),
onTap: (){},
),
Divider(),
ListTile(
leading: CircleAvatar(
backgroundColor: Colors.blue,
child: Icon(
Icons.email,
color: Colors.white,
),
),
title: Text("Please Verify your email address"),
onTap: (){},
),
],
),
),
);
}
}
| 0
|
mirrored_repositories/RestaurantAppUIKit/lib
|
mirrored_repositories/RestaurantAppUIKit/lib/screens/walkthrough.dart
|
import 'package:flutter/material.dart';
import 'package:introduction_screen/introduction_screen.dart';
import 'package:restaurant_ui_kit/screens/join.dart';
class Walkthrough extends StatefulWidget {
@override
_WalkthroughState createState() => _WalkthroughState();
}
class _WalkthroughState extends State<Walkthrough> {
List pageInfos = [
{
"title": "Fresh Food",
"body": "Vivamus magna justo, lacinia eget consectetur sed, convallis at tellus."
" Vestibulum ac diam sit amet quam vehicula elementum sed sit amet "
"dui. Nulla porttitor accumsan tincidunt.",
"img": "assets/on1.png",
},
{
"title": "Fast Delivery",
"body": "Vivamus magna justo, lacinia eget consectetur sed, convallis at tellus."
" Vestibulum ac diam sit amet quam vehicula elementum sed sit amet "
"dui. Nulla porttitor accumsan tincidunt.",
"img": "assets/on2.png",
},
{
"title": "Easy Payment",
"body": "Vivamus magna justo, lacinia eget consectetur sed, convallis at tellus."
" Vestibulum ac diam sit amet quam vehicula elementum sed sit amet "
"dui. Nulla porttitor accumsan tincidunt.",
"img": "assets/on3.png",
},
];
@override
Widget build(BuildContext context) {
List<PageViewModel> pages = [
for(int i = 0; i<pageInfos.length; i++)
_buildPageModel(pageInfos[i])
];
return WillPopScope(
onWillPop: ()=>Future.value(false),
child: Scaffold(
backgroundColor: Theme.of(context).primaryColor,
body: Padding(
padding: EdgeInsets.all(10.0),
child: IntroductionScreen(
pages: pages,
onDone: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (BuildContext context){
return JoinApp();
},
),
);
},
onSkip: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (BuildContext context){
return JoinApp();
},
),
);
},
showSkipButton: true,
skip: Text("Skip"),
next: Text(
"Next",
style: TextStyle(
fontWeight: FontWeight.w800,
color: Theme.of(context).accentColor,
),
),
done: Text(
"Done",
style: TextStyle(
fontWeight: FontWeight.w800,
color: Theme.of(context).accentColor,
),
),
),
),
),
);
}
_buildPageModel(Map item){
return PageViewModel(
title: item['title'],
body: item['body'],
image: Image.asset(
item['img'],
height: 185.0,
),
decoration: PageDecoration(
titleTextStyle: TextStyle(
fontSize: 28.0,
fontWeight: FontWeight.w600,
color: Theme.of(context).accentColor,
),
bodyTextStyle: TextStyle(fontSize: 15.0),
// dotsDecorator: DotsDecorator(
// activeColor: Theme.of(context).accentColor,
// activeSize: Size.fromRadius(8),
// ),
pageColor: Theme.of(context).primaryColor,
),
);
}
}
| 0
|
mirrored_repositories/RestaurantAppUIKit/lib
|
mirrored_repositories/RestaurantAppUIKit/lib/screens/join.dart
|
import 'package:flutter/material.dart';
import 'package:restaurant_ui_kit/screens/login.dart';
import 'package:restaurant_ui_kit/screens/register.dart';
import 'package:flutter/services.dart';
class JoinApp extends StatefulWidget {
@override
_JoinAppState createState() => _JoinAppState();
}
class _JoinAppState extends State<JoinApp> with SingleTickerProviderStateMixin{
TabController _tabController;
@override
void initState() {
super.initState();
_tabController = TabController(vsync: this, initialIndex: 1, length: 2);
SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
automaticallyImplyLeading: false,
leading: IconButton(
icon: Icon(
Icons.keyboard_backspace,
),
onPressed: ()=>Navigator.pop(context),
),
bottom: TabBar(
controller: _tabController,
indicatorColor: Theme.of(context).accentColor,
labelColor: Theme.of(context).accentColor,
unselectedLabelColor: Colors.grey,
labelStyle: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.w800,
),
unselectedLabelStyle: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.w800,
),
tabs: <Widget>[
Tab(
text: "Login",
),
Tab(
text: "Register",
),
],
),
),
body: TabBarView(
controller: _tabController,
children: <Widget>[
LoginScreen(),
RegisterScreen(),
],
),
);
}
}
| 0
|
mirrored_repositories/RestaurantAppUIKit/lib
|
mirrored_repositories/RestaurantAppUIKit/lib/screens/splash.dart
|
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:restaurant_ui_kit/screens/walkthrough.dart';
import 'package:restaurant_ui_kit/util/const.dart';
class SplashScreen extends StatefulWidget {
@override
_SplashScreenState createState() => _SplashScreenState();
}
class _SplashScreenState extends State<SplashScreen> {
startTimeout() {
return Timer(Duration(seconds: 2), changeScreen);
}
changeScreen() async{
Navigator.of(context).push(
MaterialPageRoute(
builder: (BuildContext context){
return Walkthrough();
},
),
);
}
@override
void initState() {
super.initState();
SystemChrome.setEnabledSystemUIOverlays([]);
startTimeout();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Theme.of(context).primaryColor,
body: Container(
margin: EdgeInsets.only(left: 40.0, right: 40.0),
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Icon(
Icons.fastfood,
size: 150.0,
color: Theme.of(context).accentColor,
),
SizedBox(width: 40.0),
Container(
alignment: Alignment.center,
margin: EdgeInsets.only(
top: 15.0,
),
child: Text(
"${Constants.appName}",
style: TextStyle(
fontSize: 25.0,
fontWeight: FontWeight.w700,
color: Theme.of(context).accentColor,
),
),
),
],
),
),
),
);
}
}
| 0
|
mirrored_repositories/RestaurantAppUIKit/lib
|
mirrored_repositories/RestaurantAppUIKit/lib/screens/search.dart
|
import 'package:flutter/material.dart';
import 'package:restaurant_ui_kit/util/const.dart';
import 'package:restaurant_ui_kit/util/foods.dart';
import 'package:restaurant_ui_kit/widgets/smooth_star_rating.dart';
class SearchScreen extends StatefulWidget {
@override
_SearchScreenState createState() => _SearchScreenState();
}
class _SearchScreenState extends State<SearchScreen> with AutomaticKeepAliveClientMixin<SearchScreen>{
final TextEditingController _searchControl = new TextEditingController();
@override
Widget build(BuildContext context) {
super.build(context);
return Padding(
padding: EdgeInsets.fromLTRB(10.0,0,10.0,0),
child: ListView(
children: <Widget>[
SizedBox(height: 10.0),
Card(
elevation: 6.0,
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(
Radius.circular(5.0),
),
),
child: TextField(
style: TextStyle(
fontSize: 15.0,
color: Colors.black,
),
decoration: InputDecoration(
contentPadding: EdgeInsets.all(10.0),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(5.0),
borderSide: BorderSide(color: Colors.white,),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.white,),
borderRadius: BorderRadius.circular(5.0),
),
hintText: "Search..",
suffixIcon: Icon(
Icons.search,
color: Colors.black,
),
hintStyle: TextStyle(
fontSize: 15.0,
color: Colors.black,
),
),
maxLines: 1,
controller: _searchControl,
),
),
),
SizedBox(height: 5.0),
Padding(
padding: EdgeInsets.all(20.0),
child: Text(
"History",
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.w400,
),
),
),
ListView.builder(
shrinkWrap: true,
primary: false,
physics: NeverScrollableScrollPhysics(),
itemCount: foods == null ? 0 :foods.length,
itemBuilder: (BuildContext context, int index) {
Map food = foods[index];
return ListTile(
title: Text(
"${food['name']}",
style: TextStyle(
// fontSize: 15,
fontWeight: FontWeight.w900,
),
),
leading: CircleAvatar(
radius: 25.0,
backgroundImage: AssetImage(
"${food['img']}",
),
),
trailing: Text(r"$10"),
subtitle: Row(
children: <Widget>[
SmoothStarRating(
starCount: 1,
color: Constants.ratingBG,
allowHalfRating: true,
rating: 5.0,
size: 12.0,
),
SizedBox(width: 6.0),
Text(
"5.0 (23 Reviews)",
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w300,
),
),
],
),
onTap: (){},
);
},
),
SizedBox(height: 30),
],
),
);
}
@override
bool get wantKeepAlive => true;
}
| 0
|
mirrored_repositories/RestaurantAppUIKit/lib
|
mirrored_repositories/RestaurantAppUIKit/lib/screens/login.dart
|
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:restaurant_ui_kit/screens/main_screen.dart';
class LoginScreen extends StatefulWidget {
@override
_LoginScreenState createState() => _LoginScreenState();
}
class _LoginScreenState extends State<LoginScreen> {
final TextEditingController _usernameControl = new TextEditingController();
final TextEditingController _passwordControl = new TextEditingController();
@override
Widget build(BuildContext context) {
return Padding(
padding: EdgeInsets.fromLTRB(20.0,0,20,0),
child: ListView(
shrinkWrap: true,
children: <Widget>[
SizedBox(height: 10.0),
Container(
alignment: Alignment.center,
margin: EdgeInsets.only(
top: 25.0,
),
child: Text(
"Log in to your account",
style: TextStyle(
fontSize: 18.0,
fontWeight: FontWeight.w700,
color: Theme.of(context).accentColor,
),
),
),
SizedBox(height: 30.0),
Card(
elevation: 3.0,
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(
Radius.circular(5.0),
),
),
child: TextField(
style: TextStyle(
fontSize: 15.0,
color: Colors.black,
),
decoration: InputDecoration(
contentPadding: EdgeInsets.all(10.0),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(5.0),
borderSide: BorderSide(color: Colors.white,),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.white,),
borderRadius: BorderRadius.circular(5.0),
),
hintText: "Username",
hintStyle: TextStyle(
fontSize: 15.0,
color: Colors.black,
),
prefixIcon: Icon(
Icons.perm_identity,
color: Colors.black,
),
),
maxLines: 1,
controller: _usernameControl,
),
),
),
SizedBox(height: 10.0),
Card(
elevation: 3.0,
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(
Radius.circular(5.0),
),
),
child: TextField(
style: TextStyle(
fontSize: 15.0,
color: Colors.black,
),
decoration: InputDecoration(
contentPadding: EdgeInsets.all(10.0),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(5.0),
borderSide: BorderSide(color: Colors.white,),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.white,),
borderRadius: BorderRadius.circular(5.0),
),
hintText: "Password",
prefixIcon: Icon(
Icons.lock_outline,
color: Colors.black,
),
hintStyle: TextStyle(
fontSize: 15.0,
color: Colors.black,
),
),
obscureText: true,
maxLines: 1,
controller: _passwordControl,
),
),
),
SizedBox(height: 10.0),
Container(
alignment: Alignment.centerRight,
child: FlatButton(
child: Text(
"Forgot Password?",
style: TextStyle(
fontSize: 14.0,
fontWeight: FontWeight.w500,
color: Theme.of(context).accentColor,
),
),
onPressed: (){},
),
),
SizedBox(height: 30.0),
Container(
height: 50.0,
child: RaisedButton(
child: Text(
"LOGIN".toUpperCase(),
style: TextStyle(
color: Colors.white,
),
),
onPressed: (){
Navigator.of(context).push(
MaterialPageRoute(
builder: (BuildContext context){
return MainScreen();
},
),
);
},
color: Theme.of(context).accentColor,
),
),
SizedBox(height: 10.0),
Divider(color: Theme.of(context).accentColor,),
SizedBox(height: 10.0),
Center(
child: Container(
width: MediaQuery.of(context).size.width/2,
child: Row(
children: <Widget>[
RawMaterialButton(
onPressed: (){},
fillColor: Colors.blue[800],
shape: CircleBorder(),
elevation: 4.0,
child: Padding(
padding: EdgeInsets.all(15),
child: Icon(
FontAwesomeIcons.facebookF,
color: Colors.white,
// size: 24.0,
),
),
),
RawMaterialButton(
onPressed: (){},
fillColor: Colors.white,
shape: CircleBorder(),
elevation: 4.0,
child: Padding(
padding: EdgeInsets.all(15),
child: Icon(
FontAwesomeIcons.google,
color: Colors.blue[800],
// size: 24.0,
),
),
),
],
),
),
),
SizedBox(height: 20.0),
],
),
);
}
}
| 0
|
mirrored_repositories/RestaurantAppUIKit/lib
|
mirrored_repositories/RestaurantAppUIKit/lib/screens/categories_screen.dart
|
import 'package:flutter/material.dart';
import 'package:restaurant_ui_kit/screens/notifications.dart';
import 'package:restaurant_ui_kit/util/categories.dart';
import 'package:restaurant_ui_kit/util/foods.dart';
import 'package:restaurant_ui_kit/widgets/badge.dart';
import 'package:restaurant_ui_kit/widgets/grid_product.dart';
import 'package:restaurant_ui_kit/widgets/home_category.dart';
class CategoriesScreen extends StatefulWidget {
@override
_CategoriesScreenState createState() => _CategoriesScreenState();
}
class _CategoriesScreenState extends State<CategoriesScreen> {
String catie = "Drinks";
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
automaticallyImplyLeading: false,
leading: IconButton(
icon: Icon(
Icons.keyboard_backspace,
),
onPressed: ()=>Navigator.pop(context),
),
centerTitle: true,
title: Text(
"Categories",
),
elevation: 0.0,
actions: <Widget>[
IconButton(
icon: IconBadge(
icon: Icons.notifications,
size: 22.0,
),
onPressed: (){
Navigator.of(context).push(
MaterialPageRoute(
builder: (BuildContext context){
return Notifications();
},
),
);
},
),
],
),
body: Padding(
padding: EdgeInsets.fromLTRB(10.0,0,10.0,0),
child: ListView(
children: <Widget>[
SizedBox(height: 10.0),
Container(
height: 65.0,
child: ListView.builder(
scrollDirection: Axis.horizontal,
shrinkWrap: true,
itemCount: categories == null?0:categories.length,
itemBuilder: (BuildContext context, int index) {
Map cat = categories[index];
return HomeCategory(
icon: cat['icon'],
title: cat['name'],
items: cat['items'].toString(),
isHome: false,
tap: (){
setState((){catie = "${cat['name']}";});
},
);
},
),
),
SizedBox(height: 20.0),
Text(
"$catie",
style: TextStyle(
fontSize: 23,
fontWeight: FontWeight.w800,
),
),
Divider(),
SizedBox(height: 10.0),
GridView.builder(
shrinkWrap: true,
primary: false,
physics: NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
childAspectRatio: MediaQuery.of(context).size.width /
(MediaQuery.of(context).size.height / 1.25),
),
itemCount: foods == null ? 0 :foods.length,
itemBuilder: (BuildContext context, int index) {
Map food = foods[index];
return GridProduct(
img: food['img'],
isFav: false,
name: food['name'],
rating: 5.0,
raters: 23,
);
},
),
],
),
),
);
}
}
| 0
|
mirrored_repositories/RestaurantAppUIKit/lib
|
mirrored_repositories/RestaurantAppUIKit/lib/screens/favorite_screen.dart
|
import 'package:flutter/material.dart';
import 'package:restaurant_ui_kit/util/foods.dart';
import 'package:restaurant_ui_kit/widgets/grid_product.dart';
class FavoriteScreen extends StatefulWidget {
@override
_FavoriteScreenState createState() => _FavoriteScreenState();
}
class _FavoriteScreenState extends State<FavoriteScreen> with AutomaticKeepAliveClientMixin<FavoriteScreen>{
@override
Widget build(BuildContext context) {
super.build(context);
return Scaffold(
body: Padding(
padding: EdgeInsets.fromLTRB(10.0,0,10.0,0),
child: ListView(
children: <Widget>[
SizedBox(height: 10.0),
Text(
"My Favorite Items",
style: TextStyle(
fontSize: 23,
fontWeight: FontWeight.w800,
),
),
SizedBox(height: 10.0),
GridView.builder(
shrinkWrap: true,
primary: false,
physics: NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
childAspectRatio: MediaQuery.of(context).size.width /
(MediaQuery.of(context).size.height / 1.25),
),
itemCount: foods == null ? 0 :foods.length,
itemBuilder: (BuildContext context, int index) {
// Food food = Food.fromJson(foods[index]);
Map food = foods[index];
// print(foods);
// print(foods.length);
return GridProduct(
img: food['img'],
isFav: true,
name: food['name'],
rating: 5.0,
raters: 23,
);
},
),
SizedBox(height: 30),
],
),
),
);
}
@override
bool get wantKeepAlive => true;
}
| 0
|
mirrored_repositories/RestaurantAppUIKit/lib
|
mirrored_repositories/RestaurantAppUIKit/lib/screens/dishes.dart
|
import 'package:flutter/material.dart';
import 'package:restaurant_ui_kit/screens/notifications.dart';
import 'package:restaurant_ui_kit/util/foods.dart';
import 'package:restaurant_ui_kit/widgets/badge.dart';
import 'package:restaurant_ui_kit/widgets/grid_product.dart';
class DishesScreen extends StatefulWidget {
@override
_DishesScreenState createState() => _DishesScreenState();
}
class _DishesScreenState extends State<DishesScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
automaticallyImplyLeading: false,
leading: IconButton(
icon: Icon(
Icons.keyboard_backspace,
),
onPressed: ()=>Navigator.pop(context),
),
centerTitle: true,
title: Text(
"Dishes",
),
elevation: 0.0,
actions: <Widget>[
IconButton(
icon: IconBadge(
icon: Icons.notifications,
size: 22.0,
),
onPressed: (){
Navigator.of(context).push(
MaterialPageRoute(
builder: (BuildContext context){
return Notifications();
},
),
);
},
),
],
),
body: Padding(
padding: EdgeInsets.fromLTRB(10.0,0,10.0,0),
child: ListView(
children: <Widget>[
Text(
"Chinese",
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w800,
),
maxLines: 2,
),
Divider(),
GridView.builder(
shrinkWrap: true,
primary: false,
physics: NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
childAspectRatio: MediaQuery.of(context).size.width /
(MediaQuery.of(context).size.height / 1.25),
),
itemCount: 4,
itemBuilder: (BuildContext context, int index) {
Map food = foods[index];
return GridProduct(
img: food['img'],
isFav: false,
name: food['name'],
rating: 5.0,
raters: 23,
);
},
),
SizedBox(height: 20.0),
Text(
"Italian",
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w800,
),
maxLines: 2,
),
Divider(),
GridView.builder(
shrinkWrap: true,
primary: false,
physics: NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
childAspectRatio: MediaQuery.of(context).size.width /
(MediaQuery.of(context).size.height / 1.25),
),
itemCount: 4,
itemBuilder: (BuildContext context, int index) {
Map food = foods[index];
return GridProduct(
img: food['img'],
isFav: false,
name: food['name'],
rating: 5.0,
raters: 23,
);
},
),
SizedBox(height: 20.0),
Text(
"African",
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w800,
),
maxLines: 2,
),
Divider(),
GridView.builder(
shrinkWrap: true,
primary: false,
physics: NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
childAspectRatio: MediaQuery.of(context).size.width /
(MediaQuery.of(context).size.height / 1.25),
),
itemCount: 4,
itemBuilder: (BuildContext context, int index) {
Map food = foods[index];
return GridProduct(
img: food['img'],
isFav: false,
name: food['name'],
rating: 5.0,
raters: 23,
);
},
),
],
),
),
);
}
}
| 0
|
mirrored_repositories/RestaurantAppUIKit/lib
|
mirrored_repositories/RestaurantAppUIKit/lib/screens/home.dart
|
import 'package:flutter/material.dart';
import 'package:restaurant_ui_kit/screens/dishes.dart';
import 'package:restaurant_ui_kit/widgets/grid_product.dart';
import 'package:restaurant_ui_kit/widgets/home_category.dart';
import 'package:restaurant_ui_kit/widgets/slider_item.dart';
import 'package:restaurant_ui_kit/util/foods.dart';
import 'package:restaurant_ui_kit/util/categories.dart';
import 'package:carousel_slider/carousel_slider.dart';
class Home extends StatefulWidget {
@override
_HomeState createState() => _HomeState();
}
class _HomeState extends State<Home> with AutomaticKeepAliveClientMixin<Home>{
List<T> map<T>(List list, Function handler) {
List<T> result = [];
for (var i = 0; i < list.length; i++) {
result.add(handler(i, list[i]));
}
return result;
}
int _current = 0;
@override
Widget build(BuildContext context) {
super.build(context);
return Scaffold(
body: Padding(
padding: EdgeInsets.fromLTRB(10.0,0,10.0,0),
child: ListView(
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
"Dishes",
style: TextStyle(
fontSize: 23,
fontWeight: FontWeight.w800,
),
),
FlatButton(
child: Text(
"View More",
style: TextStyle(
// fontSize: 22,
// fontWeight: FontWeight.w800,
color: Theme.of(context).accentColor,
),
),
onPressed: (){
Navigator.of(context).push(
MaterialPageRoute(
builder: (BuildContext context){
return DishesScreen();
},
),
);
},
),
],
),
SizedBox(height: 10.0),
//Slider Here
CarouselSlider(
height: MediaQuery.of(context).size.height/2.4,
items: map<Widget>(
foods,
(index, i){
Map food = foods[index];
return SliderItem(
img: food['img'],
isFav: false,
name: food['name'],
rating: 5.0,
raters: 23,
);
},
).toList(),
autoPlay: true,
// enlargeCenterPage: true,
viewportFraction: 1.0,
// aspectRatio: 2.0,
onPageChanged: (index) {
setState(() {
_current = index;
});
},
),
SizedBox(height: 20.0),
Text(
"Food Categories",
style: TextStyle(
fontSize: 23,
fontWeight: FontWeight.w800,
),
),
SizedBox(height: 10.0),
Container(
height: 65.0,
child: ListView.builder(
scrollDirection: Axis.horizontal,
shrinkWrap: true,
itemCount: categories == null?0:categories.length,
itemBuilder: (BuildContext context, int index) {
Map cat = categories[index];
return HomeCategory(
icon: cat['icon'],
title: cat['name'],
items: cat['items'].toString(),
isHome: true,
);
},
),
),
SizedBox(height: 20.0),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
"Popular Items",
style: TextStyle(
fontSize: 23,
fontWeight: FontWeight.w800,
),
),
FlatButton(
child: Text(
"View More",
style: TextStyle(
// fontSize: 22,
// fontWeight: FontWeight.w800,
color: Theme.of(context).accentColor,
),
),
onPressed: (){},
),
],
),
SizedBox(height: 10.0),
GridView.builder(
shrinkWrap: true,
primary: false,
physics: NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
childAspectRatio: MediaQuery.of(context).size.width /
(MediaQuery.of(context).size.height / 1.25),
),
itemCount: foods == null ? 0 :foods.length,
itemBuilder: (BuildContext context, int index) {
// Food food = Food.fromJson(foods[index]);
Map food = foods[index];
// print(foods);
// print(foods.length);
return GridProduct(
img: food['img'],
isFav: false,
name: food['name'],
rating: 5.0,
raters: 23,
);
},
),
SizedBox(height: 30),
],
),
),
);
}
@override
bool get wantKeepAlive => true;
}
| 0
|
mirrored_repositories/RestaurantAppUIKit/lib
|
mirrored_repositories/RestaurantAppUIKit/lib/providers/app_provider.dart
|
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:restaurant_ui_kit/util/const.dart';
import 'package:shared_preferences/shared_preferences.dart';
class AppProvider extends ChangeNotifier{
AppProvider(){
checkTheme();
}
ThemeData theme = Constants.lightTheme;
Key key = UniqueKey();
GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
void setKey(value) {
key = value;
notifyListeners();
}
void setNavigatorKey(value) {
navigatorKey = value;
notifyListeners();
}
void setTheme(value, c) {
theme = value;
SharedPreferences.getInstance().then((prefs){
prefs.setString("theme", c).then((val){
SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values);
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
statusBarColor: c == "dark" ? Constants.darkPrimary : Constants.lightPrimary,
statusBarIconBrightness: c == "dark" ? Brightness.light:Brightness.dark,
));
});
});
notifyListeners();
}
ThemeData getTheme(value) {
return theme;
}
Future<ThemeData> checkTheme() async{
SharedPreferences prefs = await SharedPreferences.getInstance();
ThemeData t;
String r = prefs.getString("theme") == null ? "light" : prefs.getString(
"theme");
if(r == "light"){
t = Constants.lightTheme;
setTheme(Constants.lightTheme, "light");
}else{
t = Constants.darkTheme;
setTheme(Constants.darkTheme, "dark");
}
return t;
}
}
| 0
|
mirrored_repositories/falldribbox
|
mirrored_repositories/falldribbox/lib/main.dart
|
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'app/routes/app_pages.dart';
void main() {
runApp(
GetMaterialApp(
debugShowCheckedModeBanner: false,
title: "Application",
initialRoute: Routes.LOGIN,
getPages: AppPages.routes,
),
);
}
| 0
|
mirrored_repositories/falldribbox/lib/app
|
mirrored_repositories/falldribbox/lib/app/routes/app_routes.dart
|
part of 'app_pages.dart';
// DO NOT EDIT. This is code generated via package:get_cli/get_cli.dart
abstract class Routes {
Routes._();
static const HOME = _Paths.HOME;
static const LOGIN = _Paths.LOGIN;
}
abstract class _Paths {
_Paths._();
static const HOME = '/home';
static const LOGIN = '/login';
}
| 0
|
mirrored_repositories/falldribbox/lib/app
|
mirrored_repositories/falldribbox/lib/app/routes/app_pages.dart
|
import 'package:get/get.dart';
import '../modules/home/bindings/home_binding.dart';
import '../modules/home/views/home_view.dart';
import '../modules/login/bindings/login_binding.dart';
import '../modules/login/views/login_view.dart';
part 'app_routes.dart';
class AppPages {
AppPages._();
static const INITIAL = Routes.HOME;
static final routes = [
GetPage(
name: _Paths.HOME,
page: () => const HomeView(),
binding: HomeBinding(),
),
GetPage(
name: _Paths.LOGIN,
page: () => const LoginView(),
binding: LoginBinding(),
),
];
}
| 0
|
mirrored_repositories/falldribbox/lib/app/modules/login
|
mirrored_repositories/falldribbox/lib/app/modules/login/views/login_view.dart
|
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../controllers/login_controller.dart';
class LoginView extends GetView<LoginController> {
const LoginView({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: false,
backgroundColor: Colors.white,
body: Stack(
children: [
// BACKGROUND
SizedBox(
width: Get.width,
child: Image.asset(
'assets/images/bg.png',
fit: BoxFit.cover,
),
),
// IMAGE
Padding(
padding: const EdgeInsets.all(30.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(
height: 100,
),
SizedBox(
width: 200,
height: 200,
child: Image.asset(
'assets/images/pic-1.png',
fit: BoxFit.contain,
)),
const SizedBox(
height: 30,
),
const Text(
'Welcome to',
style: TextStyle(fontSize: 20, fontWeight: FontWeight.w300),
),
const SizedBox(
height: 10,
),
const Text(
'Dribbox',
style: TextStyle(
fontSize: 60,
fontWeight: FontWeight.bold,
color: Color(0XFF22215B)),
),
const SizedBox(
height: 10,
),
const SizedBox(
width: 223,
child: Text(
'Best cloud storage platform for all business and individuals to manage there data',
style: TextStyle(fontSize: 14, color: Color(0xff7B7F9E)),
),
),
const SizedBox(
height: 20,
),
GestureDetector(
onTap: () {},
child: const Text(
'Join For Free.',
style: TextStyle(color: Color(0xff7B7F9E), fontSize: 14),
)),
const SizedBox(
height: 20,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
ElevatedButton(
style: ElevatedButton.styleFrom(
fixedSize: const Size(150, 50),
backgroundColor: const Color(0XFFEEF7FE),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15))),
onPressed: () {},
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
// crossAxisAlignment: CrossAxisAlignment.center,
children: [
Image.asset(
'assets/icons/finger.png',
width: 19,
),
const SizedBox(
width: 10,
),
const Text(
'Smart Id',
style:
TextStyle(fontSize: 18, color: Colors.black),
),
],
)),
// const SizedBox(
// width: 20,
// ),
ElevatedButton(
style: ElevatedButton.styleFrom(
fixedSize: const Size(150, 50),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15))),
onPressed: () {},
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text(
'Sign In',
style:
TextStyle(fontSize: 18, color: Colors.white),
),
const SizedBox(
width: 10,
),
Image.asset('assets/icons/arrow-right.png'),
],
)),
],
),
const SizedBox(height: 20),
Expanded(
child: Column(
children: [
Center(
child: TextButton(
child: const Text(
'Use Social Login',
style: TextStyle(
fontSize: 16,
color: Colors.black,
fontWeight: FontWeight.w400),
),
onPressed: () {},
)),
const SizedBox(height: 34),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
GestureDetector(
child: Image.asset(
'assets/icons/Instagram.png',
width: 17,
height: 17,
),
),
const SizedBox(
width: 60,
),
GestureDetector(
onTap: () {},
child: Image.asset(
'assets/icons/Facebook.png',
width: 17,
height: 17,
),
),
const SizedBox(
width: 60,
),
Material(
color: Colors.transparent,
child: InkWell(
onTap: () {},
child: Image.asset(
'assets/icons/Twitter.png',
width: 17,
height: 17,
),
),
),
],
),
const SizedBox(
height: 21,
),
TextButton(
child: const Text(
'Create an account',
style: TextStyle(
fontSize: 18,
color: Colors.black,
fontWeight: FontWeight.w400),
),
onPressed: () {},
),
],
),
),
],
),
)
],
),
);
}
}
| 0
|
mirrored_repositories/falldribbox/lib/app/modules/login
|
mirrored_repositories/falldribbox/lib/app/modules/login/controllers/login_controller.dart
|
import 'package:get/get.dart';
class LoginController extends GetxController {
//TODO: Implement LoginController
final count = 0.obs;
@override
void onInit() {
super.onInit();
}
@override
void onReady() {
super.onReady();
}
@override
void onClose() {
super.onClose();
}
void increment() => count.value++;
}
| 0
|
mirrored_repositories/falldribbox/lib/app/modules/login
|
mirrored_repositories/falldribbox/lib/app/modules/login/bindings/login_binding.dart
|
import 'package:get/get.dart';
import '../controllers/login_controller.dart';
class LoginBinding extends Bindings {
@override
void dependencies() {
Get.lazyPut<LoginController>(
() => LoginController(),
);
}
}
| 0
|
mirrored_repositories/falldribbox/lib/app/modules/home
|
mirrored_repositories/falldribbox/lib/app/modules/home/views/home_view.dart
|
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../controllers/home_controller.dart';
class HomeView extends GetView<HomeController> {
const HomeView({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return const Scaffold(
body: Center(
child: Text(
'HomeView is working',
style: TextStyle(fontSize: 20),
),
),
);
}
}
| 0
|
mirrored_repositories/falldribbox/lib/app/modules/home
|
mirrored_repositories/falldribbox/lib/app/modules/home/controllers/home_controller.dart
|
import 'package:get/get.dart';
class HomeController extends GetxController {
//TODO: Implement HomeController
final count = 0.obs;
@override
void onInit() {
super.onInit();
}
@override
void onReady() {
super.onReady();
}
@override
void onClose() {
super.onClose();
}
void increment() => count.value++;
}
| 0
|
mirrored_repositories/falldribbox/lib/app/modules/home
|
mirrored_repositories/falldribbox/lib/app/modules/home/bindings/home_binding.dart
|
import 'package:get/get.dart';
import '../controllers/home_controller.dart';
class HomeBinding extends Bindings {
@override
void dependencies() {
Get.lazyPut<HomeController>(
() => HomeController(),
);
}
}
| 0
|
mirrored_repositories/falldribbox
|
mirrored_repositories/falldribbox/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';
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/Hostel-Manager
|
mirrored_repositories/Hostel-Manager/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) {
throw UnsupportedError(
'DefaultFirebaseOptions have not been configured for web - '
'you can reconfigure this by running the FlutterFire CLI again.',
);
}
switch (defaultTargetPlatform) {
case TargetPlatform.android:
return android;
case TargetPlatform.iOS:
throw UnsupportedError(
'DefaultFirebaseOptions have not been configured for ios - '
'you can reconfigure this by running the FlutterFire CLI again.',
);
case TargetPlatform.macOS:
throw UnsupportedError(
'DefaultFirebaseOptions have not been configured for macos - '
'you can reconfigure this by running the FlutterFire CLI again.',
);
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 android = FirebaseOptions(
apiKey: 'AIzaSyBUW30KcgMfmfMr7z6irFLCz9G9Dcv9Amw',
appId: '1:721358647180:android:8bba875f4f26ea2a8470a9',
messagingSenderId: '721358647180',
projectId: 'hostel-management-app-4ae0f',
storageBucket: 'hostel-management-app-4ae0f.appspot.com',
);
}
| 0
|
mirrored_repositories/Hostel-Manager
|
mirrored_repositories/Hostel-Manager/lib/main.dart
|
import 'package:flutter/material.dart';
import 'package:hostel_management_app/fetures/profile/controllers/account_setup_screen_controller.dart';
import 'package:hostel_management_app/fetures/authentication/controllers/authentication_repository.dart';
import 'package:hostel_management_app/fetures/authentication/controllers/forgotpassword_controller.dart';
import 'package:hostel_management_app/fetures/authentication/controllers/login_controller.dart';
import 'package:hostel_management_app/fetures/authentication/controllers/register_controller.dart';
import 'package:hostel_management_app/fetures/bookings/controllers/bookings_controller.dart';
import 'package:hostel_management_app/fetures/bookings/controllers/bookings_repository.dart';
import 'package:hostel_management_app/fetures/dashboard/controllers/dashboard_controller.dart';
import 'package:hostel_management_app/fetures/authentication/controllers/onboarding/onboaring_controller.dart';
import 'package:hostel_management_app/fetures/home/controllers/bottomnavbar_controller.dart';
import 'package:hostel_management_app/fetures/residents/controllers/residents_controller.dart';
import 'package:hostel_management_app/fetures/rooms/controllers/rooms_controller.dart';
import 'package:hostel_management_app/fetures/profile/controllers/user_controller.dart';
import 'package:hostel_management_app/fetures/authentication/screens/splash_screen/splash_screen.dart';
import 'package:provider/provider.dart';
import 'package:firebase_core/firebase_core.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
options: const FirebaseOptions(
apiKey: "AIzaSyBUW30KcgMfmfMr7z6irFLCz9G9Dcv9Amw",
appId: "1:721358647180:android:8bba875f4f26ea2a8470a9",
messagingSenderId: '',
projectId: "hostel-management-app-4ae0f",
storageBucket: "hostel-management-app-4ae0f.appspot.com"),
);
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MultiProvider(
providers: [
ChangeNotifierProvider(
create: (context) => OnBoardingController(),
),
ChangeNotifierProvider(
create: (context) => NavBarController(),
),
ChangeNotifierProvider(
create: (context) => ResidentsController(),
),
ChangeNotifierProvider(
create: (context) => AccountSetUpScreenController(),
),
ChangeNotifierProvider(
create: (context) => SignInController(),
),
ChangeNotifierProvider(
create: (context) => AuthenticationRepository(),
),
ChangeNotifierProvider(
create: (context) => LoginController(),
),
ChangeNotifierProvider(
create: (context) => ForgotPasswordController(),
),
ChangeNotifierProvider(
create: (context) => DashboardController(),
),
ChangeNotifierProvider(
create: (context) => UserController(),
),
ChangeNotifierProvider(
create: (context) => RoomsController(),
),
ChangeNotifierProvider(
create: (context) => BookingRepository(),
),
ChangeNotifierProvider(
create: (context) => BookingsController(),
)
],
child: const MaterialApp(
debugShowCheckedModeBanner: false,
home: SplashScreen(),
),
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/commens
|
mirrored_repositories/Hostel-Manager/lib/commens/widgets/shimmer_loader.dart
|
import 'package:flutter/material.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
import 'package:shimmer/shimmer.dart';
class ShimmerEffect extends StatelessWidget {
const ShimmerEffect(
{super.key,
required this.height,
required this.width,
required this.radius,
this.colorr});
final double height, width, radius;
final Color? colorr;
@override
Widget build(BuildContext context) {
return Shimmer.fromColors(
baseColor: Colors.grey[500]!,
highlightColor: Colors.grey[200]!,
child: Container(
height: height,
width: width,
decoration: BoxDecoration(
color: colorr ?? ColorConstants.primaryWhiteColor,
borderRadius: BorderRadius.circular(radius)),
),
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/commens
|
mirrored_repositories/Hostel-Manager/lib/commens/widgets/room_card.dart
|
import 'package:flutter/material.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
import 'package:hostel_management_app/utils/text_style_constatnts.dart';
import 'package:fluentui_system_icons/fluentui_system_icons.dart';
class RoomsCard extends StatelessWidget {
const RoomsCard({
super.key,
required this.roomNumber,
required this.vaccentBedNumber,
this.onTap,
});
final String roomNumber;
final String vaccentBedNumber;
final void Function()? onTap;
@override
Widget build(BuildContext context) {
return InkWell(
onTap: onTap,
child: Stack(
children: [
Positioned(
bottom: 0,
left: 0,
child: Container(
height: 80,
width: 83,
// padding: EdgeInsets.symmetric(vertical: 2),
decoration: BoxDecoration(
color: ColorConstants.secondaryWhiteColor,
borderRadius: BorderRadius.circular(8),
boxShadow: [
BoxShadow(
color: ColorConstants.primaryBlackColor.withOpacity(0.2),
blurRadius: 2,
offset: const Offset(0, 4),
)
],
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const SizedBox(
height: 17,
),
Text(
"Room No",
style: TextStyleConstants.ownerRoomsText2,
),
Text(
roomNumber,
style: TextStyleConstants.ownerRoomNumber,
)
],
),
),
),
Positioned(
top: 5,
left: 30,
child: Hero(
tag: roomNumber,
child: CircleAvatar(
radius: 15,
backgroundColor: ColorConstants.secondaryColor4,
child: Icon(
FluentIcons.conference_room_48_regular,
color: ColorConstants.primaryBlackColor,
size: 27,
),
),
),
),
Visibility(
visible: vaccentBedNumber == "0" ? false : true,
child: Positioned(
top: 0,
left: 70,
child: CircleAvatar(
radius: 15,
backgroundColor: ColorConstants.primaryColor,
child: Text(
vaccentBedNumber,
style: TextStyleConstants.ownerRoomsCircleAvtarText,
),
),
),
),
],
),
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/commens
|
mirrored_repositories/Hostel-Manager/lib/commens/widgets/login_button.dart
|
import 'package:flutter/material.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
import 'package:hostel_management_app/utils/text_style_constatnts.dart';
class LoginButton extends StatelessWidget {
const LoginButton({super.key, this.onTap, required this.buttonName});
final void Function()? onTap;
final String buttonName;
@override
Widget build(BuildContext context) {
return InkWell(
onTap: onTap,
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: ColorConstants.primaryColor,
),
height: 45,
width: double.infinity,
child: Center(
child: Text(
buttonName,
style: TextStyleConstants.buttonText,
),
),
),
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/commens
|
mirrored_repositories/Hostel-Manager/lib/commens/widgets/custom_dropdown_button.dart
|
import 'package:dropdown_button2/dropdown_button2.dart';
import 'package:flutter/material.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
class CustomDropdownButton extends StatelessWidget {
const CustomDropdownButton({
super.key,
required this.selectedValue,
required this.items,
required this.onChanged,
required this.height,
required this.width,
});
final String selectedValue;
final List<String> items;
final Function(String) onChanged;
final double height;
final double width;
@override
Widget build(BuildContext context) {
return DropdownButtonHideUnderline(
child: DropdownButton2<String>(
isExpanded: true,
hint: Row(
children: [
Expanded(
child: Text(
selectedValue,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
color: ColorConstants.primaryWhiteColor,
),
overflow: TextOverflow.ellipsis,
),
),
],
),
items: items
.map((String item) => DropdownMenuItem<String>(
value: item,
child: Text(
item,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
color: ColorConstants.primaryWhiteColor,
),
overflow: TextOverflow.ellipsis,
),
))
.toList(),
value: selectedValue,
onChanged: (value) {
onChanged(value.toString());
},
buttonStyleData: ButtonStyleData(
height: height,
width: width,
padding: const EdgeInsets.only(left: 14, right: 14),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: ColorConstants.secondaryColor2,
),
),
iconStyleData: IconStyleData(
icon: const Icon(
Icons.keyboard_arrow_down,
),
iconSize: 25,
iconEnabledColor: ColorConstants.primaryWhiteColor,
iconDisabledColor: Colors.grey,
),
dropdownStyleData: DropdownStyleData(
maxHeight: 200,
width: width,
offset: const Offset(0, 10),
decoration: BoxDecoration(
borderRadius:
const BorderRadius.vertical(bottom: Radius.circular(10)),
color: ColorConstants.secondaryColor2,
),
scrollbarTheme: ScrollbarThemeData(
radius: const Radius.circular(40),
thickness: MaterialStateProperty.all(6),
thumbVisibility: MaterialStateProperty.all(true),
),
elevation: 0),
menuItemStyleData: const MenuItemStyleData(
height: 40,
padding: EdgeInsets.only(left: 14, right: 14),
),
),
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/commens
|
mirrored_repositories/Hostel-Manager/lib/commens/widgets/form_field.dart
|
import 'package:flutter/material.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
class CustomFormField extends StatelessWidget {
const CustomFormField(
{super.key,
required this.controller,
this.hitText,
this.hideText = false,
this.suffixIcon,
this.validator,
this.labelText});
final TextEditingController controller;
final String? hitText;
final String? labelText;
final bool hideText;
final Widget? suffixIcon;
final String? Function(String?)? validator;
@override
Widget build(BuildContext context) {
return TextFormField(
controller: controller,
validator: validator,
decoration: InputDecoration(
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(15),
borderSide: BorderSide(width: 2, color: ColorConstants.colorGrey),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(15),
borderSide:
BorderSide(width: 2, color: ColorConstants.primaryColor),
),
hintText: hitText,
label: Text(labelText ?? ""),
hintStyle: TextStyle(
fontSize: 15,
color: ColorConstants.colorGrey,
fontWeight: FontWeight.w500),
suffixIcon: suffixIcon),
obscureText: hideText,
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/commens
|
mirrored_repositories/Hostel-Manager/lib/commens/functions/loading_controller.dart
|
import 'package:flutter/material.dart';
import 'package:hostel_management_app/utils/animation_constants.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
import 'package:lottie/lottie.dart';
class FullScreenLoader {
static Future openLoadinDialog(BuildContext context) {
return showDialog(
context: context,
barrierDismissible: false,
builder: (context1) => Container(
height: double.infinity,
width: double.infinity,
color: ColorConstants.primaryWhiteColor,
padding: const EdgeInsets.all(40),
child: Center(
child: LottieBuilder.asset(
AnimationConstants.loading,
width: double.infinity,
height: double.infinity,
),
),
),
);
}
static stopLoadin(BuildContext context) {
Navigator.of(context).pop();
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/commens
|
mirrored_repositories/Hostel-Manager/lib/commens/functions/connection_checher.dart
|
import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:flutter/services.dart';
class ConnectionChecker {
final Connectivity _connectivity = Connectivity();
Future<bool> isConnected() async {
try {
final result = await _connectivity.checkConnectivity();
if (result == ConnectivityResult.none) {
return false;
}
return true;
} on PlatformException catch (_) {
return false;
}
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/commens
|
mirrored_repositories/Hostel-Manager/lib/commens/functions/make_phone_call.dart
|
// ignore_for_file: use_build_context_synchronously
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
makePhoneCall(String phoneNumber, BuildContext context) async {
String url = 'tel:$phoneNumber';
if (await canLaunchUrl(Uri.parse(url))) {
await launchUrl(Uri.parse(url));
} else {
// Handle the case where the user can't launch the phone call.
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text('Error'),
content: const Text('Could not launch the phone call.'),
actions: <Widget>[
TextButton(
onPressed: () {
Navigator.pop(context);
},
child: const Text('OK'),
),
],
);
},
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/bookings
|
mirrored_repositories/Hostel-Manager/lib/fetures/bookings/controllers/bookings_controller.dart
|
// ignore_for_file: use_build_context_synchronously
import 'package:flutter/material.dart';
import 'package:hostel_management_app/fetures/bookings/controllers/bookings_repository.dart';
import 'package:hostel_management_app/commens/functions/connection_checher.dart';
import 'package:hostel_management_app/fetures/rooms/controllers/rooms_repository.dart';
import 'package:hostel_management_app/fetures/profile/controllers/user_repository.dart';
import 'package:hostel_management_app/fetures/bookings/models/booking_model.dart';
import 'package:hostel_management_app/fetures/profile/models/owner_model.dart';
import 'package:hostel_management_app/fetures/rooms/models/room_model.dart';
import 'package:intl/intl.dart';
class BookingsController with ChangeNotifier {
GlobalKey<FormState> formKey = GlobalKey<FormState>();
final roomNoController = TextEditingController();
final nameController = TextEditingController();
final phoneNoController = TextEditingController();
final dateController = TextEditingController();
final BookingRepository bookingController = BookingRepository();
final ConnectionChecker connectionController = ConnectionChecker();
final RoomsRepository roomController = RoomsRepository();
final UserRepository ownerRepository = UserRepository();
List<BookingsModel> allBookings = [];
List<BookingsModel> bookings = [];
List<BookingsModel> bookingsWithinThisWeek = [];
List<RoomModel> vacantRooms = [];
bool isAdvancePaid = true;
bool isBookingsLoading = false;
bool isRoomsLoading = false;
DateTime checkInDate = DateTime.now();
bool isEditing = false;
String? updatingBookingId;
//----------------------------------------------------------------------------- fetching vacant rooms
fetchVacantRooms() async {
try {
isRoomsLoading = true;
List<RoomModel> allRooms = await roomController.fetchData();
// Filter out vacant rooms (Vacancy > 0)
vacantRooms = allRooms.where((room) => room.vacancy > 0).toList();
vacantRooms.sort((a, b) => a.roomNo.compareTo(b.roomNo));
} catch (e) {
rethrow; // or return an empty list or handle the error appropriately
} finally {
isRoomsLoading = false;
notifyListeners();
}
}
//--------------------------------------------------------------------------- fetch Bookings data
fetchBookingsData() async {
try {
isBookingsLoading = true;
allBookings = await bookingController.fetchData();
allBookings.sort((a, b) => a.checkIn.compareTo(b.checkIn));
bookings = allBookings;
await filterBooking();
isBookingsLoading = false;
notifyListeners();
} catch (e) {
rethrow; // or return an empty list or handle the error appropriately
} finally {
isBookingsLoading = false;
notifyListeners();
}
}
//----------------------------------------------------------------------------Filtering bookings
filterBooking() async {
// Clear the list before adding new data
bookingsWithinThisWeek.clear();
// Get the current date and time
final currentDate = DateTime.now();
// Filter bookings with check-in date within this week
final thisWeekBookings = allBookings.where((booking) {
final daysDifference = booking.checkIn.difference(currentDate).inDays;
return daysDifference < 20;
}).toList();
// Move the filtered bookings to another list
bookingsWithinThisWeek.addAll(thisWeekBookings);
}
//----------------------------------------------------------------------------add booking
addBooking({
required BuildContext context,
required int roomNo,
required String roomId,
}) async {
try {
final isConnected = await connectionController.isConnected();
if (!isConnected) {
ScaffoldMessenger.of(context)
.showSnackBar(const SnackBar(content: Text("Network error")));
}
final booking = BookingsModel(
roomNO: roomNo,
name: nameController.text,
phoneNo: phoneNoController.text,
checkIn: checkInDate,
advancePaid: isAdvancePaid,
roomId: roomId);
await bookingController.addBooking(booking);
// fetching current vaccancy from roomdata to update vacancy
final RoomModel? room =
await roomController.fetchSingleRoom(roomId: roomId);
final currentRoomVacancy = room!.vacancy;
final int roomVacancy = currentRoomVacancy - 1;
notifyListeners();
final Map<String, dynamic> json = {"Vacancy": roomVacancy};
await roomController.updateSingleField(json: json, roomId: roomId);
final OwnerModel? owner = await ownerRepository.fetchOwnerRecords();
final currentHostelVacancy = owner!.noOfVacancy;
final int hostelVacancy = currentHostelVacancy - 1;
notifyListeners();
final Map<String, dynamic> data = {'NoOfVacancy': hostelVacancy};
await ownerRepository.accountSetup(data);
fetchBookingsData();
fetchVacantRooms();
roomNoController.clear();
nameController.clear();
dateController.clear();
phoneNoController.clear();
notifyListeners();
Navigator.pop(context);
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text("Booking Added Successfull")));
} catch (e) {
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: Text("Error: $e")));
}
}
//--------------------------------------------------------------------------- delete booking
deleteBooking({
required BuildContext context,
required String bookingId,
required String roomId,
}) async {
try {
final isConnected = await connectionController.isConnected();
if (!isConnected) {
ScaffoldMessenger.of(context)
.showSnackBar(const SnackBar(content: Text("Network error")));
}
await bookingController.deleteBooking(bookingId);
// fetching current vaccancy from roomdata to update vacancy
final RoomModel? room =
await roomController.fetchSingleRoom(roomId: roomId);
final currentVacancy = room!.vacancy;
final int vacancy = currentVacancy + 1;
notifyListeners();
final Map<String, dynamic> json = {"Vacancy": vacancy};
await roomController.updateSingleField(json: json, roomId: roomId);
final OwnerModel? owner = await ownerRepository.fetchOwnerRecords();
final currentHostelVacancy = owner!.noOfVacancy;
final int hostelVacancy = currentHostelVacancy + 1;
notifyListeners();
final Map<String, dynamic> data = {'NoOfVacancy': hostelVacancy};
await ownerRepository.accountSetup(data);
fetchBookingsData();
fetchVacantRooms();
Navigator.pop(context);
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text("Record Deleted Successfully")));
} catch (e) {
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: Text("Error: $e")));
}
}
//--------------------------------------------------------------------------- Update Booking
updateBooking(BuildContext context) async {
try {
final Map<String, dynamic> json = {
"Name": nameController.text,
"phoneNo": phoneNoController.text.trim(),
"CheckIn": checkInDate,
"AdvancePaid": isAdvancePaid
};
await bookingController.updadatSingleField(
json: json, bookingId: updatingBookingId!);
fetchBookingsData();
fetchVacantRooms();
onCanacel();
Navigator.pop(context);
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text("Record Edited Successfully")));
} catch (e) {
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: Text("Error: $e")));
}
}
//----------------------------------------------------------------------------- on edit tap
onEdit({required BookingsModel booking}) {
isEditing = true;
nameController.text = booking.name;
phoneNoController.text = booking.phoneNo;
dateController.text = DateFormat("dd/MM/yyyy").format(booking.checkIn);
checkInDate = booking.checkIn;
updatingBookingId = booking.id;
isAdvancePaid = booking.advancePaid;
notifyListeners();
}
//----------------------------------------------------------------------------bookings filter
String selectedFilter = "All";
List<String> filters = ["All", "This Week", "This Month"];
int selectedDays = 7;
selectFilter(filter) async {
selectedFilter = filter;
if (selectedFilter == "This Week") {
selectedDays = 7;
filterBookings();
} else if (selectedFilter == "This Month") {
selectedDays = 30;
filterBookings();
} else if (selectedFilter == "All") {
bookings = allBookings;
}
notifyListeners();
}
filterBookings() async {
try {
// Get the current date and time
final currentDate = DateTime.now();
// Filter bookings with check-in date within this week
final filteredBookings = allBookings.where((booking) {
final daysDifference = booking.checkIn.difference(currentDate).inDays;
return daysDifference >= 0 && daysDifference < selectedDays;
}).toList();
bookings = filteredBookings;
notifyListeners();
} catch (e) {
rethrow;
}
}
//----------------------------------------------------------------------------on cancel
onCanacel() {
isEditing = false;
nameController.clear();
phoneNoController.clear();
dateController.clear();
isAdvancePaid = false;
notifyListeners();
}
//----------------------------------------------------------------------------- check In date assigning
void setDate(DateTime date) {
checkInDate = date;
dateController.text = "${checkInDate.toLocal()}".split(' ')[0];
notifyListeners();
}
//----------------------------------------------------------------------------- advance paid or not radio button function
void advance(bool value) {
isAdvancePaid = value;
notifyListeners();
}
//------------------------------------------------------------------------------Text field validation
fieldValidation(value) {
if (value == null || value.isEmpty) {
return "this Field is required.";
} else {
return null;
}
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/bookings
|
mirrored_repositories/Hostel-Manager/lib/fetures/bookings/controllers/bookings_repository.dart
|
// ignore_for_file: avoid_print
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:hostel_management_app/fetures/bookings/models/booking_model.dart';
class BookingRepository with ChangeNotifier {
final _db = FirebaseFirestore.instance;
final FirebaseAuth _auth = FirebaseAuth.instance;
//------------------------------------------------------------------------------fetch Bookings
Future<List<BookingsModel>> fetchData() async {
try {
final userId = _auth.currentUser?.uid;
if (userId == null || userId.isEmpty) {
throw Exception("Unable to find user information, try again later");
}
final result = await _db
.collection("Owners")
.doc(userId)
.collection("Bookings")
.get();
final roomModels = result.docs
.map((documentSnapshot) =>
BookingsModel.fromDocumentSnapshot(documentSnapshot))
.toList();
return roomModels;
} catch (e) {
print("Error: $e");
rethrow;
}
}
//----------------------------------------------------------------------------Add new Booking
addBooking(BookingsModel booking) async {
try {
final userId = _auth.currentUser!.uid;
await _db
.collection("Owners")
.doc(userId)
.collection("Bookings")
.add(booking.toJson());
} catch (e) {
print(e.toString());
}
}
//----------------------------------------------------------------------------Update Booking
Future<void> updadatBooking(BookingsModel booking) async {
final userId = _auth.currentUser!.uid;
try {
await _db
.collection("Owners")
.doc(userId)
.collection("Bookings")
.doc(booking.id)
.update(booking.toJson());
} catch (e) {
print("Somthing went wrong");
}
}
//----------------------------------------------------------------------------update only room no
Future<void> updateBookingsRoomNo(int oldRoomNo, int newRoomNo) async {
final userId = _auth.currentUser!.uid;
try {
// Query the collection to find all bookings with the oldRoomNo
QuerySnapshot bookingsSnapshot = await _db
.collection("Owners")
.doc(userId)
.collection("Bookings")
.where("RoomNo", isEqualTo: oldRoomNo)
.get();
// Update the roomNo field for each matching booking
for (QueryDocumentSnapshot bookingDoc in bookingsSnapshot.docs) {
await _db
.collection("Owners")
.doc(userId)
.collection("Bookings")
.doc(bookingDoc.id)
.update({"RoomNo": newRoomNo});
}
} catch (e) {
print("Something went wrong: $e");
rethrow;
}
}
//----------------------------------------------------------------------------update single field
Future<void> updadatSingleField(
{required Map<String, dynamic> json, required String bookingId}) async {
final userId = _auth.currentUser!.uid;
try {
await _db
.collection("Owners")
.doc(userId)
.collection("Bookings")
.doc(bookingId)
.update(json);
} catch (e) {
print("Somthing went wrong");
}
}
//----------------------------------------------------------------------------Delete a booking
Future<void> deleteBooking(String bookingId) async {
try {
final userId = _auth.currentUser!.uid;
await _db
.collection("Owners")
.doc(userId)
.collection("Bookings")
.doc(bookingId)
.delete();
} catch (e) {
print(e.toString());
}
}
//----------------------------------------------------------------------------delete bookiing with room number
Future<void> deleteBookingsByRoomNo(int roomNo) async {
try {
final userId = _auth.currentUser!.uid;
// Query the collection to find all documents with the specified roomNo
QuerySnapshot bookingSnapshot = await _db
.collection("Owners")
.doc(userId)
.collection("Bookings")
.where("RoomNo", isEqualTo: roomNo)
.get();
// Delete all matching documents
for (QueryDocumentSnapshot bookingDoc in bookingSnapshot.docs) {
await _db
.collection("Owners")
.doc(userId)
.collection("Bookings")
.doc(bookingDoc.id)
.delete();
}
} catch (e) {
print(e.toString());
}
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/bookings
|
mirrored_repositories/Hostel-Manager/lib/fetures/bookings/widgets/confirm_delete_dialog.dart
|
import 'package:flutter/material.dart';
import 'package:hostel_management_app/fetures/bookings/controllers/bookings_controller.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
import 'package:provider/provider.dart';
class DeletDialog extends StatelessWidget {
const DeletDialog({
super.key,
required this.bookingId,
required this.roomId,
});
final String bookingId, roomId;
@override
Widget build(BuildContext context) {
return AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15.0),
),
title: const Text(
'Confirm Delete',
textAlign: TextAlign.center,
),
content: const Text(
'Are you sure you want to Delelte this record permenetly?'),
actionsAlignment: MainAxisAlignment.center,
actions: <Widget>[
OutlinedButton(
onPressed: () {
Navigator.of(context)
.pop(false); // Dismiss the dialog and return false
},
child: const Text('Cancel'),
),
ElevatedButton(
style: ButtonStyle(
backgroundColor:
MaterialStatePropertyAll(ColorConstants.colorRed)),
onPressed: () async {
Provider.of<BookingsController>(context, listen: false)
.deleteBooking(
context: context, bookingId: bookingId, roomId: roomId);
},
child: const Text('Delete'),
),
],
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/bookings
|
mirrored_repositories/Hostel-Manager/lib/fetures/bookings/widgets/booking_formfield.dart
|
import 'package:flutter/material.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
class BookingTextField extends StatelessWidget {
const BookingTextField(
{super.key,
required this.controller,
this.suffix,
this.enablde = true,
required this.validator});
final TextEditingController controller;
final Widget? suffix;
final bool enablde;
final Function(String?) validator;
@override
Widget build(BuildContext context) {
return SizedBox(
height: 50,
child: TextFormField(
validator: (value) => validator(value),
enabled: enablde,
controller: controller,
decoration: InputDecoration(
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide:
BorderSide(width: 1.5, color: ColorConstants.primaryWhiteColor),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide:
BorderSide(width: 2, color: ColorConstants.primaryWhiteColor),
),
disabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide:
BorderSide(width: 2, color: ColorConstants.primaryWhiteColor),
),
suffixIcon: suffix,
),
),
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/bookings
|
mirrored_repositories/Hostel-Manager/lib/fetures/bookings/widgets/bookings_card.dart
|
import 'package:fluentui_system_icons/fluentui_system_icons.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
import 'package:hostel_management_app/utils/text_style_constatnts.dart';
import 'package:intl/intl.dart';
class BookingsCard extends StatelessWidget {
const BookingsCard({
super.key,
required this.name,
required this.date,
required this.advance,
required this.roomNo,
this.onTap,
required this.onDelete,
required this.onEdit,
});
final String name;
final DateTime date;
final bool advance;
final int roomNo;
final void Function()? onTap;
final void Function()? onDelete;
final void Function()? onEdit;
@override
Widget build(BuildContext context) {
return InkWell(
onTap: () => onTap?.call(),
child: Container(
padding: const EdgeInsets.all(10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Hero(
tag: name,
child: CircleAvatar(
radius: 20,
backgroundColor: ColorConstants.secondaryColor4,
child: Icon(
Icons.person,
color: ColorConstants.primaryWhiteColor,
),
),
),
const SizedBox(
width: 10,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(
height: 5,
),
Text(
name,
style: TextStyleConstants.dashboardBookingName,
),
const SizedBox(height: 5),
Row(
children: [
const Icon(
Icons.calendar_month,
size: 17,
),
const SizedBox(
width: 5,
),
Text(
DateFormat('dd MMM yyyy').format(date),
style: TextStyleConstants.bookingsJoiningDate,
),
],
),
const SizedBox(
height: 5,
),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5),
color: advance
? ColorConstants.colorGreen
: ColorConstants.colorRed),
padding: const EdgeInsets.symmetric(
horizontal: 10, vertical: 4),
child: Center(
child: Text(
advance ? "Advance Paid" : "Advance Not Paid",
style: TextStyleConstants.buttonText,
)),
)
],
)
],
),
Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: ColorConstants.secondaryColor4),
padding: const EdgeInsets.symmetric(
horizontal: 7, vertical: 4),
child: Row(
children: [
Icon(
FluentIcons.conference_room_48_regular,
color: ColorConstants.primaryBlackColor,
size: 26,
),
Text(
roomNo.toString(),
style: TextStyleConstants.bookingsRoomNumber,
)
],
),
),
],
),
const SizedBox(
height: 5,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
IconButton(
onPressed: () => onEdit?.call(),
icon: const Icon(FontAwesomeIcons.penToSquare)),
const SizedBox(
width: 20,
),
IconButton(
onPressed: () => onDelete?.call(),
icon: const Icon(Icons.delete))
],
)
],
)
],
),
),
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/bookings
|
mirrored_repositories/Hostel-Manager/lib/fetures/bookings/models/booking_model.dart
|
import 'package:cloud_firestore/cloud_firestore.dart';
class BookingsModel {
final int roomNO;
final String name;
final String phoneNo;
final DateTime checkIn;
final bool advancePaid;
final String roomId;
String? id;
BookingsModel(
{required this.roomNO,
required this.roomId,
required this.name,
required this.phoneNo,
required this.checkIn,
required this.advancePaid,
this.id});
Map<String, dynamic> toJson() {
return {
"RoomNo": roomNO,
"Name": name,
"phoneNo": phoneNo,
"CheckIn": checkIn,
"AdvancePaid": advancePaid,
"RoomId": roomId
};
}
factory BookingsModel.fromDocumentSnapshot(
DocumentSnapshot<Map<String, dynamic>> document) {
if (document.data() != null) {
final data = document.data()!;
return BookingsModel(
id: document.id,
roomNO: data["RoomNo"] ?? 0,
name: data['Name'] ?? "",
checkIn: (data['CheckIn'] as Timestamp).toDate(),
phoneNo: data['phoneNo'] ?? "",
advancePaid: data['AdvancePaid'] ?? false,
roomId: data['RoomId'] ?? "");
} else {
return BookingsModel.empty();
}
}
static BookingsModel empty() => BookingsModel(
roomNO: 0,
name: '',
phoneNo: '',
roomId: '',
checkIn: DateTime(2000),
advancePaid: false);
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/bookings
|
mirrored_repositories/Hostel-Manager/lib/fetures/bookings/screens/add_booking_screen.dart
|
import 'package:flutter/material.dart';
import 'package:hostel_management_app/fetures/bookings/controllers/bookings_controller.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
import 'package:hostel_management_app/utils/image_constants.dart';
import 'dart:ui' as ui;
import 'package:hostel_management_app/utils/text_style_constatnts.dart';
import 'package:hostel_management_app/fetures/bookings/widgets/booking_formfield.dart';
import 'package:provider/provider.dart';
class AddBookingScreen extends StatelessWidget {
const AddBookingScreen(
{super.key, required this.roomNo, required this.roomid});
final int roomNo;
final String roomid;
@override
Widget build(BuildContext context) {
final controller = Provider.of<BookingsController>(context, listen: false);
const gap = SizedBox(
height: 10,
);
return BackdropFilter(
filter: ui.ImageFilter.blur(
sigmaX: 5.0,
sigmaY: 5.0,
),
child: SafeArea(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 20),
child: Container(
height: double.infinity,
width: double.infinity,
decoration: BoxDecoration(
color: ColorConstants.secondaryColor5.withOpacity(0.5),
borderRadius: BorderRadius.circular(40)),
padding: const EdgeInsets.all(25),
child: Scaffold(
backgroundColor: Colors.transparent,
body: SingleChildScrollView(
child: Form(
key: controller.formKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
IconButton(
onPressed: () {
controller.onCanacel();
Navigator.pop(context);
},
icon: Icon(
Icons.arrow_back_ios_new,
color: ColorConstants.primaryWhiteColor,
),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Column(
children: [
CircleAvatar(
radius: 25,
backgroundColor: ColorConstants.primaryWhiteColor,
child: Hero(
tag: Image,
child: Image.asset(
ImageConstants.roomsIcon2,
color: ColorConstants.primaryBlackColor,
),
),
),
Text(
"Room No",
style: TextStyleConstants.ownerRoomNumber2,
),
Text(
roomNo.toString(),
style: TextStyleConstants.ownerRoomNumber3,
),
const SizedBox(
height: 20,
),
],
),
],
),
const Text("Name "),
gap,
BookingTextField(
controller: controller.nameController,
validator: (p0) => controller.fieldValidation(p0),
),
gap,
const Text("Phone no"),
gap,
BookingTextField(
controller: controller.phoneNoController,
validator: (p0) => controller.fieldValidation(p0),
),
gap,
const Text("Joining date"),
gap,
InkWell(
onTap: () async {
final date = await showDatePicker(
context: context,
initialDate: DateTime.now(),
firstDate: DateTime.now(),
lastDate: DateTime(2025),
);
controller.setDate(date!);
},
child: BookingTextField(
controller: controller.dateController,
validator: (p0) => controller.fieldValidation(p0),
suffix: Icon(
Icons.calendar_month_outlined,
color: ColorConstants.primaryWhiteColor,
),
enablde: false,
),
),
gap,
const Text("Advance"),
gap,
Consumer<BookingsController>(
builder: (context, value, child) => Row(
children: [
RadioMenuButton(
value: true,
groupValue: controller.isAdvancePaid,
onChanged: (value) => controller.advance(value!),
child: const Text("Paid"),
),
RadioMenuButton(
style: const ButtonStyle(),
value: false,
groupValue: controller.isAdvancePaid,
onChanged: (value) => controller.advance(value!),
child: const Text("Not Paid"))
],
),
),
gap,
Center(
child: InkWell(
onTap: () {
if (controller.formKey.currentState!.validate()) {
if (controller.isEditing) {
controller.updateBooking(context);
} else {
controller.addBooking(
context: context,
roomNo: roomNo,
roomId: roomid);
}
}
},
child: Container(
height: 50,
width: 150,
decoration: BoxDecoration(
color: ColorConstants.primaryColor,
borderRadius: BorderRadius.circular(15),
),
child: Center(
child: Text(
controller.isEditing ? "Edit" : "Add",
style: TextStyleConstants.buttonText,
),
),
),
),
)
],
),
),
),
),
),
)),
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/bookings
|
mirrored_repositories/Hostel-Manager/lib/fetures/bookings/screens/bookings_page.dart
|
import 'package:flutter/material.dart';
import 'package:hostel_management_app/commens/widgets/custom_dropdown_button.dart';
import 'package:hostel_management_app/fetures/bookings/controllers/bookings_controller.dart';
import 'package:hostel_management_app/fetures/profile/controllers/user_controller.dart';
import 'package:hostel_management_app/fetures/bookings/models/booking_model.dart';
import 'package:hostel_management_app/fetures/rooms/models/room_model.dart';
import 'package:hostel_management_app/fetures/rooms/widgets/rooms_loading_card.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
import 'package:hostel_management_app/utils/text_style_constatnts.dart';
import 'package:hostel_management_app/fetures/bookings/screens/booked_resident_detailes_screen.dart';
import 'package:hostel_management_app/fetures/bookings/screens/add_booking_screen.dart';
import 'package:hostel_management_app/fetures/bookings/widgets/bookings_card.dart';
import 'package:hostel_management_app/commens/widgets/room_card.dart';
import 'package:hostel_management_app/fetures/bookings/widgets/confirm_delete_dialog.dart';
import 'package:hostel_management_app/fetures/residents/widgets/resident_loading_card.dart';
import 'package:provider/provider.dart';
class BookingsPage extends StatefulWidget {
const BookingsPage({super.key});
@override
State<BookingsPage> createState() => _BookingsPageState();
}
class _BookingsPageState extends State<BookingsPage> {
@override
void initState() {
Provider.of<BookingsController>(context, listen: false).fetchVacantRooms();
Provider.of<BookingsController>(context, listen: false).fetchBookingsData();
Provider.of<UserController>(context, listen: false).fetchData();
super.initState();
}
@override
Widget build(BuildContext context) {
final controller = Provider.of<BookingsController>(context);
final userController = Provider.of<UserController>(context);
return Scaffold(
backgroundColor: ColorConstants.primaryWhiteColor,
appBar: AppBar(
title: Text(
"Booking Detailes",
style: TextStyleConstants.homeMainTitle2,
),
backgroundColor: ColorConstants.primaryWhiteColor,
elevation: 0,
leadingWidth: 10,
),
body: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: SingleChildScrollView(
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Consumer<BookingsController>(
builder: (context, value, child) => CustomDropdownButton(
selectedValue: value.selectedFilter,
items: value.filters,
onChanged: (p0) => value.selectFilter(p0),
height: 50,
width: 150))
],
),
const SizedBox(
height: 20,
),
SizedBox(
height: controller.bookings.length < 3
? MediaQuery.sizeOf(context).height * 30 / 100
: MediaQuery.sizeOf(context).height * 45 / 100,
child: Consumer<BookingsController>(
builder: (context, value, child) => value.bookings.isEmpty
? const Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('No available Bookings'),
Icon(Icons.error_outline_outlined),
],
))
: value.isBookingsLoading
? ListView.separated(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemBuilder: (context, index) {
return const ResidentsLoadingCard();
},
separatorBuilder: (context, index) => Divider(
color: ColorConstants.secondaryWhiteColor,
height: 10,
),
itemCount: value.bookings.isEmpty
? 3
: value.bookings.length)
: ListView.builder(
itemCount: value.bookings.length,
itemBuilder: (context, index) {
final BookingsModel booking =
value.bookings[index];
return BookingsCard(
name: booking.name,
advance: booking.advancePaid,
date: booking.checkIn,
roomNo: booking.roomNO,
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
BookedResidentDetailesScreen(
index: index,
),
),
);
},
onDelete: () {
showDialog(
context: context,
builder: (context) => DeletDialog(
bookingId: booking.id.toString(),
roomId: booking.roomId),
);
},
onEdit: () {
Provider.of<BookingsController>(context,
listen: false)
.onEdit(booking: booking);
showAdaptiveDialog(
barrierColor: Colors.transparent,
context: context,
builder: (context) => AddBookingScreen(
roomNo: booking.roomNO,
roomid: booking.roomId,
),
);
},
);
},
),
),
),
const SizedBox(
height: 20,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Add Bookings",
style: TextStyleConstants.homeMainTitle2,
),
Column(
children: [
Text(
'Total Beds vaccent',
style: TextStyleConstants.ownerRoomsText2,
),
const SizedBox(
height: 10,
),
CircleAvatar(
radius: 15,
backgroundColor: ColorConstants.primaryColor,
child: Text(
userController.user?.noOfVacancy.toString() ?? "",
style: TextStyleConstants.ownerRoomsCircleAvtarText,
),
)
],
),
],
),
const SizedBox(
height: 20,
),
Consumer<BookingsController>(
builder: (context, value, child) => value.vacantRooms.isNotEmpty
? value.isRoomsLoading
? GridView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
padding:
const EdgeInsets.only(bottom: 10, left: 10),
itemCount: controller.vacantRooms.isEmpty
? 6
: controller.vacantRooms.length,
gridDelegate:
const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
crossAxisSpacing: 0,
mainAxisSpacing: 20,
mainAxisExtent: 90,
),
itemBuilder: (context, index) =>
const RoomsLoadingCard())
: GridView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
padding:
const EdgeInsets.only(bottom: 10, left: 10),
itemCount: controller.vacantRooms.length,
gridDelegate:
const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
crossAxisSpacing: 0,
mainAxisSpacing: 20,
mainAxisExtent: 90,
),
itemBuilder: (context, index) {
final RoomModel room =
controller.vacantRooms[index];
return RoomsCard(
roomNumber: room.roomNo.toString(),
vaccentBedNumber: room.vacancy.toString(),
onTap: () {
showAdaptiveDialog(
barrierColor: Colors.transparent,
context: context,
builder: (context) => AddBookingScreen(
roomNo: room.roomNo,
roomid: room.id!,
),
);
},
);
},
)
: const Center(
child: Text("No Available Vacancies"),
),
)
],
),
),
),
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/bookings
|
mirrored_repositories/Hostel-Manager/lib/fetures/bookings/screens/booked_resident_detailes_screen.dart
|
import 'package:fluentui_system_icons/fluentui_system_icons.dart';
import 'package:flutter/material.dart';
import 'package:hostel_management_app/commens/functions/make_phone_call.dart';
import 'package:hostel_management_app/fetures/bookings/controllers/bookings_controller.dart';
import 'package:hostel_management_app/fetures/residents/controllers/residents_controller.dart';
import 'package:hostel_management_app/fetures/bookings/models/booking_model.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
import 'package:hostel_management_app/utils/text_style_constatnts.dart';
import 'package:hostel_management_app/fetures/bookings/screens/add_booking_screen.dart';
import 'package:hostel_management_app/fetures/bookings/widgets/confirm_delete_dialog.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
class BookedResidentDetailesScreen extends StatelessWidget {
const BookedResidentDetailesScreen(
{super.key, required this.index, this.isSorted = false});
final int index;
final bool? isSorted;
@override
Widget build(BuildContext context) {
final controller = Provider.of<ResidentsController>(context, listen: false);
return Consumer<BookingsController>(
builder: (context, value, child) {
final BookingsModel detailes = isSorted!
? value.bookingsWithinThisWeek[index]
: value.bookings[index];
return Scaffold(
backgroundColor: ColorConstants.primaryWhiteColor,
appBar: AppBar(
backgroundColor: ColorConstants.primaryWhiteColor,
iconTheme: IconThemeData(color: ColorConstants.primaryBlackColor),
leading: IconButton(
onPressed: () {
Navigator.pop(context);
},
icon: const Icon(
Icons.chevron_left_outlined,
size: 30,
)),
actions: [
PopupMenuButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
),
elevation: 10,
itemBuilder: (context) {
return [
PopupMenuItem(
child: const Text('Edit'),
onTap: () {
Provider.of<BookingsController>(context,
listen: false)
.onEdit(booking: detailes);
showAdaptiveDialog(
barrierColor: Colors.transparent,
context: context,
builder: (context) => AddBookingScreen(
roomNo: detailes.roomNO,
roomid: detailes.roomId,
),
);
}),
PopupMenuItem(
child: Text(
'Delete',
style: TextStyle(color: ColorConstants.colorRed),
),
onTap: () async {
await showDialog(
context: context,
builder: (context1) => DeletDialog(
bookingId: detailes.id.toString(),
roomId: detailes.roomId),
);
// ignore: use_build_context_synchronously
Navigator.pop(context);
},
),
];
},
),
],
elevation: 0,
),
body: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Center(
child: Hero(
tag: detailes.name,
child: CircleAvatar(
radius: 55,
backgroundColor: ColorConstants.secondaryColor4,
child: const Icon(
Icons.person,
size: 50,
),
),
),
),
const SizedBox(
height: 20,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: ColorConstants.secondaryColor4),
padding: const EdgeInsets.symmetric(
horizontal: 7, vertical: 4),
child: Row(
children: [
Icon(
FluentIcons.conference_room_48_regular,
color: ColorConstants.primaryBlackColor,
size: 29,
),
Text(
detailes.roomNO.toString(),
style: TextStyleConstants.bookingsRoomNumber,
)
],
),
),
const SizedBox(
width: 20,
),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5),
color: detailes.advancePaid
? ColorConstants.colorGreen
: ColorConstants.colorRed),
padding: const EdgeInsets.symmetric(
horizontal: 10, vertical: 7),
child: Center(
child: Text(
detailes.advancePaid
? "Advance Paid"
: "Advance Not Paid",
style: TextStyleConstants.buttonText,
),
),
)
],
),
const SizedBox(
height: 20,
),
const Text("Name"),
const SizedBox(
height: 5,
),
Container(
padding: const EdgeInsets.all(15),
width: double.infinity,
decoration: BoxDecoration(
color: ColorConstants.secondaryColor4.withOpacity(0.1),
borderRadius: BorderRadius.circular(10),
),
child: Text(
detailes.name,
style: TextStyleConstants.dashboardBookingName,
),
),
const SizedBox(
height: 20,
),
const Text("Phone Number"),
const SizedBox(
height: 5,
),
Container(
padding:
const EdgeInsets.symmetric(horizontal: 10, vertical: 3),
width: double.infinity,
decoration: BoxDecoration(
color: ColorConstants.secondaryColor4.withOpacity(0.1),
borderRadius: BorderRadius.circular(10),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
detailes.phoneNo,
style: TextStyleConstants.dashboardBookingName,
),
IconButton(
onPressed: () {
makePhoneCall(detailes.phoneNo, context);
},
icon: const Icon(Icons.call),
)
],
),
),
const SizedBox(
height: 20,
),
const Text("Joining Date"),
const SizedBox(
height: 5,
),
Container(
padding: const EdgeInsets.all(15),
width: double.infinity,
decoration: BoxDecoration(
color: ColorConstants.secondaryColor4.withOpacity(0.1),
borderRadius: BorderRadius.circular(10)),
child: Text(
DateFormat('dd/MM/yyy').format(detailes.checkIn),
style: TextStyleConstants.dashboardBookingName,
),
),
const SizedBox(
height: 20,
),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
InkWell(
onTap: () {
controller.addBookingToResident(detailes, context);
},
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: ColorConstants.primaryColor,
),
height: 40,
width: 150,
child: Center(
child: Text(
"Add To Residents",
style: TextStyleConstants.buttonText,
),
),
),
),
],
)
],
),
),
),
);
},
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/bookings
|
mirrored_repositories/Hostel-Manager/lib/fetures/bookings/screens/booking_successfull_page.dart
|
import 'package:flutter/material.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
import 'package:hostel_management_app/utils/text_style_constatnts.dart';
class BokkingsuccessfullScreen extends StatefulWidget {
const BokkingsuccessfullScreen({super.key});
@override
State<BokkingsuccessfullScreen> createState() =>
_BokkingsuccessfullScreenState();
}
class _BokkingsuccessfullScreenState extends State<BokkingsuccessfullScreen> {
@override
void initState() {
Future.delayed(const Duration(seconds: 1)).then(
(value) {
Navigator.pop(context);
Navigator.pop(context);
},
);
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
CircleAvatar(
radius: 50,
backgroundColor: ColorConstants.primaryColor,
child: Icon(
Icons.done,
size: 60,
color: ColorConstants.primaryWhiteColor,
),
),
const SizedBox(
height: 70,
),
Text(
"Booking Added \n Successfully",
style: TextStyleConstants.loginTiltle,
textAlign: TextAlign.center,
),
const SizedBox(
height: 10,
),
],
),
),
),
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/residents
|
mirrored_repositories/Hostel-Manager/lib/fetures/residents/controllers/residents_controller.dart
|
// ignore_for_file: use_build_context_synchronously, avoid_print
import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:hostel_management_app/fetures/bookings/controllers/bookings_controller.dart';
import 'package:hostel_management_app/commens/functions/connection_checher.dart';
import 'package:hostel_management_app/fetures/residents/controllers/residents_repository.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:hostel_management_app/fetures/rooms/controllers/rooms_repository.dart';
import 'package:hostel_management_app/fetures/profile/controllers/user_repository.dart';
import 'package:hostel_management_app/fetures/bookings/models/booking_model.dart';
import 'package:hostel_management_app/fetures/profile/models/owner_model.dart';
import 'package:hostel_management_app/fetures/residents/models/resident_model.dart';
import 'package:hostel_management_app/fetures/rooms/models/room_model.dart';
import 'package:hostel_management_app/fetures/residents/screens/residents_adding_form.dart';
import 'package:image_picker/image_picker.dart';
import 'package:intl/intl.dart';
class ResidentsController with ChangeNotifier {
GlobalKey<FormState> formKey = GlobalKey<FormState>();
final purposeController = TextEditingController();
final nameController = TextEditingController();
final phoneNoController = TextEditingController();
final emailController = TextEditingController();
final addressController = TextEditingController();
final emargencyContactController = TextEditingController();
final checkInDateController = TextEditingController();
final checkOutDateController = TextEditingController();
final ResidentsRepository residentsRepository = ResidentsRepository();
final ConnectionChecker connectionController = ConnectionChecker();
final BookingsController bookingsController = BookingsController();
final RoomsRepository roomController = RoomsRepository();
final UserRepository ownerRepository = UserRepository();
final FirebaseAuth auth = FirebaseAuth.instance;
List<ResidentModel> allResidents = [];
List<ResidentModel> residents = [];
List<RoomModel> vacantRooms = [];
List<String> vacantRoomNoList = [];
String? selectedRoom = "0";
String? selectedRoomId = "";
DateTime? checkInDate;
DateTime? checkOutDate;
File? selectedImage;
String oldImage = "";
String? imageUrl;
String? editingRoomId;
String? editingResidentId;
ResidentModel? editingResidnt;
BookingsModel? addingBooking;
bool isAddingaBookedResident = false;
int? oldRoomNo;
bool isEditing = false;
bool isResidentsLoading = false;
List<String> filters = [
"All Residents",
"Rent Penting",
];
String selctedFilter = "All Residents";
// -----------------------------------------------------------------------------Fetch Resident detailes
Future<void> fetchResidents() async {
try {
isResidentsLoading = true;
allResidents = await residentsRepository.fetchData();
allResidents.sort((a, b) => a.roomNo.compareTo(b.roomNo));
residents = allResidents;
} catch (e) {
print(e.toString());
rethrow;
} finally {
isResidentsLoading = false;
notifyListeners();
}
}
//------------------------------------------------------------------------------Fetch Vacant Rooms
fetchVacantRooms() async {
try {
vacantRoomNoList.clear();
List<RoomModel> allRooms = await roomController.fetchData();
// Filter out vacant rooms (Vacancy > 0)
vacantRooms = allRooms.where((room) => room.vacancy > 0).toList();
if (vacantRooms.isNotEmpty) {
// Create a Set to keep track of unique room numbers
vacantRooms.sort((a, b) => a.roomNo.compareTo(b.roomNo));
for (RoomModel room in vacantRooms) {
String roomNumber = room.roomNo.toString();
// Check if the room number hasn't been added before
if (!vacantRoomNoList.contains(roomNumber)) {
vacantRoomNoList.add(roomNumber);
}
}
if (vacantRoomNoList.isNotEmpty) {
selectedRoom = vacantRoomNoList[0].toString();
selectedRoomId = vacantRooms[0].id!;
}
} else {
// Handle case when all rooms are occupied
selectedRoom = null; // or provide a default value
selectedRoomId = null; // or provide a default value
}
notifyListeners();
} catch (e) {
print(e.toString());
rethrow;
}
}
//-------------------------------------------------------------------------------Add Resident
addResident(BuildContext context) async {
try {
final isConnected = await connectionController.isConnected();
if (!isConnected) {
ScaffoldMessenger.of(context)
.showSnackBar(const SnackBar(content: Text("Network error")));
}
if (selectedImage != null) {
try {
imageUrl = await ownerRepository.uploadImage(
'Owners/Images/Residents', XFile(selectedImage!.path));
} catch (e) {
print("image : ${e.toString()}");
}
}
DateTime nextMonthDate = checkInDate!.add(const Duration(days: 30));
final resident = ResidentModel(
name: nameController.text,
profilePic: imageUrl ?? "",
roomNo: int.parse(selectedRoom!),
roomId: selectedRoomId!,
phone: phoneNoController.text,
email: emailController.text,
address: addressController.text,
emargencyContact: emargencyContactController.text,
purposOfStay: purposeController.text,
checkIn: checkInDate!,
checkOut: checkOutDate!,
nextRentDate: nextMonthDate,
isRentPaid: true);
String documentId = await residentsRepository.addResidents(resident);
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
content: Text("ResidentAdded Successfully"),
));
if (isAddingaBookedResident) {
await bookingsController.deleteBooking(
context: context,
bookingId: addingBooking!.id!,
roomId: addingBooking!.roomId);
isAddingaBookedResident = false;
bookingsController.fetchBookingsData();
notifyListeners();
}
// Upadte room deatile
updateRoom(newResidentId: documentId);
// hostel vacancy
final OwnerModel? owner = await ownerRepository.fetchOwnerRecords();
final currentHostelVacancy = owner!.noOfVacancy;
final int hostelVacancy = currentHostelVacancy - 1;
notifyListeners();
final Map<String, dynamic> data = {'NoOfVacancy': hostelVacancy};
await ownerRepository.accountSetup(data);
//refresh the page
Navigator.pop(context);
refreshpage(context);
} catch (e) {
print(e.toString());
} finally {
isAddingaBookedResident = false;
isEditing = false;
notifyListeners();
}
}
//-------------------------------------------------------------------------------Edit Resident detaile
Future<void> editResident(BuildContext context) async {
try {
final isConnected = await connectionController.isConnected();
if (!isConnected) {
ScaffoldMessenger.of(context)
.showSnackBar(const SnackBar(content: Text("Network error")));
}
if (selectedImage != null) {
try {
imageUrl = await ownerRepository.uploadImage(
'Owners/Images/Residents', XFile(selectedImage!.path));
} catch (e) {
print("image : ${e.toString()}");
}
}
DateTime nextMonthDate = checkInDate!.add(const Duration(days: 30));
final resident = ResidentModel(
id: editingResidentId,
name: nameController.text,
profilePic: imageUrl ?? oldImage,
roomNo: int.parse(selectedRoom!),
roomId: selectedRoomId!,
phone: phoneNoController.text,
email: emailController.text,
address: addressController.text,
emargencyContact: emargencyContactController.text,
purposOfStay: purposeController.text,
checkIn: checkInDate!,
checkOut: checkOutDate!,
nextRentDate: nextMonthDate,
isRentPaid: true);
if (editingResidnt!.roomNo == int.parse(selectedRoom!)) {
await residentsRepository.updateResident(resident);
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
content: Text("Resident detailes Edited successfully")));
Navigator.pop(context);
refreshpage(context);
} else {
try {
await residentsRepository.updateResident(resident);
Navigator.pop(context);
// await updateRoom(newResidentId: editingResidnt!.id.toString());
// Fetch information about the old room
final RoomModel? oldRoom = await roomController.fetchSingleRoom(
roomId: editingResidnt!.roomId,
);
// Update the old room's data
final int currentVacancy = oldRoom!.vacancy;
final int updatedVacancy = currentVacancy + 1;
final List<String> currentResidents = oldRoom.residents;
final List<String> updatedResidents = List.from(currentResidents)
..remove(editingResidnt!.id.toString());
// Update the old room document with new vacancy and residents list
final Map<String, dynamic> oldRoomData = {
"Vacancy": updatedVacancy,
"Residents": updatedResidents,
};
await roomController.updateSingleField(
json: oldRoomData,
roomId: editingResidnt!.roomId,
);
// Fetch information about the new room
final RoomModel? newRoom = await roomController.fetchSingleRoom(
roomId: selectedRoomId!,
);
// Update the new room's data
final int currentNewVacancy = newRoom!.vacancy;
final int updatedNewVacancy = currentNewVacancy - 1;
final List<String> currentNewResidents = newRoom.residents;
final List<String> updatedNewResidents =
List.from(currentNewResidents)
..add(editingResidnt!.id.toString());
// Update the new room document with new vacancy and residents list
final Map<String, dynamic> newRoomData = {
"Vacancy": updatedNewVacancy,
"Residents": updatedNewResidents,
};
await roomController.updateSingleField(
json: newRoomData,
roomId: selectedRoomId!,
);
Navigator.pop(context);
refreshpage(context);
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text("Resident details edited successfully")),
);
} catch (e) {
print(e);
}
}
} catch (e) {
print(e);
}
}
//--------------------------------------------------------------------------------Add bookings to resident
addBookingToResident(BookingsModel booking, BuildContext context) {
nameController.text = booking.name;
phoneNoController.text = booking.phoneNo;
checkInDateController.text =
DateFormat('dd/MM/yyyy').format(booking.checkIn);
checkInDate = booking.checkIn;
selectedRoom = booking.roomNO.toString();
selectedRoomId = booking.roomId;
isAddingaBookedResident = true;
addingBooking = booking;
notifyListeners();
showModalBottomSheet(
isScrollControlled: true,
context: context,
builder: (context) => const ResidentsAddingPage(),
elevation: 10,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
),
useSafeArea: true,
);
}
//------------------------------------------------------------------------------Delete Resident
Future<void> deleteResident(
{required BuildContext context, required ResidentModel resident}) async {
try {
final isConnected = await connectionController.isConnected();
if (!isConnected) {
ScaffoldMessenger.of(context)
.showSnackBar(const SnackBar(content: Text("Network error")));
}
await residentsRepository.deleteResident(resident.id!);
final RoomModel? room =
await roomController.fetchSingleRoom(roomId: resident.roomId);
final currentVacancy = room!.vacancy;
final int vacancy = currentVacancy + 1;
final currentResidents = room.residents;
currentResidents.remove(resident.id);
notifyListeners();
final Map<String, dynamic> json = {
"Vacancy": vacancy,
"Residents": currentResidents
};
await roomController.updateSingleField(
json: json, roomId: resident.roomId);
final OwnerModel? owner = await ownerRepository.fetchOwnerRecords();
final currentHostelVacancy = owner!.noOfVacancy;
final int hostelVacancy = currentHostelVacancy + 1;
notifyListeners();
final Map<String, dynamic> data = {'NoOfVacancy': hostelVacancy};
await ownerRepository.accountSetup(data);
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text("Resident deleted Successfull")));
Navigator.pop(context);
refreshpage(context);
} catch (e) {
print(e);
}
}
//--------------------------------------------------------------------------------On edit
onEdit(ResidentModel resident, BuildContext context) async {
await fetchVacantRooms();
isEditing = true;
selectedRoom = resident.roomNo.toString();
selectedRoomId = resident.roomId;
selectedImage = null;
oldImage = resident.profilePic;
imageUrl = resident.profilePic;
checkInDate = resident.checkIn;
checkOutDate = resident.checkOut;
nameController.text = resident.name;
phoneNoController.text = resident.phone;
emailController.text = resident.email;
addressController.text = resident.address;
emargencyContactController.text = resident.emargencyContact;
purposeController.text = resident.purposOfStay;
checkInDateController.text =
DateFormat('dd/MM/yyyy').format(resident.checkIn);
checkOutDateController.text =
DateFormat('dd/MM/yyyy').format(resident.checkOut);
editingRoomId = resident.roomId;
oldRoomNo = resident.roomNo;
editingResidentId = resident.id;
editingResidnt = resident;
if (!vacantRoomNoList.contains(resident.roomNo.toString())) {
vacantRoomNoList.add(resident.roomNo.toString());
}
notifyListeners();
showModalBottomSheet(
isScrollControlled: true,
context: context,
builder: (context) => const ResidentsAddingPage(),
elevation: 10,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
),
useSafeArea: true,
);
notifyListeners();
}
//------------------------------------------------------------------------------Edit rentpaid
editRentPaid(
{required String id,
required DateTime currentRentDate,
required BuildContext context}) async {
try {
DateTime nextDate = currentRentDate.add(const Duration(days: 30));
Map<String, dynamic> json = {"NextRentDate": nextDate, "Rentpaid": true};
await residentsRepository.updateSingleField(id, json);
showSnackbar(context: context, content: "Rent Updated successfully");
Navigator.pop(context);
} catch (e) {
showSnackbar(context: context, content: e.toString());
rethrow;
}
}
//------------------------------------------------------------------------------update room data
Future<void> updateRoom({required String newResidentId}) async {
try {
final RoomModel? room =
await roomController.fetchSingleRoom(roomId: selectedRoomId!);
final currentVacancy = room!.vacancy;
final int vacancy = currentVacancy - 1;
final currentResidents = room.residents;
currentResidents.add(newResidentId);
notifyListeners();
final Map<String, dynamic> json = {
"Vacancy": vacancy,
"Residents": currentResidents
};
await roomController.updateSingleField(
json: json, roomId: selectedRoomId!);
} catch (e) {
print(e);
}
}
//------------------------------------------------------------------------------select Image
Future<void> openImagePicker() async {
try {
final XFile? pickedImage = await ImagePicker().pickImage(
source: ImageSource.gallery,
imageQuality: 70,
maxHeight: 512,
maxWidth: 512);
if (pickedImage != null) {
selectedImage = File(pickedImage.path);
notifyListeners();
} else {
if (kDebugMode) {
print('Image not Selected');
}
}
} catch (e) {
print(e);
}
}
//------------------------------------------------------------------------------refresh page
refreshpage(BuildContext context) {
fetchResidents();
fetchVacantRooms();
notifyListeners();
selectedImage = null;
imageUrl = null;
checkInDate = null;
checkOutDate = null;
selectedImage = null;
oldImage = '';
editingRoomId = null;
editingResidentId = null;
oldRoomNo = null;
nameController.clear();
phoneNoController.clear();
emailController.clear();
addressController.clear();
emargencyContactController.clear();
purposeController.clear();
checkInDateController.clear();
checkOutDateController.clear();
isEditing = false;
notifyListeners();
}
//----------------------------------------------------------------------------filter Rooms
selectFilter(filter) async {
isResidentsLoading = true;
selctedFilter = filter;
if (selctedFilter == "All Residents") {
residents = allResidents;
} else if (selctedFilter == "Rent Penting") {
residents =
allResidents.where((element) => element.isRentPaid == false).toList();
}
isResidentsLoading = false;
notifyListeners();
}
//------------------------------------------------------------------------------select room
selectRoom(room) async {
selectedRoom = room;
selectedRoomId = findRoomByRoomNo(int.parse(selectedRoom!));
notifyListeners();
}
//------------------------------------------------------------------------------fetching RoomId
String findRoomByRoomNo(int roomNumber) {
// Find the first room in vacantRooms with the specified room number
RoomModel? room = vacantRooms.firstWhere(
(room) => room.roomNo == roomNumber,
orElse: () => RoomModel.empty());
return room.id!;
}
//------------------------------------------------------------------------------Set checkIn date
void setCheckInDate(DateTime date) {
checkInDate = date;
checkInDateController.text = DateFormat('dd/MM/yyy').format(date);
notifyListeners();
}
//------------------------------------------------------------------------------Set checkOut date
void setCheckOutDate(DateTime date) {
checkOutDate = date;
checkOutDateController.text = DateFormat('dd/MM/yyy').format(date);
notifyListeners();
}
//-----------------------------------------------------------------------------Text field validation
fieldValidation(value) {
if (value == null || value.isEmpty) {
return "this Field is required.";
} else {
return null;
}
}
showSnackbar({required BuildContext context, required String content}) {
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: Text(content)));
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/residents
|
mirrored_repositories/Hostel-Manager/lib/fetures/residents/controllers/residents_repository.dart
|
// ignore_for_file: avoid_print
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:hostel_management_app/fetures/residents/models/resident_model.dart';
class ResidentsRepository {
final _db = FirebaseFirestore.instance;
final FirebaseAuth _auth = FirebaseAuth.instance;
//----------------------------------------------------------------------------Fetch Resident Detailes
Future<List<ResidentModel>> fetchData() async {
try {
final userId = _auth.currentUser?.uid;
if (userId == null || userId.isEmpty) {
throw Exception("Unable to find user information, try again later");
}
final result = await _db
.collection("Owners")
.doc(userId)
.collection("Residents")
.get();
final residentModel = result.docs
.map((documentSnapshot) =>
ResidentModel.fromDocumentSnapshot(documentSnapshot))
.toList();
return residentModel;
} catch (e) {
print("Error: $e");
rethrow;
}
}
//----------------------------------------------------------------------------fetchResident detailes with id
Future<List<ResidentModel>> fetchResidentsByIds(
List<String> residentIds) async {
try {
final userId = _auth.currentUser?.uid;
if (userId == null || userId.isEmpty) {
throw Exception("Unable to find user information, try again later");
}
final List<ResidentModel> residentModels = [];
for (String residentId in residentIds) {
final result = await _db
.collection("Owners")
.doc(userId)
.collection("Residents")
.doc(residentId)
.get();
if (result.exists) {
final residentModel = ResidentModel.fromDocumentSnapshot(result);
residentModels.add(residentModel);
} else {}
}
return residentModels;
} catch (e) {
print("Error: $e");
rethrow;
}
}
// ---------------------------------------------------------------------------Add Residents
Future<String> addResidents(ResidentModel resident) async {
try {
final userId = _auth.currentUser?.uid;
if (userId == null || userId.isEmpty) {
throw Exception("Unable to find user information, try again later");
}
DocumentReference docRef = await _db
.collection("Owners")
.doc(userId)
.collection("Residents")
.add(resident.toJson());
// Return the document ID
return docRef.id;
} catch (e) {
print("Error : ${e.toString()}");
rethrow;
}
}
//------------------------------------------------------------------------------delete Resident
Future<void> deleteResident(String residentId) async {
try {
final userId = _auth.currentUser!.uid;
await _db
.collection("Owners")
.doc(userId)
.collection("Residents")
.doc(residentId)
.delete();
} catch (e) {
print("somthing went wrong $e");
rethrow;
}
}
//------------------------------------------------------------------------------delete list of documents
Future<void> deleteListOfResidents(List<String> residentIds) async {
try {
final userId = _auth.currentUser!.uid;
for (String residentId in residentIds) {
await _db
.collection("Owners")
.doc(userId)
.collection("Residents")
.doc(residentId)
.delete();
}
} catch (e) {
print("Something went wrong $e");
rethrow;
}
}
// -----------------------------------------------------------------------------delete with room no
Future<void> deleteResidentsByRoomNo(int roomNo) async {
try {
final userId = _auth.currentUser!.uid;
// Query the collection to find all residents with the specified roomNo
QuerySnapshot residentsSnapshot = await _db
.collection("Owners")
.doc(userId)
.collection("Residents")
.where("RoomNo", isEqualTo: roomNo)
.get();
// Delete all matching documents
for (QueryDocumentSnapshot residentDoc in residentsSnapshot.docs) {
await _db
.collection("Owners")
.doc(userId)
.collection("Residents")
.doc(residentDoc.id)
.delete();
}
} catch (e) {
print("Something went wrong: $e");
rethrow;
}
}
//----------------------------------------------------------------------------update resident Detailes
Future<void> updateResident(ResidentModel resident) async {
final userId = _auth.currentUser!.uid;
try {
await _db
.collection("Owners")
.doc(userId)
.collection("Residents")
.doc(resident.id)
.update(resident.toJson());
} catch (e) {
print("Somthing went wrong : $e");
rethrow;
}
}
//------------------------------------------------------------------------------update romm no only
Future<void> updateResidentsRoomNo(int oldRoomNo, int newRoomNo) async {
final userId = _auth.currentUser!.uid;
try {
// Query the collection to find all residents with the oldRoomNo
QuerySnapshot residentsSnapshot = await _db
.collection("Owners")
.doc(userId)
.collection("Residents")
.where("RoomNo", isEqualTo: oldRoomNo)
.get();
// Update the roomNo field for each matching resident
for (QueryDocumentSnapshot residentDoc in residentsSnapshot.docs) {
await _db
.collection("Owners")
.doc(userId)
.collection("Residents")
.doc(residentDoc.id)
.update({"RoomNo": newRoomNo});
}
} catch (e) {
print("Something went wrong: $e");
rethrow;
}
}
//------------------------------------------------------------------------------update Singlefield
Future<void> updateSingleField(String id, Map<String, dynamic> json) async {
final userId = _auth.currentUser!.uid;
try {
await _db
.collection("Owners")
.doc(userId)
.collection("Residents")
.doc(id)
.update(json);
} catch (e) {
print("Something went wrong: $e");
rethrow;
}
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/residents
|
mirrored_repositories/Hostel-Manager/lib/fetures/residents/widgets/resident_detailes_card.dart
|
import 'package:flutter/material.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
import 'package:hostel_management_app/utils/text_style_constatnts.dart';
class DetailesCard extends StatelessWidget {
const DetailesCard({
super.key,
required this.tiltle,
required this.data,
});
final String tiltle;
final String data;
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(tiltle),
const SizedBox(
height: 5,
),
Container(
padding: const EdgeInsets.all(15),
width: double.infinity,
decoration: BoxDecoration(
color: ColorConstants.secondaryColor2.withOpacity(0.1),
borderRadius: BorderRadius.circular(10)),
child: Text(
data,
style: TextStyleConstants.dashboardBookingName,
),
),
const SizedBox(
height: 20,
),
],
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/residents
|
mirrored_repositories/Hostel-Manager/lib/fetures/residents/widgets/custom_formfield.dart
|
import 'package:flutter/material.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
class CustomFormField extends StatelessWidget {
const CustomFormField({
super.key,
required this.controller,
this.suffixWidget,
this.isExpanded = false,
this.validator,
});
final TextEditingController controller;
final Widget? suffixWidget;
final bool isExpanded;
final String? Function(String?)? validator;
@override
Widget build(BuildContext context) {
return SizedBox(
height: isExpanded ? 100 : 50,
child: TextFormField(
expands: isExpanded,
validator: validator,
maxLines: isExpanded ? null : 1,
controller: controller,
textAlign: TextAlign.start,
textAlignVertical: TextAlignVertical.top,
decoration: InputDecoration(
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide:
BorderSide(width: 1.5, color: ColorConstants.primaryColor),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide:
BorderSide(width: 2, color: ColorConstants.primaryColor),
),
suffixIcon: suffixWidget),
),
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/residents
|
mirrored_repositories/Hostel-Manager/lib/fetures/residents/widgets/confirm_delete_dialog.dart
|
import 'package:flutter/material.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
class ConfirmDialog extends StatelessWidget {
const ConfirmDialog({
super.key,
this.onPressed,
required this.title,
required this.content,
this.button2Text = "Delete",
this.button1Text = "Cancel",
});
final void Function()? onPressed;
final String title;
final String content;
final String? button2Text;
final String? button1Text;
@override
Widget build(BuildContext context) {
return AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15.0),
),
title: Text(
title,
textAlign: TextAlign.center,
),
content: Text(content),
actionsAlignment: MainAxisAlignment.center,
actions: <Widget>[
OutlinedButton(
onPressed: () {
Navigator.of(context).pop(false);
},
child: Text(button1Text!),
),
ElevatedButton(
style: ButtonStyle(
backgroundColor:
MaterialStatePropertyAll(ColorConstants.colorRed)),
onPressed: onPressed,
child: Text(button2Text!),
),
],
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/residents
|
mirrored_repositories/Hostel-Manager/lib/fetures/residents/widgets/resident_loading_card.dart
|
import 'package:flutter/material.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
import 'package:hostel_management_app/commens/widgets/shimmer_loader.dart';
class ResidentsLoadingCard extends StatelessWidget {
const ResidentsLoadingCard({
super.key,
});
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.all(10),
decoration: BoxDecoration(
color: ColorConstants.secondaryWhiteColor,
borderRadius: BorderRadius.circular(8),
boxShadow: [
BoxShadow(
color: ColorConstants.primaryBlackColor.withOpacity(0.2),
blurRadius: 2,
offset: const Offset(0, 4),
)
]),
child: const Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ShimmerEffect(height: 40, width: 40, radius: 20),
SizedBox(
width: 10,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 5,
),
ShimmerEffect(height: 20, width: 200, radius: 10),
SizedBox(height: 5),
Row(
children: [
Icon(
Icons.calendar_month,
size: 17,
),
SizedBox(
width: 5,
),
ShimmerEffect(height: 15, width: 100, radius: 5)
],
),
SizedBox(
height: 5,
),
ShimmerEffect(height: 30, width: 80, radius: 10)
],
)
],
),
Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
ShimmerEffect(height: 25, width: 60, radius: 10),
],
)
],
),
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/residents
|
mirrored_repositories/Hostel-Manager/lib/fetures/residents/widgets/residents_detailes_card.dart
|
import 'package:cached_network_image/cached_network_image.dart';
import 'package:fluentui_system_icons/fluentui_system_icons.dart';
import 'package:flutter/material.dart';
import 'package:hostel_management_app/commens/widgets/shimmer_loader.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
import 'package:hostel_management_app/utils/text_style_constatnts.dart';
class ResidentsDetailescard extends StatelessWidget {
const ResidentsDetailescard(
{super.key,
required this.name,
required this.joiningDate,
required this.roomNumber,
required this.onTap,
required this.isFeePaid,
required this.image});
final String name;
final String joiningDate;
final int roomNumber;
final String image;
final bool isFeePaid;
final void Function()? onTap;
@override
Widget build(BuildContext context) {
return InkWell(
onTap: onTap,
child: Container(
padding: const EdgeInsets.all(10),
decoration: BoxDecoration(
color: ColorConstants.secondaryWhiteColor,
borderRadius: BorderRadius.circular(8),
boxShadow: [
BoxShadow(
color: ColorConstants.primaryBlackColor.withOpacity(0.2),
blurRadius: 2,
offset: const Offset(0, 4),
)
],
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Hero(
tag: name,
child: Container(
height: 40,
width: 40,
decoration: BoxDecoration(
color: ColorConstants.secondaryColor3,
borderRadius: BorderRadius.circular(100),
),
child: ClipRRect(
borderRadius: BorderRadius.circular(100),
child: image.isNotEmpty
? CachedNetworkImage(
imageUrl: image,
fit: BoxFit.cover,
errorWidget: (context, url, error) =>
const Icon(Icons.error),
progressIndicatorBuilder:
(context, url, progress) =>
const ShimmerEffect(
height: 40, width: 40, radius: 40),
)
: const Center(
child: Icon(Icons.person),
),
),
),
),
const SizedBox(
width: 10,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(
height: 5,
),
Text(
name,
style: TextStyleConstants.dashboardBookingName,
),
const SizedBox(height: 5),
Row(
children: [
const Icon(
Icons.calendar_month,
size: 17,
),
const SizedBox(
width: 5,
),
Text(
"$joiningDate joining",
style: TextStyleConstants.bookingsJoiningDate,
),
],
),
const SizedBox(
height: 5,
),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5),
color: isFeePaid == true
? ColorConstants.colorGreen.withOpacity(0.6)
: ColorConstants.colorRed),
padding: const EdgeInsets.symmetric(
horizontal: 10, vertical: 5),
child: Center(
child: isFeePaid == true
? Text(
"Fees Paid",
style: TextStyleConstants.buttonText,
)
: Text(
"Fees Not Paid",
style: TextStyleConstants.buttonText,
),
),
)
],
)
],
),
Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: ColorConstants.secondaryColor4),
padding:
const EdgeInsets.symmetric(horizontal: 7, vertical: 4),
child: Row(
children: [
Icon(
FluentIcons.conference_room_48_regular,
color: ColorConstants.primaryBlackColor,
size: 27,
),
Text(
roomNumber.toString(),
style: TextStyleConstants.bookingsRoomNumber,
)
],
),
),
const SizedBox(
width: 20,
),
const SizedBox(
height: 5,
),
IconButton(
onPressed: () {},
icon: Icon(
Icons.call,
size: 30,
color: ColorConstants.primaryColor,
),
)
],
)
],
),
),
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/residents
|
mirrored_repositories/Hostel-Manager/lib/fetures/residents/models/resident_model.dart
|
import 'package:cloud_firestore/cloud_firestore.dart';
class ResidentModel {
ResidentModel(
{this.id,
required this.name,
required this.profilePic,
required this.roomNo,
required this.roomId,
required this.phone,
required this.email,
required this.address,
required this.emargencyContact,
required this.purposOfStay,
required this.checkIn,
required this.checkOut,
required this.nextRentDate,
required this.isRentPaid});
final String? id;
final String profilePic;
final String name;
final int roomNo;
final String roomId;
final String phone;
final String email;
final String address;
final String emargencyContact;
final String purposOfStay;
final DateTime checkIn;
final DateTime checkOut;
final DateTime nextRentDate;
final bool isRentPaid;
Map<String, dynamic> toJson() {
return {
"RoomNo": roomNo,
"Name": name,
"ProfilePhoto": profilePic,
"RoomId": roomId,
"Phone": phone,
"Email": email,
"Address": address,
"EmargencyContact": emargencyContact,
"CheckIn": checkIn,
"CheckOut": checkOut,
"NextRentDate": nextRentDate,
"Rentpaid": isRentPaid,
"Purpose": purposOfStay
};
}
factory ResidentModel.fromDocumentSnapshot(
DocumentSnapshot<Map<String, dynamic>> document) {
if (document.data() != null) {
final data = document.data()!;
return ResidentModel(
id: document.id,
name: data["Name"] ?? "",
roomNo: data["RoomNo"] ?? 0,
roomId: data["RoomId"] ?? "",
phone: data["Phone"] ?? "",
email: data["Email"] ?? "",
address: data["Address"] ?? "",
emargencyContact: data["EmargencyContact"] ?? "",
purposOfStay: data["Purpose"] ?? "",
checkIn: (data['CheckIn'] as Timestamp).toDate(),
checkOut: (data['CheckOut'] as Timestamp).toDate(),
nextRentDate: (data['NextRentDate'] as Timestamp).toDate(),
isRentPaid: data["Rentpaid"] ?? false,
profilePic: data["ProfilePhoto"] ?? '');
} else {
return ResidentModel.empty();
}
}
static ResidentModel empty() => ResidentModel(
name: '',
roomNo: 0,
roomId: '',
profilePic: '',
phone: '',
email: '',
address: '',
emargencyContact: '',
purposOfStay: '',
checkIn: DateTime(2000),
checkOut: DateTime(2000),
nextRentDate: DateTime(2000),
isRentPaid: false);
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/residents
|
mirrored_repositories/Hostel-Manager/lib/fetures/residents/screens/residents_adding_form.dart
|
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:hostel_management_app/fetures/residents/controllers/residents_controller.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
import 'package:hostel_management_app/utils/text_style_constatnts.dart';
import 'package:hostel_management_app/commens/widgets/custom_dropdown_button.dart';
import 'package:hostel_management_app/fetures/residents/widgets/custom_formfield.dart';
import 'package:provider/provider.dart';
class ResidentsAddingPage extends StatelessWidget {
const ResidentsAddingPage({super.key});
@override
Widget build(BuildContext context) {
final controller = Provider.of<ResidentsController>(context, listen: false);
const gap = SizedBox(
height: 10,
);
return Container(
padding: const EdgeInsets.all(25),
child: SingleChildScrollView(
child: Form(
key: controller.formKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Center(
child: SizedBox(
height: 100,
width: 100,
child: InkWell(
onTap: () => controller.openImagePicker(),
child: Stack(
children: [
Positioned(
child: Hero(
tag: Form,
child: Consumer<ResidentsController>(
builder: (context, value, child) => CircleAvatar(
radius: 50,
backgroundColor: ColorConstants.secondaryColor4,
backgroundImage: controller.selectedImage != null
? FileImage(
File(controller.selectedImage!.path))
: controller.oldImage != ""
? NetworkImage(controller.oldImage)
as ImageProvider<Object>?
: null,
child: controller.selectedImage == null &&
controller.oldImage == ""
? Icon(
Icons.person,
color: ColorConstants.primaryBlackColor,
size: 40,
)
: null,
),
),
)),
Positioned(
bottom: 3,
right: 3,
child: CircleAvatar(
radius: 13,
backgroundColor: ColorConstants.secondaryColor5,
child: const Icon(Icons.add),
),
)
],
),
),
),
),
gap,
gap,
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text("Room no :"),
Consumer<ResidentsController>(
builder: (context, value, child) => CustomDropdownButton(
selectedValue: controller.selectedRoom!,
items: controller.vacantRoomNoList,
onChanged: (p0) => controller.selectRoom(p0),
height: 50,
width: 100),
),
],
),
gap,
const Text("Name"),
gap,
CustomFormField(
controller: controller.nameController,
validator: (p0) => controller.fieldValidation(p0),
),
gap,
const Text("Phone no"),
gap,
CustomFormField(
controller: controller.phoneNoController,
validator: (p0) => controller.fieldValidation(p0),
),
gap,
const Text(
"Emaile",
),
gap,
CustomFormField(
controller: controller.emailController,
validator: (p0) => controller.fieldValidation(p0),
),
gap,
const Text("Address"),
gap,
CustomFormField(
controller: controller.addressController,
isExpanded: true,
validator: (p0) => controller.fieldValidation(p0),
),
gap,
const Text(
"Emergency Contact no",
),
gap,
CustomFormField(
controller: controller.emargencyContactController,
validator: (p0) => controller.fieldValidation(p0),
),
gap,
const Text("Purpose of Stay"),
gap,
CustomFormField(controller: controller.purposeController),
gap,
const Text(
"Joining date",
),
gap,
CustomFormField(
controller: controller.checkInDateController,
validator: (p0) => controller.fieldValidation(p0),
suffixWidget: InkWell(
onTap: () async {
final date = await showDatePicker(
context: context,
initialDate: DateTime.now(),
firstDate: DateTime(2024),
lastDate: DateTime(2025));
controller.setCheckInDate(date!);
},
child: Icon(
Icons.calendar_month_outlined,
color: ColorConstants.roomsBlackColor,
),
),
),
gap,
const Text("Ending Date (optional)"),
gap,
CustomFormField(
controller: controller.checkOutDateController,
validator: (p0) => controller.fieldValidation(p0),
suffixWidget: InkWell(
onTap: () async {
final date = await showDatePicker(
context: context,
initialDate: controller.checkInDate ?? DateTime(2024),
firstDate: controller.checkInDate ?? DateTime(2024),
lastDate: DateTime(2025));
controller.setCheckOutDate(date!);
},
child: Icon(
Icons.calendar_month_outlined,
color: ColorConstants.roomsBlackColor,
),
)),
gap,
Center(
child: InkWell(
onTap: () {
if (controller.formKey.currentState!.validate()) {
if (controller.isEditing) {
controller.editResident(context);
} else {
controller.addResident(context);
}
}
},
child: Container(
height: 50,
width: 150,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: ColorConstants.primaryColor),
child: Center(
child: Text(
controller.isEditing ? "Edit" : "Add",
style: TextStyleConstants.buttonText,
),
),
),
),
)
],
),
),
),
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/residents
|
mirrored_repositories/Hostel-Manager/lib/fetures/residents/screens/resident_deatailes_screen.dart
|
import 'package:cached_network_image/cached_network_image.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:hostel_management_app/commens/functions/make_phone_call.dart';
import 'package:hostel_management_app/fetures/residents/controllers/residents_controller.dart';
import 'package:hostel_management_app/fetures/residents/models/resident_model.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
import 'package:hostel_management_app/utils/image_constants.dart';
import 'package:hostel_management_app/utils/text_style_constatnts.dart';
import 'package:hostel_management_app/commens/widgets/shimmer_loader.dart';
import 'package:hostel_management_app/fetures/residents/widgets/confirm_delete_dialog.dart';
import 'package:hostel_management_app/fetures/residents/widgets/resident_detailes_card.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
class ResidentDetailesScreen extends StatefulWidget {
const ResidentDetailesScreen({super.key, required this.residentId});
final String residentId;
@override
State<ResidentDetailesScreen> createState() => _ResidentDetailesScreenState();
}
class _ResidentDetailesScreenState extends State<ResidentDetailesScreen> {
late String uid;
late DocumentReference residentReference;
@override
void initState() {
uid = FirebaseAuth.instance.currentUser!.uid;
residentReference = FirebaseFirestore.instance
.collection("Owners")
.doc(uid)
.collection("Residents")
.doc(widget.residentId);
super.initState();
}
@override
Widget build(BuildContext context) {
final controller = Provider.of<ResidentsController>(context, listen: false);
return StreamBuilder(
stream: residentReference.snapshots(),
builder: (context, snapshot) {
// ResidentModel resident = ResidentModel.fromDocumentSnapshot(
// snapshot.data! as DocumentSnapshot<Map<String, dynamic>>);
ResidentModel? resident;
if (snapshot.hasData && snapshot.data != null) {
resident = ResidentModel.fromDocumentSnapshot(
snapshot.data! as DocumentSnapshot<Map<String, dynamic>>);
} else {
// Handle the case where snapshot data is null or not available
return const CircularProgressIndicator(); // or any other appropriate widget
}
return Scaffold(
backgroundColor: ColorConstants.primaryWhiteColor,
appBar: AppBar(
backgroundColor: ColorConstants.primaryWhiteColor,
iconTheme: IconThemeData(color: ColorConstants.primaryBlackColor),
leading: IconButton(
onPressed: () {
Navigator.pop(context);
},
icon: const Icon(
Icons.chevron_left_outlined,
size: 30,
)),
actions: [
PopupMenuButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
),
elevation: 10,
itemBuilder: (context) {
return [
PopupMenuItem(
child: const Text('Edit'),
onTap: () async {
controller.onEdit(resident!, context);
}),
PopupMenuItem(
child: Text(
'Delete',
style: TextStyle(color: ColorConstants.colorRed),
),
onTap: () {
showDialog(
context: context,
builder: (context1) => ConfirmDialog(
title: 'Confirm Delete',
content: 'Are you sure you want to Delelte?',
onPressed: () => controller.deleteResident(
context: context1, resident: resident!),
),
);
Navigator.pop(context);
controller.deleteResident(
context: context, resident: resident!);
},
),
];
},
),
],
elevation: 0,
),
body: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Hero(
tag: resident.name,
child: Container(
height: 110,
width: 110,
decoration: BoxDecoration(
color: ColorConstants.secondaryColor3,
borderRadius: BorderRadius.circular(100),
),
child: ClipRRect(
borderRadius: BorderRadius.circular(100),
child: resident.profilePic.isNotEmpty
? CachedNetworkImage(
imageUrl: resident.profilePic,
fit: BoxFit.cover,
errorWidget: (context, url, error) =>
const Icon(Icons.error),
progressIndicatorBuilder:
(context, url, progress) =>
const ShimmerEffect(
height: 110,
width: 110,
radius: 100),
)
: const Center(
child: Icon(Icons.person),
),
),
),
),
],
),
const SizedBox(
height: 20,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: ColorConstants.secondaryColor4),
padding: const EdgeInsets.symmetric(
horizontal: 7, vertical: 4),
child: Row(
children: [
Image.asset(
ImageConstants.roomsIcon2,
color: ColorConstants.primaryBlackColor,
height: 25,
width: 25,
),
Text(
resident.roomNo.toString(),
style: TextStyleConstants.bookingsRoomNumber,
)
],
),
),
const SizedBox(
width: 20,
),
InkWell(
onTap: () {
if (!resident!.isRentPaid) {
showDialog(
context: context,
builder: (context) => ConfirmDialog(
title: "Confirm Rent Paid",
content: "'Are you sure he/she rent paid",
button2Text: "Yes",
button1Text: "No",
onPressed: () {
controller.editRentPaid(
id: resident!.id!,
currentRentDate:
resident.nextRentDate,
context: context);
},
));
}
},
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5),
color: resident.isRentPaid
? ColorConstants.colorGreen
: ColorConstants.colorRed),
padding: const EdgeInsets.symmetric(
horizontal: 10, vertical: 7),
child: Center(
child: Text(
resident.isRentPaid ? "Fees Paid" : "Fees Not Paid",
style: TextStyleConstants.buttonText,
)),
),
)
],
),
const SizedBox(
height: 20,
),
DetailesCard(
tiltle: 'Name',
data: resident.name,
),
const Text("Phone Number"),
const SizedBox(
height: 5,
),
Container(
padding: const EdgeInsets.all(10),
width: double.infinity,
decoration: BoxDecoration(
color: ColorConstants.secondaryColor2.withOpacity(0.1),
borderRadius: BorderRadius.circular(10)),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
resident.phone,
style: TextStyleConstants.dashboardBookingName,
),
InkWell(
onTap: () {
makePhoneCall(resident!.phone, context);
},
child: const Icon(
Icons.call,
size: 28,
),
)
],
),
),
const SizedBox(
height: 20,
),
DetailesCard(
tiltle: 'Email',
data: resident.email,
),
DetailesCard(
tiltle: 'Address',
data: resident.address,
),
DetailesCard(
tiltle: 'Purpose of Stay',
data: resident.purposOfStay,
),
const Text("Eemergency Contact Number"),
const SizedBox(
height: 5,
),
Container(
padding: const EdgeInsets.all(10),
width: double.infinity,
decoration: BoxDecoration(
color: ColorConstants.secondaryColor2.withOpacity(0.1),
borderRadius: BorderRadius.circular(10)),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
resident.emargencyContact,
style: TextStyleConstants.dashboardBookingName,
),
InkWell(
onTap: () {
makePhoneCall(resident!.emargencyContact, context);
},
child: const Icon(
Icons.call,
size: 28,
),
)
],
),
),
const SizedBox(
height: 20,
),
DetailesCard(
tiltle: 'CheckOut Date',
data: DateFormat('dd/MM/yyyy').format(resident.checkIn),
),
DetailesCard(
tiltle: 'CheckOut Date',
data: DateFormat('dd/MM/yyyy').format(resident.checkOut),
),
],
),
),
),
);
},
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/residents
|
mirrored_repositories/Hostel-Manager/lib/fetures/residents/screens/residents_page.dart
|
// ignore_for_file: use_build_context_synchronously
import 'package:flutter/material.dart';
import 'package:hostel_management_app/commens/widgets/custom_dropdown_button.dart';
import 'package:hostel_management_app/fetures/residents/controllers/residents_controller.dart';
import 'package:hostel_management_app/fetures/residents/models/resident_model.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
import 'package:hostel_management_app/utils/image_constants.dart';
import 'package:hostel_management_app/utils/text_style_constatnts.dart';
import 'package:hostel_management_app/fetures/residents/widgets/resident_loading_card.dart';
import 'package:hostel_management_app/fetures/residents/screens/resident_deatailes_screen.dart';
import 'package:hostel_management_app/fetures/residents/screens/residents_adding_form.dart';
import 'package:hostel_management_app/fetures/residents/widgets/residents_detailes_card.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
class ResidentsPage extends StatefulWidget {
const ResidentsPage({super.key});
@override
State<ResidentsPage> createState() => _ResidentsPageState();
}
class _ResidentsPageState extends State<ResidentsPage> {
@override
void initState() {
Provider.of<ResidentsController>(context, listen: false).fetchResidents();
super.initState();
}
@override
Widget build(BuildContext context) {
final controller = Provider.of<ResidentsController>(context, listen: false);
return Scaffold(
backgroundColor: ColorConstants.primaryWhiteColor,
appBar: AppBar(
title: Text(
"Residents Detailes",
style: TextStyleConstants.homeMainTitle2,
),
backgroundColor: ColorConstants.primaryWhiteColor,
elevation: 0,
leadingWidth: 10,
),
body: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Consumer<ResidentsController>(
builder: (context, value, child) => CustomDropdownButton(
selectedValue: value.selctedFilter,
items: value.filters,
onChanged: (p0) => value.selectFilter(p0),
height: 50,
width: MediaQuery.sizeOf(context).width * 0.4),
)
],
),
const SizedBox(
height: 20,
),
Consumer<ResidentsController>(
builder: (context, value, child) => value.isResidentsLoading
? ListView.separated(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemBuilder: (context, index) {
return const ResidentsLoadingCard();
},
separatorBuilder: (context, index) => Divider(
color: ColorConstants.secondaryWhiteColor,
height: 10,
),
itemCount: controller.residents.isEmpty
? 10
: controller.residents.length)
: value.residents.isEmpty
? Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Center(
child:
Image.asset(ImageConstants.emptyListImage),
),
const SizedBox(
height: 30,
),
const Text("Residents List is Empty !")
],
)
: ListView.separated(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemBuilder: (context, index) {
ResidentModel resident =
controller.residents[index];
return ResidentsDetailescard(
roomNumber: resident.roomNo,
joiningDate: DateFormat('dd MMM yyyy')
.format(resident.checkIn),
name: resident.name,
isFeePaid: resident.isRentPaid,
image: resident.profilePic,
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
ResidentDetailesScreen(
residentId: resident.id!,
),
),
);
},
);
},
separatorBuilder: (context, index) => Divider(
color: ColorConstants.secondaryWhiteColor,
height: 10,
),
itemCount: value.residents.length),
)
],
),
),
),
floatingActionButton: FloatingActionButton(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)),
onPressed: () async {
await Provider.of<ResidentsController>(context, listen: false)
.fetchVacantRooms();
if (controller.vacantRoomNoList.isEmpty) {
showDialog(
context: context,
builder: (context) =>
const AlertDialog(title: Text("No Vacant Rooms Available !")),
);
} else {
showModalBottomSheet(
isScrollControlled: true,
context: context,
builder: (context) => Padding(
padding: EdgeInsets.only(
bottom: MediaQuery.of(context).viewInsets.bottom),
child: const ResidentsAddingPage(),
),
elevation: 10,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
),
useSafeArea: true,
);
}
},
backgroundColor: ColorConstants.primaryWhiteColor,
elevation: 50,
child: Icon(
Icons.person_add_alt_1,
color: ColorConstants.primaryColor,
),
),
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/payments
|
mirrored_repositories/Hostel-Manager/lib/fetures/payments/widgets/pyment_name_card.dart
|
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:hostel_management_app/commens/widgets/shimmer_loader.dart';
import 'package:hostel_management_app/fetures/residents/models/resident_model.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
import 'package:hostel_management_app/utils/image_constants.dart';
import 'package:hostel_management_app/utils/text_style_constatnts.dart';
import 'package:hostel_management_app/fetures/residents/screens/resident_deatailes_screen.dart';
class PaymentNameCard extends StatelessWidget {
const PaymentNameCard(
{super.key,
required this.name,
required this.date,
required this.rentAmount,
required this.resident});
final String name;
final String date;
final String rentAmount;
final ResidentModel resident;
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.only(bottom: 10),
child: InkWell(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ResidentDetailesScreen(
residentId: resident.id!,
),
),
);
},
child: Container(
width: double.infinity,
padding: const EdgeInsets.all(10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: ColorConstants.primaryWhiteColor),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Hero(
tag: name,
child: Container(
height: 30,
width: 30,
decoration: BoxDecoration(
color: ColorConstants.secondaryColor3,
borderRadius: BorderRadius.circular(100),
),
child: ClipRRect(
borderRadius: BorderRadius.circular(100),
child: resident.profilePic.isNotEmpty
? CachedNetworkImage(
imageUrl: resident.profilePic,
fit: BoxFit.cover,
errorWidget: (context, url, error) =>
const Icon(Icons.error),
progressIndicatorBuilder:
(context, url, progress) =>
const ShimmerEffect(
height: 30, width: 30, radius: 30),
)
: const Center(
child: Icon(Icons.person),
),
),
),
),
const SizedBox(
width: 10,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
name,
style: TextStyleConstants.dashboardBookingName,
),
const SizedBox(
height: 5,
),
Row(
children: [
Image.asset(
ImageConstants.calenderIcon,
),
Text(
"$date due",
style: TextStyleConstants.dashboardPendingDue,
),
],
),
],
),
],
),
Row(
children: [
SizedBox(
height: 18,
width: 9,
child: Image.asset(
ImageConstants.moneyIcon,
color: ColorConstants.primaryColor,
)),
const SizedBox(
width: 4,
),
Text(rentAmount,
style: TextStyleConstants.dashboardBookinRoomNo),
],
),
],
),
),
),
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/payments
|
mirrored_repositories/Hostel-Manager/lib/fetures/payments/widgets/pending_payments_detailes_card.dart
|
import 'package:flutter/material.dart';
import 'package:hostel_management_app/fetures/residents/models/resident_model.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
import 'package:hostel_management_app/utils/image_constants.dart';
import 'package:hostel_management_app/utils/text_style_constatnts.dart';
import 'package:hostel_management_app/fetures/payments/widgets/pyment_name_card.dart';
import 'package:intl/intl.dart';
class PendingPaymentDetailesCard extends StatelessWidget {
const PendingPaymentDetailesCard(
{super.key,
required this.roomNo,
required this.residents,
required this.totalAmount});
final String roomNo;
final int totalAmount;
final List<ResidentModel> residents;
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.all(15),
width: double.infinity,
decoration: BoxDecoration(
color: ColorConstants.secondaryColor3,
borderRadius: BorderRadius.circular(15)),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: ColorConstants.secondaryColor1),
padding: const EdgeInsets.symmetric(horizontal: 7, vertical: 4),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Image.asset(
ImageConstants.roomsIcon2,
color: ColorConstants.primaryBlackColor,
height: 25,
width: 25,
),
Text(
"Room No ",
style: TextStyleConstants.bookingsRoomNumber,
),
Text(
roomNo,
style: TextStyleConstants.bookingsRoomNumber,
)
],
),
),
Padding(
padding: const EdgeInsets.only(top: 10, left: 10),
child: Column(
children: List.generate(
residents.length,
(index) => PaymentNameCard(
name: residents[index].name,
date: DateFormat('dd MMM')
.format(residents[index].nextRentDate),
rentAmount: (totalAmount / residents.length).toString(),
resident: residents[index],
)),
),
)
],
),
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/payments
|
mirrored_repositories/Hostel-Manager/lib/fetures/payments/screens/pending_payments_screen.dart
|
import 'package:flutter/material.dart';
import 'package:hostel_management_app/fetures/dashboard/controllers/dashboard_controller.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
import 'package:hostel_management_app/utils/image_constants.dart';
import 'package:hostel_management_app/utils/text_style_constatnts.dart';
import 'package:hostel_management_app/fetures/payments/widgets/pending_payments_detailes_card.dart';
import 'package:provider/provider.dart';
class PendingPaymentsScreen extends StatelessWidget {
const PendingPaymentsScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: ColorConstants.primaryWhiteColor,
appBar: AppBar(
title: Hero(
tag: Title,
child: Text(
"Pending Payments",
style: TextStyleConstants.homeMainTitle2,
),
),
leading: IconButton(
onPressed: () {
Navigator.pop(context);
},
icon: Icon(
Icons.arrow_back_ios_new,
color: ColorConstants.primaryColor,
)),
backgroundColor: ColorConstants.primaryWhiteColor,
elevation: 0,
),
body: Consumer<DashboardController>(
builder: (context, value, child) => Padding(
padding: const EdgeInsets.all(20.0),
child: SingleChildScrollView(
child: Column(
children: [
ListView.separated(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemBuilder: (context, index) => PendingPaymentDetailesCard(
roomNo:
value.pendingPayments[index]["RoomNo"].toString(),
residents: value.pendingPayments[index]["Residents"],
totalAmount: value.pendingPayments[index]
["TotalAmount"],
),
separatorBuilder: (context, index) => const Divider(
height: 10,
),
itemCount: value.pendingPayments.length),
const SizedBox(
height: 10,
),
Container(
padding: const EdgeInsets.all(15),
width: double.infinity,
decoration: BoxDecoration(
color: ColorConstants.secondaryColor3,
borderRadius: BorderRadius.circular(15)),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Total :",
style: TextStyleConstants.upComingVaccencyText2,
),
Row(
children: [
SizedBox(
height: 30,
width: 15,
child: Image.asset(
ImageConstants.moneyIcon,
color: ColorConstants.primaryBlackColor,
)),
const SizedBox(
width: 4,
),
Text(
value.totalPentingAmount.toString(),
style: TextStyleConstants.upComingVaccencyText2,
),
],
),
],
),
)
],
),
),
),
),
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/dashboard
|
mirrored_repositories/Hostel-Manager/lib/fetures/dashboard/controllers/dashboard_controller.dart
|
// ignore_for_file: avoid_print
import 'package:flutter/material.dart';
import 'package:hostel_management_app/fetures/residents/controllers/residents_repository.dart';
import 'package:hostel_management_app/fetures/profile/controllers/user_repository.dart';
import 'package:hostel_management_app/fetures/profile/models/owner_model.dart';
import 'package:hostel_management_app/fetures/residents/models/resident_model.dart';
import 'package:hostel_management_app/fetures/rooms/controllers/rooms_repository.dart';
import 'package:hostel_management_app/fetures/rooms/models/room_model.dart';
import 'package:intl/intl.dart';
class DashboardController with ChangeNotifier {
OwnerModel? user = OwnerModel.empty();
List<Map<String, int>> roomsGoingtoVacant = [];
String selectedValue = "This Week";
int selectedDays = 7;
List<String> sortingItems = ["This Week", "This Month", "This Year"];
bool isFilterLoading = false;
bool isPaymentsLoading = false;
List<ResidentModel> allResidents = [];
List<ResidentModel> rentPendingResidents = [];
List<ResidentModel> paymentDueResidents = [];
List<Map<String, dynamic>> pendingPayments = [];
int totalPentingAmount = 0;
final UserRepository controller = UserRepository();
final ResidentsRepository residentsRepository = ResidentsRepository();
final roomController = RoomsRepository();
//------------------------------------------------------------------------------Fetch data
fetchData() async {
try {
isFilterLoading = true;
final currentUser = await controller.fetchOwnerRecords();
allResidents = await residentsRepository.fetchData();
user = currentUser;
notifyListeners();
getVacatingRooms();
await updatePendingPayments();
isFilterLoading = false;
notifyListeners();
} catch (e) {
user = OwnerModel.empty();
notifyListeners();
print(e);
}
}
//------------------------------------------------------------------------------Fetch vacating Rooms
getVacatingRooms() async {
try {
isFilterLoading = true;
// Get the current date and time
final currentDate = DateTime.now();
// Filter bookings with check-in date within this week
final thisWeekVaccating = allResidents.where((resident) {
final daysDifference = resident.checkOut.difference(currentDate).inDays;
return daysDifference < selectedDays;
}).toList();
roomsGoingtoVacant = getVacancyCount(thisWeekVaccating);
notifyListeners();
} catch (e) {
print(e);
} finally {
isFilterLoading = false;
notifyListeners();
}
}
//------------------------------------------------------------------------------Update Pending payments
updatePendingPayments() async {
try {
isPaymentsLoading = true;
paymentDueResidents.clear();
rentPendingResidents.clear();
pendingPayments.clear();
totalPentingAmount = 0;
final currentDate = DateTime.now();
paymentDueResidents = allResidents
.where((resident) =>
currentDate.isAfter(resident.nextRentDate) ||
currentDate.isAtSameMomentAs(resident.nextRentDate))
.toList();
if (paymentDueResidents.isNotEmpty) {
Map<String, dynamic> json = {'Rentpaid': false};
for (int i = 0; i < paymentDueResidents.length; i++) {
await residentsRepository.updateSingleField(
paymentDueResidents[i].id!, json);
}
for (ResidentModel resident in allResidents) {
if (resident.isRentPaid == false) {
rentPendingResidents.add(resident);
}
}
pendingPayments =
await convertResidentsListToMapList(rentPendingResidents);
isFilterLoading = false;
notifyListeners();
}
} catch (e) {
print('Error fetching residents data: $e');
} finally {
isPaymentsLoading = false;
}
}
//------------------------------------------------------------------------------get Vacancy Count
List<Map<String, int>> getVacancyCount(
List<ResidentModel> vacatingResidents) {
Map<int, int> roomCountMap = {};
// Count the number of residents vacating each room
for (ResidentModel resident in vacatingResidents) {
int roomNo = resident.roomNo;
roomCountMap.update(roomNo, (value) => value + 1, ifAbsent: () => 1);
}
// Convert the roomCountMap to the desired format
List<Map<String, int>> result = roomCountMap.entries.map((entry) {
return {"RoomNo": entry.key, "Vacancy": entry.value};
}).toList();
return result;
}
//----------------------------------------------------------------------------Convert rent pending residents to map
Future<List<Map<String, dynamic>>> convertResidentsListToMapList(
List<ResidentModel> residentsList,
) async {
Map<int, List<ResidentModel>> residentsMap = {};
for (var resident in residentsList) {
if (!residentsMap.containsKey(resident.roomNo)) {
residentsMap[resident.roomNo] = [];
}
residentsMap[resident.roomNo]!.add(resident);
}
List<Map<String, dynamic>> resultList = [];
for (var entry in residentsMap.entries) {
int roomNo = entry.key;
List<ResidentModel> residents = entry.value;
RoomModel roomModel =
await roomController.getRoomByRoomNo(roomNo) ?? RoomModel.empty();
int totalAmount = roomModel.rent * residents.length;
totalPentingAmount = totalPentingAmount + totalAmount;
resultList.add({
"RoomNo": roomNo,
"Residents": residents,
"TotalAmount": totalAmount,
});
}
return resultList;
}
selectFilter(filter) async {
selectedValue = filter;
notifyListeners();
if (selectedValue == "This Week") {
selectedDays = 7;
notifyListeners();
} else if (selectedValue == "This Month") {
selectedDays = 30;
notifyListeners();
} else if (selectedValue == "This Year") {
selectedDays = 365;
notifyListeners();
}
await getVacatingRooms();
}
String date() {
return DateFormat('dd/MM/yyyy').format(DateTime.now());
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/dashboard
|
mirrored_repositories/Hostel-Manager/lib/fetures/dashboard/widgets/vacant_rooms_loading.dart
|
import 'package:flutter/material.dart';
import 'package:hostel_management_app/commens/widgets/shimmer_loader.dart';
class VaccentLoadingCard extends StatelessWidget {
const VaccentLoadingCard({
super.key,
});
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 7),
child: const Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
ShimmerEffect(height: 30, width: 30, radius: 15),
ShimmerEffect(height: 25, width: 100, radius: 20)
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
ShimmerEffect(height: 30, width: 30, radius: 15),
ShimmerEffect(height: 25, width: 100, radius: 20),
],
),
],
),
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/dashboard
|
mirrored_repositories/Hostel-Manager/lib/fetures/dashboard/widgets/upcoming_bookings_card.dart
|
import 'package:fluentui_system_icons/fluentui_system_icons.dart';
import 'package:flutter/material.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
import 'package:hostel_management_app/utils/text_style_constatnts.dart';
class UpcomingBookings extends StatelessWidget {
const UpcomingBookings(
{super.key,
required this.name,
required this.date,
required this.roomNumber,
required this.beadNumber,
required this.isAdvacePaid,
this.onTap});
final String name;
final String date;
final String roomNumber;
final String beadNumber;
final bool isAdvacePaid;
final void Function()? onTap;
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.only(right: 20, bottom: 10, left: 10),
child: InkWell(
onTap: onTap,
child: Container(
width: 277,
padding: const EdgeInsets.symmetric(vertical: 14, horizontal: 20),
decoration: BoxDecoration(
color: ColorConstants.primaryWhiteColor,
borderRadius: BorderRadius.circular(10),
boxShadow: [
BoxShadow(
color: ColorConstants.primaryBlackColor.withOpacity(0.3),
blurRadius: 1,
offset: const Offset(0, 2), // Offset for the bottom shadow
),
]),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
CircleAvatar(
radius: 18,
backgroundColor: ColorConstants.secondaryColor3,
child: Icon(
FluentIcons.book_contacts_32_regular,
color: ColorConstants.primaryWhiteColor,
size: 26,
),
),
const SizedBox(
width: 15,
),
Text(
name,
style: TextStyleConstants.dashboardBookingName,
)
],
),
Text(
date,
style: TextStyleConstants.dashboardDate,
)
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
children: [
Icon(
FluentIcons.conference_room_16_regular,
color: ColorConstants.primaryBlackColor,
size: 26,
),
Text(
roomNumber,
style: TextStyleConstants.dashboardBookinRoomNo,
),
const Text("Room")
],
),
Column(
children: [
Icon(
FluentIcons.bed_24_regular,
color: ColorConstants.primaryBlackColor,
size: 26,
),
Text(
beadNumber,
style: TextStyleConstants.dashboardBookinRoomNo,
),
const Text("Bead")
],
),
Column(
children: [
Icon(
isAdvacePaid
? FluentIcons.phone_checkmark_20_regular
: FluentIcons.phone_dismiss_20_regular,
color: ColorConstants.primaryBlackColor,
size: 26,
),
Text(
isAdvacePaid ? "Paid" : "Not Paid",
style: TextStyleConstants.dashboardBookinRoomNo,
),
const Text("Advance")
],
)
],
)
],
),
),
),
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/dashboard
|
mirrored_repositories/Hostel-Manager/lib/fetures/dashboard/widgets/pending_payment_card.dart
|
import 'package:fluentui_system_icons/fluentui_system_icons.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:hostel_management_app/fetures/residents/models/resident_model.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
import 'package:hostel_management_app/utils/image_constants.dart';
import 'package:hostel_management_app/utils/text_style_constatnts.dart';
import 'package:hostel_management_app/fetures/payments/screens/pending_payments_screen.dart';
class PendingPaymentCard extends StatelessWidget {
const PendingPaymentCard({
super.key,
required this.roomNumber,
required this.date,
required this.amount,
required this.residents,
});
final String roomNumber;
final String date;
final String amount;
final List<ResidentModel> residents;
@override
Widget build(BuildContext context) {
return InkWell(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const PendingPaymentsScreen(),
));
},
child: SizedBox(
height: 106,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
CircleAvatar(
radius: 19,
backgroundColor: ColorConstants.secondaryColor4,
child: Icon(
FluentIcons.door_28_regular,
color: ColorConstants.primaryBlackColor,
size: 26,
),
),
const SizedBox(
width: 10,
),
Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Text(
"Room No $roomNumber",
style: TextStyleConstants.dashboardBookingName,
),
Row(
children: [
Image.asset(
ImageConstants.calenderIcon,
),
Text(
"$date due",
style: TextStyleConstants.dashboardPendingDue,
),
],
),
SizedBox(
height: 24,
width: 60,
child: Stack(
children: [
Positioned(
left: 0,
child: CircleAvatar(
radius: 12,
backgroundImage: residents[0].profilePic == ""
? null
: NetworkImage(residents[0].profilePic),
)),
residents.length > 1
? Positioned(
left: 15,
child: CircleAvatar(
radius: 12,
backgroundImage: residents[1].profilePic ==
""
? null
: NetworkImage(residents[1].profilePic),
))
: residents.length > 2
? Positioned(
right: 0,
bottom: 4,
child: Text("+${residents.length - 2}"),
)
: const SizedBox()
],
),
)
],
)
],
),
Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Row(
children: [
FaIcon(
FontAwesomeIcons.indianRupeeSign,
color: ColorConstants.primaryBlackColor,
size: 20,
),
const SizedBox(
width: 10,
),
Text(
amount,
style: TextStyleConstants.dashboardPendingMoney,
)
],
),
Image.asset(
ImageConstants.upRightArrowIcon,
color: ColorConstants.primaryBlackColor,
)
],
)
],
),
),
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/dashboard
|
mirrored_repositories/Hostel-Manager/lib/fetures/dashboard/widgets/rooms_vaccent_card.dart
|
import 'package:flutter/material.dart';
import 'package:hostel_management_app/commens/widgets/shimmer_loader.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
import 'package:hostel_management_app/utils/text_style_constatnts.dart';
class RoomVaccentCard extends StatelessWidget {
const RoomVaccentCard(
{super.key,
required this.title,
required this.number,
required this.bgColor,
required this.icon,
required this.onTap,
this.isLoading = false});
final String title;
final String number;
final Color bgColor;
final Icon icon;
final void Function()? onTap;
final bool isLoading;
@override
Widget build(BuildContext context) {
return InkWell(
onTap: onTap,
child: Container(
height: MediaQuery.sizeOf(context).height * 17 / 100,
width: MediaQuery.sizeOf(context).width * 36 / 100,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15), color: bgColor),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
CircleAvatar(
radius: 17.5,
backgroundColor: ColorConstants.primaryWhiteColor,
child: icon,
),
isLoading
? const ShimmerEffect(height: 40, width: 35, radius: 35)
: Text(
number,
style: TextStyleConstants.ownerRoomNumber3,
),
Hero(
tag: title,
child:
Text(title, style: TextStyleConstants.dashboardVacentRoom2))
],
),
),
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/dashboard
|
mirrored_repositories/Hostel-Manager/lib/fetures/dashboard/widgets/pending_loading_card.dart
|
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:hostel_management_app/commens/widgets/shimmer_loader.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
import 'package:hostel_management_app/utils/image_constants.dart';
import 'package:hostel_management_app/fetures/payments/screens/pending_payments_screen.dart';
class PendingLoadingCard extends StatelessWidget {
const PendingLoadingCard({
super.key,
});
@override
Widget build(BuildContext context) {
return InkWell(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const PendingPaymentsScreen(),
));
},
child: SizedBox(
height: 106,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const ShimmerEffect(height: 38, width: 38, radius: 38),
const SizedBox(
width: 10,
),
Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
const ShimmerEffect(height: 35, width: 150, radius: 20),
Row(
children: [
Image.asset(
ImageConstants.calenderIcon,
),
const ShimmerEffect(height: 25, width: 100, radius: 20),
],
),
],
)
],
),
Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Row(
children: [
FaIcon(
FontAwesomeIcons.indianRupeeSign,
color: ColorConstants.primaryBlackColor,
size: 20,
),
const SizedBox(
width: 10,
),
const ShimmerEffect(height: 30, width: 100, radius: 20),
],
),
],
)
],
),
),
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/dashboard
|
mirrored_repositories/Hostel-Manager/lib/fetures/dashboard/widgets/date_card.dart
|
import 'package:flutter/material.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
import 'package:hostel_management_app/utils/image_constants.dart';
import 'package:hostel_management_app/utils/text_style_constatnts.dart';
class DateCard extends StatelessWidget {
const DateCard({super.key, required this.date});
final String date;
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 12.5, vertical: 10),
decoration: BoxDecoration(
color: ColorConstants.primaryWhiteColor,
borderRadius: BorderRadius.circular(10),
boxShadow: [
BoxShadow(
color: ColorConstants.primaryBlackColor.withOpacity(0.3),
blurRadius: 1,
offset: const Offset(0, 2),
),
]),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Image.asset(ImageConstants.calenderIcon),
Text(
date,
style: TextStyleConstants.dashboardDate,
)
],
),
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/dashboard
|
mirrored_repositories/Hostel-Manager/lib/fetures/dashboard/widgets/going_to_vaccent_card.dart
|
import 'package:fluentui_system_icons/fluentui_system_icons.dart';
import 'package:flutter/material.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
import 'package:hostel_management_app/utils/text_style_constatnts.dart';
class GoingToVaccentCard extends StatelessWidget {
const GoingToVaccentCard(
{super.key,
required this.roomNumber,
required this.beadNumber,
required this.backgroungColor});
final String roomNumber;
final String beadNumber;
final Color backgroungColor;
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),
color: backgroungColor,
),
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 7),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
CircleAvatar(
radius: 15,
backgroundColor: ColorConstants.primaryWhiteColor,
child: Icon(
FluentIcons.conference_room_16_regular,
color: ColorConstants.primaryBlackColor,
),
),
Text(
"Room No",
style: TextStyleConstants.upComingVaccencyText1,
),
Text(
roomNumber,
style: TextStyleConstants.upComingVaccencyText2,
)
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
CircleAvatar(
radius: 15,
backgroundColor: ColorConstants.primaryWhiteColor,
child: Icon(
FluentIcons.bed_24_regular,
color: ColorConstants.primaryBlackColor,
size: 22,
),
),
Text(
"Vacancy",
style: TextStyleConstants.upComingVaccencyText1,
),
Text(
beadNumber,
style: TextStyleConstants.upComingVaccencyText2,
)
],
),
],
),
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/dashboard
|
mirrored_repositories/Hostel-Manager/lib/fetures/dashboard/screens/vacant_beds_screen.dart
|
import 'package:flutter/material.dart';
import 'package:hostel_management_app/fetures/profile/controllers/user_controller.dart';
import 'package:hostel_management_app/fetures/rooms/controllers/rooms_controller.dart';
import 'package:hostel_management_app/fetures/rooms/models/room_model.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
import 'package:hostel_management_app/utils/text_style_constatnts.dart';
import 'package:hostel_management_app/commens/widgets/room_card.dart';
import 'package:hostel_management_app/fetures/rooms/screens/room_detailes_screen.dart';
import 'package:provider/provider.dart';
class VacantBedsScreen extends StatefulWidget {
const VacantBedsScreen({super.key});
@override
State<VacantBedsScreen> createState() => _VacantBedsScreenState();
}
class _VacantBedsScreenState extends State<VacantBedsScreen> {
@override
void initState() {
Provider.of<RoomsController>(context, listen: false).fetchVacantRooms();
Provider.of<UserController>(context, listen: false).fetchData();
super.initState();
}
@override
Widget build(BuildContext context) {
final controller = Provider.of<RoomsController>(context);
final userController = Provider.of<UserController>(context);
return Scaffold(
backgroundColor: ColorConstants.primaryWhiteColor,
appBar: AppBar(
title: Text(
"Vacant beds",
style: TextStyleConstants.homeMainTitle2,
),
leading: IconButton(
onPressed: () {
Navigator.pop(context);
},
icon: Icon(
Icons.arrow_back_ios_new,
color: ColorConstants.primaryColor,
)),
backgroundColor: ColorConstants.primaryWhiteColor,
elevation: 0,
),
body: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: SingleChildScrollView(
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Column(
children: [
Text(
'Total Beds',
style: TextStyleConstants.ownerRoomsText2,
),
const SizedBox(
height: 10,
),
CircleAvatar(
radius: 15,
backgroundColor: ColorConstants.roomsCircleAvatarColor,
child: Text(
userController.user?.noOfBeds.toString() ?? "",
style: TextStyleConstants.ownerRoomsCircleAvtarText,
),
)
],
),
const SizedBox(
width: 20,
),
Column(
children: [
Text(
' Beds vaccent',
style: TextStyleConstants.ownerRoomsText2,
),
const SizedBox(
height: 10,
),
CircleAvatar(
radius: 15,
backgroundColor: ColorConstants.primaryColor,
child: Text(
userController.user?.noOfVacancy.toString() ?? "",
style: TextStyleConstants.ownerRoomsCircleAvtarText,
),
)
],
)
],
),
const SizedBox(
height: 30,
),
controller.vacantRooms.isNotEmpty
? GridView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
padding: const EdgeInsets.only(bottom: 10, left: 10),
itemCount: controller.vacantRooms.length,
gridDelegate:
const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
crossAxisSpacing: 0,
mainAxisSpacing: 20,
mainAxisExtent: 90,
),
itemBuilder: (context, index) {
final RoomModel room = controller.vacantRooms[index];
return RoomsCard(
roomNumber: room.roomNo.toString(),
vaccentBedNumber: room.vacancy.toString(),
onTap: () {
showAdaptiveDialog(
context: context,
builder: (context) => RoomsViewScreen(
roomDetailes: room,
index: index,
isVacantRoom: true,
),
barrierColor: Colors.transparent);
},
);
},
)
: const Center(
child: Text("No Available Vacancies"),
)
],
),
),
),
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/dashboard
|
mirrored_repositories/Hostel-Manager/lib/fetures/dashboard/screens/dashboard_page.dart
|
import 'package:cached_network_image/cached_network_image.dart';
import 'package:fluentui_system_icons/fluentui_system_icons.dart';
import 'package:flutter/material.dart';
import 'package:hostel_management_app/commens/widgets/shimmer_loader.dart';
import 'package:hostel_management_app/fetures/bookings/controllers/bookings_controller.dart';
import 'package:hostel_management_app/fetures/dashboard/controllers/dashboard_controller.dart';
import 'package:hostel_management_app/fetures/dashboard/widgets/pending_loading_card.dart';
import 'package:hostel_management_app/fetures/profile/controllers/user_controller.dart';
import 'package:hostel_management_app/fetures/bookings/models/booking_model.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
import 'package:hostel_management_app/utils/text_style_constatnts.dart';
import 'package:hostel_management_app/fetures/payments/screens/pending_payments_screen.dart';
import 'package:hostel_management_app/fetures/bookings/screens/booked_resident_detailes_screen.dart';
import 'package:hostel_management_app/commens/widgets/custom_dropdown_button.dart';
import 'package:hostel_management_app/fetures/dashboard/widgets/date_card.dart';
import 'package:hostel_management_app/fetures/dashboard/widgets/going_to_vaccent_card.dart';
import 'package:hostel_management_app/fetures/dashboard/widgets/pending_payment_card.dart';
import 'package:hostel_management_app/fetures/dashboard/widgets/rooms_vaccent_card.dart';
import 'package:hostel_management_app/fetures/dashboard/widgets/upcoming_bookings_card.dart';
import 'package:hostel_management_app/fetures/profile/screens/profile_screen.dart';
import 'package:hostel_management_app/fetures/dashboard/screens/vacant_beds_screen.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
class DashBoardPage extends StatefulWidget {
const DashBoardPage({super.key});
@override
State<DashBoardPage> createState() => _DashBoardPageState();
}
class _DashBoardPageState extends State<DashBoardPage>
with TickerProviderStateMixin {
final con = DashboardController();
late AnimationController _controller1;
late Animation<Offset> _animation1;
late AnimationController _controller2;
late Animation<Offset> _animation2;
@override
void initState() {
Provider.of<UserController>(context, listen: false).fetchData();
Provider.of<BookingsController>(context, listen: false).fetchBookingsData();
Provider.of<DashboardController>(context, listen: false).fetchData();
super.initState();
_controller1 = AnimationController(
vsync: this,
duration: const Duration(milliseconds: 400),
);
_controller2 = AnimationController(
vsync: this,
duration: const Duration(milliseconds: 400),
);
_animation1 = Tween<Offset>(
begin: const Offset(-1.0, 0.0),
end: Offset.zero,
).animate(CurvedAnimation(
parent: _controller1,
curve: Curves.easeInOut,
));
_animation2 = Tween<Offset>(
begin: const Offset(1.0, 0.0),
end: Offset.zero,
).animate(CurvedAnimation(
parent: _controller2,
curve: Curves.easeInOut,
));
_controller1.forward();
_controller2.forward();
}
@override
Widget build(BuildContext context) {
final controller = Provider.of<UserController>(context);
final bookingsController = Provider.of<BookingsController>(context);
final dashboardController =
Provider.of<DashboardController>(context, listen: false);
return Scaffold(
backgroundColor: ColorConstants.primaryWhiteColor,
appBar: AppBar(
automaticallyImplyLeading: false,
backgroundColor: ColorConstants.primaryWhiteColor,
elevation: 0,
title: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Consumer(
builder: (context, value, child) => Text(
"Welcom Back,",
style: TextStyleConstants.homeMainTitle1,
),
),
const SizedBox(
height: 5,
),
SizedBox(
width: MediaQuery.sizeOf(context).width - 100,
child: Text(
controller.user!.ownwerName,
overflow: TextOverflow.ellipsis,
style: TextStyleConstants.homeMainTitle2,
),
)
],
),
actions: [
InkWell(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const ProfileScreen(),
),
);
},
child: Hero(
tag: "profile",
child: Container(
height: 40,
width: 40,
decoration: BoxDecoration(
color: ColorConstants.secondaryColor3,
borderRadius: BorderRadius.circular(100),
),
child: ClipRRect(
borderRadius: BorderRadius.circular(100),
child: controller.user!.profilePictuer.isNotEmpty
? CachedNetworkImage(
imageUrl: controller.user!.profilePictuer,
fit: BoxFit.cover,
errorWidget: (context, url, error) =>
const Icon(Icons.error),
progressIndicatorBuilder: (context, url, progress) =>
const ShimmerEffect(
height: 40, width: 40, radius: 40),
)
: const Center(
child: Icon(Icons.person),
),
),
),
),
),
const SizedBox(
width: 30,
),
],
),
body: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(
height: 10,
),
Padding(
padding: EdgeInsets.symmetric(
horizontal: MediaQuery.sizeOf(context).width * 11 / 100),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Consumer<UserController>(
builder: (context, value, child) => SlideTransition(
position: _animation1,
child: RoomVaccentCard(
title: "Beds Vacantnt",
number: value.user?.noOfVacancy.toString() ?? "",
bgColor: ColorConstants.primaryColor,
icon: Icon(
FluentIcons.bed_20_regular,
color: ColorConstants.primaryBlackColor,
size: 26,
),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
const VacantBedsScreen(),
));
},
),
),
),
Consumer<DashboardController>(
builder: (context, value, child) => SlideTransition(
position: _animation2,
child: RoomVaccentCard(
title: "Paymenys penting",
isLoading: value.isPaymentsLoading,
number: value.rentPendingResidents.length.toString(),
bgColor: ColorConstants.secondaryColor3,
icon: Icon(
FluentIcons.conference_room_48_regular,
color: ColorConstants.primaryBlackColor,
size: 26,
),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
const PendingPaymentsScreen(),
),
);
},
),
),
),
],
),
),
const SizedBox(
height: 20,
),
Padding(
padding: const EdgeInsets.only(left: 20),
child: Text(
"Going to vaccent",
style: TextStyleConstants.dashboardSubtitle1,
),
),
Padding(
padding: const EdgeInsets.only(top: 17, left: 20),
child: Row(
children: [
Consumer<DashboardController>(
builder: (context, value, child) => CustomDropdownButton(
selectedValue: value.selectedValue,
items: value.sortingItems,
onChanged: (p0) => value.selectFilter(p0),
height: 40,
width: 150),
),
const SizedBox(
width: 18.6,
),
DateCard(date: dashboardController.date())
],
),
),
const SizedBox(
height: 8,
),
Consumer<DashboardController>(
builder: (context, value, child) {
if (value.roomsGoingtoVacant.isNotEmpty) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: GridView.builder(
shrinkWrap: true,
physics: const ScrollPhysics(),
itemCount: value.roomsGoingtoVacant.length,
gridDelegate:
const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
mainAxisSpacing: 5,
crossAxisSpacing: 10,
mainAxisExtent: 80,
),
itemBuilder: (context, index) => SlideTransition(
position: index % 2 == 0 ? _animation1 : _animation2,
child: GoingToVaccentCard(
roomNumber: value.roomsGoingtoVacant[index]
["RoomNo"]
.toString(),
beadNumber: value.roomsGoingtoVacant[index]
["Vacancy"]
.toString(),
backgroungColor: ColorConstants.secondaryColor4),
),
),
);
} else {
return SizedBox(
height: 100,
child: Center(
child: Text(
"No Rooms going to Vacant this ${value.selectedValue}"),
),
);
}
},
),
const SizedBox(
height: 20,
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Text(
"Upcoming Bookings",
style: TextStyleConstants.dashboardSubtitle1,
),
),
const SizedBox(
height: 20,
),
bookingsController.bookingsWithinThisWeek.isEmpty
? const Center(
child: SizedBox(
height: 50,
child: Center(
child: Text("No Bookings"),
),
),
)
: Padding(
padding: const EdgeInsets.only(left: 20),
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
children: List.generate(
bookingsController.bookingsWithinThisWeek.length,
(index) {
BookingsModel booking = bookingsController
.bookingsWithinThisWeek[index];
return SlideTransition(
position: _animation2,
child: UpcomingBookings(
name: booking.name,
date: DateFormat('dd/MM/yyyy')
.format(booking.checkIn),
roomNumber: booking.roomNO.toString(),
beadNumber: "5",
isAdvacePaid: booking.advancePaid,
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
BookedResidentDetailesScreen(
index: index,
isSorted: true,
),
),
);
},
),
);
}),
),
),
),
const SizedBox(
height: 33,
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Hero(
tag: Title,
child: Text(
"Pending Payments",
style: TextStyleConstants.dashboardSubtitle1,
),
),
),
Consumer<DashboardController>(
builder: (context, value, child) => Padding(
padding: const EdgeInsets.all(25),
child: value.isPaymentsLoading
? SizedBox(
height: value.pendingPayments.length == 1
? 100
: value.pendingPayments.length == 2
? 230
: 339,
child: ListView.separated(
itemCount: value.pendingPayments.isEmpty
? 2
: value.pendingPayments.length,
physics: const ScrollPhysics(),
separatorBuilder: (context, index) => Container(
color: ColorConstants.secondaryWhiteColor,
height: 12,
),
itemBuilder: (context, index) =>
const PendingLoadingCard()),
)
: value.pendingPayments.isEmpty
? const Center(
child: SizedBox(
height: 50,
child: Center(
child: Text("No Pending Payments"),
),
),
)
: SizedBox(
height: value.pendingPayments.length == 1
? 100
: value.pendingPayments.length == 2
? 230
: 339,
child: ListView.separated(
itemCount: value.pendingPayments.length,
physics: const ScrollPhysics(),
separatorBuilder: (context, index) =>
Container(
color:
ColorConstants.secondaryWhiteColor,
height: 12,
),
itemBuilder: (context, index) {
Map<String, dynamic> pendingPayment =
value.pendingPayments[index];
return PendingPaymentCard(
roomNumber:
pendingPayment["RoomNo"].toString(),
date: DateFormat('dd MMM').format(
pendingPayment["Residents"][0]
.nextRentDate),
amount: pendingPayment["TotalAmount"]
.toString(),
residents: pendingPayment["Residents"],
);
}),
),
),
),
Center(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: InkWell(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const PendingPaymentsScreen(),
),
);
},
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: ColorConstants.primaryColor,
),
height: 40,
width: 150,
child: Center(
child: Text(
"Show All",
style: TextStyleConstants.buttonText,
),
),
),
),
),
),
],
),
),
),
);
}
@override
void dispose() {
_controller1.dispose();
_controller2.dispose();
super.dispose();
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/profile
|
mirrored_repositories/Hostel-Manager/lib/fetures/profile/controllers/user_controller.dart
|
// ignore_for_file: avoid_print
import 'package:flutter/material.dart';
import 'package:hostel_management_app/fetures/authentication/controllers/authentication_repository.dart';
import 'package:hostel_management_app/commens/functions/loading_controller.dart';
import 'package:hostel_management_app/fetures/profile/controllers/user_repository.dart';
import 'package:hostel_management_app/fetures/profile/models/owner_model.dart';
import 'package:hostel_management_app/fetures/authentication/screens/login_screen.dart';
import 'package:image_picker/image_picker.dart';
class UserController with ChangeNotifier {
OwnerModel? user = OwnerModel.empty();
final UserRepository controller = UserRepository();
final loadingController = FullScreenLoader();
bool isProfileUploading = false;
//----------------------------------------------------------------------------Fetch user data
fetchData() async {
try {
final currentUser = await controller.fetchOwnerRecords();
user = currentUser;
notifyListeners();
} catch (e) {
user = OwnerModel.empty();
notifyListeners();
}
}
final nameController = TextEditingController();
final hostelNameController = TextEditingController();
final emailController = TextEditingController();
final phoneNoController = TextEditingController();
final addressController = TextEditingController();
final roonNoController = TextEditingController();
GlobalKey<FormState> profileUpdateFormKey = GlobalKey<FormState>();
fillForm() {
nameController.text = user!.ownwerName;
hostelNameController.text = user!.hostelName;
emailController.text = user!.emailAddress;
phoneNoController.text = user!.mobileNumber;
addressController.text = user!.address;
roonNoController.text = user!.noOfRooms.toString();
}
//----------------------------------------------------------------------------Update user data
updateData(context) async {
try {
final updatedUser = OwnerModel(
id: user!.id,
hostelName: hostelNameController.text,
address: addressController.text,
emailAddress: emailController.text,
mobileNumber: phoneNoController.text,
ownwerName: nameController.text,
profilePictuer: user!.profilePictuer,
noOfRooms: int.parse(roonNoController.text),
noOfBeds: user!.noOfBeds,
noOfVacancy: user!.noOfVacancy,
isAccountSetupCompleted: true,
);
await controller.updateOwnerRecords(updatedUser);
fetchData();
Navigator.pop(context);
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text("Profile Updated Successfull")));
} catch (e) {
print(e.toString());
}
}
//----------------------------------------------------------------------------Delte user
deleteUserAccount(context) async {
try {
final auth = AuthenticationRepository();
await auth.deleteAccount();
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text("Account Deleted Successfully")));
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(
builder: (context) => const LoginScreen(),
),
(route) => false);
} catch (e) {
print(e.toString());
}
}
//----------------------------------------------------------------------------Upload profile pick
uploadUserProfilePicture(context) async {
try {
isProfileUploading = true;
final image = await ImagePicker().pickImage(
source: ImageSource.gallery,
imageQuality: 70,
maxHeight: 512,
maxWidth: 512);
if (image != null) {
final imageUrl =
await controller.uploadImage('Owners/Images/Profile', image);
Map<String, dynamic> json = {"ProfilePictuer": imageUrl};
controller.accountSetup(json);
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
content: Text("Profile picture Changed Sussefully")));
fetchData();
isProfileUploading = false;
}
} catch (e) {
print(e.toString());
} finally {
isProfileUploading = false;
}
}
fieldValidation(value) {
if (value == null || value.isEmpty) {
return "Name is required.";
} else {
return null;
}
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/profile
|
mirrored_repositories/Hostel-Manager/lib/fetures/profile/controllers/account_setup_screen_controller.dart
|
// ignore_for_file: use_build_context_synchronously, avoid_print
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:hostel_management_app/fetures/profile/controllers/user_repository.dart';
import 'package:hostel_management_app/fetures/home/screen/home_screen.dart';
import 'package:image_picker/image_picker.dart';
class AccountSetUpScreenController with ChangeNotifier {
List<int> noOfRooms = [];
final hostelNameController = TextEditingController();
final phoneNumberController = TextEditingController();
final addressController = TextEditingController();
final roomNumberController = TextEditingController();
String? imageUrl;
File? selectedImage;
GlobalKey<FormState> accountSetupFormKey = GlobalKey<FormState>();
final UserRepository controller = UserRepository();
Future<void> updateOwnerRecords(BuildContext context, String pro) async {
if (selectedImage != null) {
try {
imageUrl = await controller.uploadImage(
'Owners/Images/Profile', XFile(selectedImage!.path));
} catch (e) {
print(e);
}
}
final Map<String, dynamic> jason = {
'HostelName': hostelNameController.text,
'Address': addressController.text,
'MobileNumber': phoneNumberController.text,
'ProfilePictuer': imageUrl ?? pro,
'NoOfRooms': int.parse(roomNumberController.text),
'AccountSetupcompleted': true
};
controller.accountSetup(jason);
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(
builder: (context) => const HomeScreen(),
),
(route) => false);
hostelNameController.clear();
addressController.clear();
phoneNumberController.clear();
imageUrl = '';
roomNumberController.clear();
}
//------------------------------------------------------------------------------select Image
Future<void> openImagePicker() async {
try {
final XFile? pickedImage = await ImagePicker().pickImage(
source: ImageSource.gallery,
imageQuality: 70,
maxHeight: 512,
maxWidth: 512);
if (pickedImage != null) {
selectedImage = File(pickedImage.path);
notifyListeners();
} else {
print('Image not Selected');
}
} catch (e) {
print(e);
}
}
//------------------------------------------------------------------------------ form valitator
nameValidation(value) {
if (value == null || value.isEmpty) {
return "This field is required.";
} else {
return null;
}
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/profile
|
mirrored_repositories/Hostel-Manager/lib/fetures/profile/controllers/user_repository.dart
|
// ignore_for_file: avoid_print
import 'dart:io';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_storage/firebase_storage.dart';
import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:hostel_management_app/fetures/profile/models/owner_model.dart';
import 'package:image_picker/image_picker.dart';
class UserRepository with ChangeNotifier {
final FirebaseFirestore _db = FirebaseFirestore.instance;
final FirebaseAuth _auth = FirebaseAuth.instance;
Future<void> saveUserRecords(OwnerModel owner) async {
try {
await _db.collection("Owners").doc(owner.id).set(owner.toJson());
} catch (e) {
print(e);
}
}
Future<OwnerModel?> fetchOwnerRecords() async {
try {
final currentUser = _auth.currentUser;
final documentSnapshot =
await _db.collection("Owners").doc(currentUser?.uid).get();
if (documentSnapshot.exists) {
return OwnerModel.fromSnapshot(documentSnapshot);
}
} catch (e) {
print(e);
}
return null;
}
Future<void> accountSetup(Map<String, dynamic> json) async {
try {
final currentUser = _auth.currentUser;
await _db.collection("Owners").doc(currentUser!.uid).update(json);
} catch (e) {
print(e);
}
}
Future<void> updateOwnerRecords(OwnerModel user) async {
try {
await _db.collection("Owners").doc(user.id).update(user.toJson());
} catch (e) {
print(e);
}
}
Future<void> deleteOwnerRecords(String userId) async {
try {
await _db.collection("Owners").doc(userId).delete();
} catch (e) {
print(e);
}
}
Future<String?> uploadImage(String path, XFile image) async {
try {
final ref = FirebaseStorage.instance.ref(path).child(image.name);
await ref.putFile(File(image.path));
final url = await ref.getDownloadURL();
return url;
} catch (e) {
print(e);
}
return null;
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/profile
|
mirrored_repositories/Hostel-Manager/lib/fetures/profile/widgets/confirm_logout_dialog.dart
|
// ignore_for_file: use_build_context_synchronously
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:google_sign_in/google_sign_in.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
import 'package:hostel_management_app/fetures/authentication/screens/login_screen.dart';
class ConfirmLogoutDialog extends StatelessWidget {
const ConfirmLogoutDialog({
super.key,
});
@override
Widget build(BuildContext context) {
return AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15.0),
),
title: const Text(
'Confirm Logout',
textAlign: TextAlign.center,
),
content: const Text('Are you sure you want to logout?'),
actionsAlignment: MainAxisAlignment.center,
actions: <Widget>[
OutlinedButton(
onPressed: () {
Navigator.of(context)
.pop(false); // Dismiss the dialog and return false
},
child: const Text('Cancel'),
),
ElevatedButton(
style: ButtonStyle(
backgroundColor:
MaterialStatePropertyAll(ColorConstants.colorRed)),
onPressed: () async {
await GoogleSignIn().signOut();
await FirebaseAuth.instance.signOut();
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(
builder: (context) => const LoginScreen(),
),
(route) => false);
},
child: const Text('Logout'),
),
],
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/profile
|
mirrored_repositories/Hostel-Manager/lib/fetures/profile/widgets/room_no_card.dart
|
import 'package:flutter/material.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
import 'package:hostel_management_app/utils/image_constants.dart';
import 'package:hostel_management_app/utils/text_style_constatnts.dart';
class NumberCard extends StatelessWidget {
const NumberCard({
super.key,
required this.title,
required this.number,
});
final String title;
final String number;
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: ColorConstants.secondaryColor4.withOpacity(0.5)),
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 10),
child: Column(
children: [
Row(
children: [
Image.asset(
ImageConstants.bedIcon2,
color: ColorConstants.primaryBlackColor,
height: 25,
width: 25,
),
Text(
title,
style: TextStyleConstants.bookingsRoomNumber,
)
],
),
Text(
number,
style: TextStyleConstants.upComingVaccencyText2,
)
],
),
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/profile
|
mirrored_repositories/Hostel-Manager/lib/fetures/profile/widgets/confirm_delete_dialog.dart
|
import 'package:flutter/material.dart';
import 'package:hostel_management_app/fetures/profile/controllers/user_controller.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
import 'package:provider/provider.dart';
class ConfirmDeletDialog extends StatelessWidget {
const ConfirmDeletDialog({
super.key,
});
@override
Widget build(BuildContext context) {
return AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15.0),
),
title: const Text(
'Confirm Delete',
textAlign: TextAlign.center,
),
content: const Text(
'Are you sure you want to Delete your Account permenetly?'),
actionsAlignment: MainAxisAlignment.center,
actions: <Widget>[
OutlinedButton(
onPressed: () {
Navigator.of(context)
.pop(false);
},
child: const Text('Cancel'),
),
ElevatedButton(
style: ButtonStyle(
backgroundColor:
MaterialStatePropertyAll(ColorConstants.colorRed)),
onPressed: () async {
Provider.of<UserController>(context, listen: false)
.deleteUserAccount(context);
},
child: const Text('Delete'),
),
],
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/profile
|
mirrored_repositories/Hostel-Manager/lib/fetures/profile/widgets/profile_detailes_card.dart
|
import 'package:flutter/material.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
import 'package:hostel_management_app/utils/text_style_constatnts.dart';
class ProfileDetailesCard extends StatelessWidget {
const ProfileDetailesCard({
super.key,
required this.title,
required this.data,
});
final String title;
final String data;
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(title),
const SizedBox(
height: 5,
),
Container(
padding: const EdgeInsets.all(15),
width: double.infinity,
decoration: BoxDecoration(
color: ColorConstants.secondaryColor2.withOpacity(0.3),
borderRadius: BorderRadius.circular(10)),
child: Text(
data,
style: TextStyleConstants.dashboardBookingName,
),
),
],
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/profile
|
mirrored_repositories/Hostel-Manager/lib/fetures/profile/models/owner_model.dart
|
import 'package:cloud_firestore/cloud_firestore.dart';
class OwnerModel {
OwnerModel(
{required this.id,
required this.hostelName,
required this.address,
required this.emailAddress,
required this.mobileNumber,
required this.ownwerName,
required this.profilePictuer,
required this.noOfRooms,
required this.noOfBeds,
required this.noOfVacancy,
required this.isAccountSetupCompleted});
final String id;
String ownwerName;
String hostelName;
String address;
final String emailAddress;
final String mobileNumber;
String profilePictuer;
final int noOfRooms;
final int noOfBeds;
final int noOfVacancy;
final bool isAccountSetupCompleted;
Map<String, dynamic> toJson() {
return {
'OwnerName': ownwerName,
'HostelName': hostelName,
'Address': hostelName,
'EmailAddress': emailAddress,
'MobileNumber': mobileNumber,
'ProfilePictuer': profilePictuer,
'NoOfRooms': noOfRooms,
'NoOfBeds': noOfBeds,
'NoOfVacancy': noOfVacancy,
'AccountSetupcompleted': isAccountSetupCompleted
};
}
// factory model to create owner model from firebase document snapshort
factory OwnerModel.fromSnapshot(
DocumentSnapshot<Map<String, dynamic>> document) {
if (document.data() != null) {
final data = document.data()!;
return OwnerModel(
id: document.id,
hostelName: data['HostelName'] ?? '',
address: data['Address'] ?? '',
emailAddress: data['EmailAddress'] ?? '',
mobileNumber: data['MobileNumber'] ?? '',
ownwerName: data['OwnerName'] ?? '',
profilePictuer: data['ProfilePictuer'] ?? '',
noOfRooms: data['NoOfRooms'] ?? 0,
noOfBeds: data['NoOfBeds'] ?? 0,
noOfVacancy: data['NoOfVacancy'] ?? 0,
isAccountSetupCompleted: data['AccountSetupcompleted'] ?? false);
} else {
return OwnerModel.empty();
}
}
static OwnerModel empty() => OwnerModel(
id: '',
hostelName: '',
address: '',
emailAddress: '',
mobileNumber: '',
ownwerName: '',
profilePictuer: '',
noOfRooms: 0,
noOfBeds: 0,
noOfVacancy: 0,
isAccountSetupCompleted: false);
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/profile
|
mirrored_repositories/Hostel-Manager/lib/fetures/profile/screens/profile_screen.dart
|
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:hostel_management_app/fetures/profile/controllers/user_controller.dart';
import 'package:hostel_management_app/utils/animation_constants.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
import 'package:hostel_management_app/utils/image_constants.dart';
import 'package:hostel_management_app/commens/widgets/shimmer_loader.dart';
import 'package:hostel_management_app/fetures/profile/screens/profile_editing_screen.dart';
import 'package:hostel_management_app/fetures/profile/widgets/confirm_delete_dialog.dart';
import 'package:hostel_management_app/fetures/profile/widgets/confirm_logout_dialog.dart';
import 'package:hostel_management_app/fetures/profile/widgets/profile_detailes_card.dart';
import 'package:hostel_management_app/fetures/profile/widgets/room_no_card.dart';
import 'package:lottie/lottie.dart';
import 'package:provider/provider.dart';
class ProfileScreen extends StatelessWidget {
const ProfileScreen({super.key});
@override
Widget build(BuildContext context) {
final controller = Provider.of<UserController>(context);
const gap = SizedBox(
height: 20,
);
return Scaffold(
backgroundColor: ColorConstants.primaryWhiteColor,
appBar: AppBar(
backgroundColor: ColorConstants.primaryWhiteColor,
iconTheme: IconThemeData(color: ColorConstants.primaryBlackColor),
leading: IconButton(
onPressed: () {
Navigator.pop(context);
},
icon: const Icon(
Icons.chevron_left_outlined,
size: 30,
),
),
actions: [
PopupMenuButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
),
elevation: 10,
itemBuilder: (context) {
return [
PopupMenuItem(
child: const Text('Edit'),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const ProfileEdingScreen(),
));
}),
PopupMenuItem(
child: Row(
children: [
Text(
'Log Out',
style: TextStyle(color: ColorConstants.colorRed),
),
const SizedBox(
width: 5,
),
Icon(
Icons.logout,
size: 20,
color: ColorConstants.colorRed,
)
],
),
onTap: () {
showDialog(
context: context,
builder: (context) => const ConfirmLogoutDialog(),
);
},
),
PopupMenuItem(
child: Row(
children: [
Text(
'Delete Account',
style: TextStyle(color: ColorConstants.colorRed),
),
const SizedBox(
width: 5,
),
Icon(
Icons.delete,
size: 20,
color: ColorConstants.colorRed,
)
],
),
onTap: () {
showDialog(
context: context,
builder: (context) => const ConfirmDeletDialog(),
);
},
),
];
},
),
],
elevation: 0,
),
body: Padding(
padding: const EdgeInsets.only(right: 20, left: 20, bottom: 20),
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Hero(
tag: "profile",
child: Consumer<UserController>(
builder: (context, value, child) {
return Container(
height: 110,
width: 110,
decoration: BoxDecoration(
color: ColorConstants.primaryWhiteColor,
borderRadius: BorderRadius.circular(100),
),
child: value.isProfileUploading
? Center(
child: LottieBuilder(
lottie:
AssetLottie(AnimationConstants.loading2)),
)
: ClipRRect(
borderRadius: BorderRadius.circular(100),
child: controller.user!.profilePictuer.isNotEmpty
? CachedNetworkImage(
imageUrl: controller.user!.profilePictuer,
fit: BoxFit.cover,
errorWidget: (context, url, error) =>
const Icon(Icons.error),
progressIndicatorBuilder:
(context, url, progress) =>
const ShimmerEffect(
height: 110,
width: 110,
radius: 100),
)
: Image.asset(ImageConstants.profileImage),
),
);
},
),
),
TextButton(
onPressed: () {
Provider.of<UserController>(context, listen: false)
.uploadUserProfilePicture(context);
},
child: const Text("Change Profile Pic")),
ProfileDetailesCard(
title: "",
data: controller.user!.hostelName,
),
gap,
ProfileDetailesCard(
title: "Owner Name", data: controller.user!.ownwerName),
gap,
ProfileDetailesCard(
title: "Address",
data: controller.user!.address,
),
gap,
ProfileDetailesCard(
title: "Phone Number", data: controller.user!.mobileNumber),
gap,
ProfileDetailesCard(
title: "Email", data: controller.user!.emailAddress),
gap,
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
NumberCard(
title: "No of Rooms",
number: controller.user!.noOfRooms.toString()),
NumberCard(
title: "No of Beds",
number: controller.user!.noOfBeds.toString())
],
),
],
),
),
),
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/profile
|
mirrored_repositories/Hostel-Manager/lib/fetures/profile/screens/account_setup_screen.dart
|
import 'dart:io';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:hostel_management_app/fetures/profile/controllers/account_setup_screen_controller.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
import 'package:hostel_management_app/utils/text_style_constatnts.dart';
import 'package:hostel_management_app/commens/widgets/login_button.dart';
import 'package:provider/provider.dart';
class AccountSetupScreen extends StatefulWidget {
const AccountSetupScreen({super.key});
@override
State<AccountSetupScreen> createState() => _AccountSetupScreenState();
}
class _AccountSetupScreenState extends State<AccountSetupScreen> {
final FirebaseFirestore _db = FirebaseFirestore.instance;
final FirebaseAuth _auth = FirebaseAuth.instance;
String profilePhoto = "";
fetchprofile() async {
final currentUser = _auth.currentUser;
final documentSnapshot =
await _db.collection("Owners").doc(currentUser?.uid).get();
profilePhoto = documentSnapshot['ProfilePictuer'];
}
@override
Widget build(BuildContext context) {
final controller = Provider.of<AccountSetUpScreenController>(context);
return Scaffold(
backgroundColor: ColorConstants.secondaryWhiteColor,
body: SafeArea(
child: Center(
child: Container(
height: MediaQuery.sizeOf(context).height * 85 / 100,
width: MediaQuery.sizeOf(context).width * 90 / 100,
decoration: BoxDecoration(
color: ColorConstants.primaryWhiteColor,
borderRadius: BorderRadius.circular(30),
boxShadow: [
BoxShadow(
color: ColorConstants.primaryBlackColor.withOpacity(0.3),
blurRadius: 1,
offset: const Offset(0, 2), // Offset for the bottom shadow
),
]),
child: Padding(
padding: const EdgeInsets.all(20),
child: SingleChildScrollView(
child: Form(
key: controller.accountSetupFormKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Center(
child: Text(
"Set Up Your\nHostel",
textAlign: TextAlign.center,
style: TextStyle(
color: ColorConstants.primaryColor,
fontSize: 25,
fontWeight: FontWeight.w700),
),
),
const SizedBox(
height: 20,
),
Center(
child: SizedBox(
height: 100,
width: 100,
child: Stack(
children: [
Positioned(
child: Hero(
tag: Form,
child: InkWell(
onTap: () => controller.openImagePicker(),
child:
Consumer<AccountSetUpScreenController>(
builder: (context, value, child) =>
CircleAvatar(
radius: 50,
backgroundColor:
ColorConstants.secondaryColor4,
backgroundImage: profilePhoto != ""
? NetworkImage(profilePhoto)
as ImageProvider<Object>?
: controller.selectedImage != null
? FileImage(File(controller
.selectedImage!.path))
: null,
child:
controller.selectedImage == null &&
profilePhoto == ""
? Icon(
Icons.person,
color: ColorConstants
.primaryBlackColor,
size: 40,
)
: null,
),
),
),
),
),
Positioned(
bottom: 3,
right: 3,
child: CircleAvatar(
radius: 13,
backgroundColor:
ColorConstants.secondaryColor5,
child: const Icon(Icons.add),
),
)
],
),
),
),
const SizedBox(
height: 20,
),
Text(
"Your Hostel Name",
style: TextStyleConstants.dashboardBookingName,
),
const SizedBox(
height: 10,
),
SizedBox(
height: 50,
child: TextFormField(
controller: controller.hostelNameController,
validator: (value) =>
controller.nameValidation(value),
decoration: InputDecoration(
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: BorderSide(
width: 1,
color: ColorConstants.primaryColor),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: BorderSide(
width: 2,
color: ColorConstants.primaryColor),
),
errorBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: BorderSide(
width: 2,
color: ColorConstants.primaryColor),
),
counterStyle: TextStyle(
color: ColorConstants.primaryBlackColor)),
cursorColor: ColorConstants.primaryBlackColor,
),
),
const SizedBox(
height: 20,
),
Text(
"Address",
style: TextStyleConstants.dashboardBookingName,
),
const SizedBox(
height: 10,
),
SizedBox(
height: 100,
child: TextFormField(
controller: controller.addressController,
maxLines: null,
expands: true,
textAlignVertical: TextAlignVertical.top,
validator: (value) =>
controller.nameValidation(value),
decoration: InputDecoration(
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: BorderSide(
width: 1,
color: ColorConstants.primaryColor),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: BorderSide(
width: 2,
color: ColorConstants.primaryColor),
),
errorBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: BorderSide(
width: 2,
color: ColorConstants.primaryColor),
),
counterStyle: TextStyle(
color: ColorConstants.primaryBlackColor)),
),
),
const SizedBox(
height: 20,
),
Text(
"Phone no",
style: TextStyleConstants.dashboardBookingName,
),
const SizedBox(
height: 10,
),
SizedBox(
height: 50,
child: TextFormField(
controller: controller.phoneNumberController,
validator: (value) =>
controller.nameValidation(value),
decoration: InputDecoration(
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: BorderSide(
width: 1,
color: ColorConstants.primaryColor),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: BorderSide(
width: 2,
color: ColorConstants.primaryColor),
),
errorBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: BorderSide(
width: 2,
color: ColorConstants.primaryColor),
),
counterStyle: TextStyle(
color: ColorConstants.primaryBlackColor)),
cursorColor: ColorConstants.primaryBlackColor,
),
),
const SizedBox(
height: 20,
),
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
"No of Roms : ",
style: TextStyleConstants.dashboardBookingName,
),
SizedBox(
height: 50,
width: 100,
child: TextFormField(
controller: controller.roomNumberController,
validator: (value) =>
controller.nameValidation(value),
decoration: InputDecoration(
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: BorderSide(
width: 1,
color: ColorConstants.primaryColor),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: BorderSide(
width: 2,
color: ColorConstants.primaryColor),
),
errorBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: BorderSide(
width: 2,
color: ColorConstants.primaryColor),
),
counterStyle: TextStyle(
color: ColorConstants.primaryBlackColor)),
cursorColor: ColorConstants.primaryBlackColor,
keyboardType: TextInputType.number,
),
),
],
),
const SizedBox(
height: 20,
),
const SizedBox(
height: 20,
),
LoginButton(
buttonName: "Continue",
onTap: () {
if (controller.accountSetupFormKey.currentState!
.validate()) {
Provider.of<AccountSetUpScreenController>(context,
listen: false)
.updateOwnerRecords(context, profilePhoto);
}
},
)
],
),
),
),
),
),
),
),
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/profile
|
mirrored_repositories/Hostel-Manager/lib/fetures/profile/screens/profile_editing_screen.dart
|
import 'package:flutter/material.dart';
import 'package:hostel_management_app/fetures/profile/controllers/user_controller.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
import 'package:hostel_management_app/utils/text_style_constatnts.dart';
import 'package:hostel_management_app/commens/widgets/form_field.dart';
import 'package:provider/provider.dart';
class ProfileEdingScreen extends StatefulWidget {
const ProfileEdingScreen({super.key});
@override
State<ProfileEdingScreen> createState() => _ProfileEdingScreenState();
}
class _ProfileEdingScreenState extends State<ProfileEdingScreen> {
@override
void initState() {
Provider.of<UserController>(context, listen: false).fillForm();
super.initState();
}
@override
Widget build(BuildContext context) {
const gap = SizedBox(
height: 20,
);
final controller = Provider.of<UserController>(context);
return Scaffold(
appBar: AppBar(
backgroundColor: ColorConstants.primaryWhiteColor,
iconTheme: IconThemeData(color: ColorConstants.primaryBlackColor),
leading: IconButton(
onPressed: () {
Navigator.pop(context);
},
icon: const Icon(
Icons.chevron_left_outlined,
size: 30,
),
),
elevation: 0,
),
body: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(20.0),
child: Column(
children: [
Form(
key: controller.profileUpdateFormKey,
child: Column(
children: [
CustomFormField(
controller: controller.nameController,
labelText: 'Name',
validator: (p0) {
controller.fieldValidation(p0!);
return null;
},
),
gap,
CustomFormField(
controller: controller.hostelNameController,
labelText: 'Hostel Name',
validator: (p0) {
controller.fieldValidation(p0!);
return null;
},
),
gap,
CustomFormField(
controller: controller.emailController,
labelText: 'Email',
validator: (p0) {
controller.fieldValidation(p0!);
return null;
},
),
gap,
CustomFormField(
controller: controller.phoneNoController,
labelText: 'Phone No',
validator: (p0) {
controller.fieldValidation(p0!);
return null;
},
),
gap,
SizedBox(
height: 100,
child: TextFormField(
maxLines: 10,
textAlignVertical: TextAlignVertical.top,
textAlign: TextAlign.start,
controller: controller.addressController,
validator: (value) => controller.fieldValidation(value),
decoration: InputDecoration(
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(15),
borderSide: BorderSide(
width: 2, color: ColorConstants.colorGrey),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(15),
borderSide: BorderSide(
width: 2, color: ColorConstants.primaryColor),
),
label: const Text("Address"),
hintStyle: TextStyle(
fontSize: 15,
color: ColorConstants.colorGrey,
fontWeight: FontWeight.w500),
),
),
),
gap,
CustomFormField(
controller: controller.roonNoController,
labelText: 'No of Rooms',
validator: (p0) {
controller.fieldValidation(p0!);
return null;
},
),
gap,
gap,
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
InkWell(
onTap: () {
Navigator.pop(context);
},
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: ColorConstants.secondaryColor2,
),
height: 50,
width: 150,
child: Center(
child: Text(
"cancel",
style: TextStyleConstants.buttonText,
),
),
),
),
InkWell(
onTap: () {
if (controller.profileUpdateFormKey.currentState!
.validate()) {
Provider.of<UserController>(context,
listen: false)
.updateData(context);
}
},
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: ColorConstants.primaryColor,
),
height: 50,
width: 150,
child: Center(
child: Text(
"Update",
style: TextStyleConstants.buttonText,
),
),
),
),
],
),
],
),
)
],
),
),
),
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/home
|
mirrored_repositories/Hostel-Manager/lib/fetures/home/controllers/bottomnavbar_controller.dart
|
import 'package:flutter/material.dart';
import 'package:hostel_management_app/fetures/bookings/screens/bookings_page.dart';
import 'package:hostel_management_app/fetures/dashboard/screens/dashboard_page.dart';
import 'package:hostel_management_app/fetures/residents/screens/residents_page.dart';
import 'package:hostel_management_app/fetures/rooms/screens/rooms_page.dart';
class NavBarController with ChangeNotifier {
int selectedIndex = 0;
List<Widget> ownerPages = [
const DashBoardPage(),
const OwnerRoomsPage(),
const BookingsPage(),
const ResidentsPage(),
];
void onNavTap(index) {
selectedIndex = index;
notifyListeners();
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/home
|
mirrored_repositories/Hostel-Manager/lib/fetures/home/screen/home_screen.dart
|
import 'package:fluentui_system_icons/fluentui_system_icons.dart';
import 'package:flutter/material.dart';
import 'package:hostel_management_app/fetures/home/controllers/bottomnavbar_controller.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
import 'package:provider/provider.dart';
class HomeScreen extends StatelessWidget {
const HomeScreen({super.key});
@override
Widget build(BuildContext context) {
NavBarController navBarController = Provider.of<NavBarController>(context);
return Scaffold(
backgroundColor: ColorConstants.primaryWhiteColor,
body: Provider.of<NavBarController>(context)
.ownerPages[Provider.of<NavBarController>(context).selectedIndex],
bottomNavigationBar: BottomNavigationBar(
elevation: 0,
backgroundColor: ColorConstants.primaryWhiteColor,
type: BottomNavigationBarType.fixed,
currentIndex: navBarController.selectedIndex,
onTap: (value) {
Provider.of<NavBarController>(context, listen: false).onNavTap(value);
},
selectedLabelStyle: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w500,
color: ColorConstants.primaryBlackColor),
selectedItemColor: ColorConstants.primaryBlackColor,
unselectedItemColor: ColorConstants.primaryBlackColor,
unselectedLabelStyle: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w400,
color: ColorConstants.primaryBlackColor),
unselectedIconTheme:
IconThemeData(size: 25, color: ColorConstants.primaryBlackColor),
selectedIconTheme:
IconThemeData(size: 25, color: ColorConstants.primaryBlackColor),
items: [
BottomNavigationBarItem(
icon: Icon(
navBarController.selectedIndex == 0
? FluentIcons.home_12_filled
: FluentIcons.home_12_regular,
),
label: 'Home'),
BottomNavigationBarItem(
icon: Icon(
navBarController.selectedIndex == 1
? FluentIcons.door_16_filled
: FluentIcons.conference_room_24_regular,
),
label: 'Rooms'),
BottomNavigationBarItem(
icon: Icon(
navBarController.selectedIndex == 2
? FluentIcons.book_contacts_20_filled
: FluentIcons.book_contacts_20_regular,
color: ColorConstants.primaryBlackColor,
size: 27,
),
label: 'Bookings'),
BottomNavigationBarItem(
icon: Icon(
navBarController.selectedIndex == 3
? FluentIcons.people_12_filled
: FluentIcons.people_12_regular,
),
label: 'Residents',
),
],
),
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/authentication
|
mirrored_repositories/Hostel-Manager/lib/fetures/authentication/controllers/screen_redirector.dart
|
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:hostel_management_app/fetures/authentication/screens/onboarding/onboarding_screen.dart';
import 'package:hostel_management_app/fetures/home/screen/home_screen.dart';
class ScreenReDirector {
Widget redirectScreen() {
final user = FirebaseAuth.instance.currentUser;
if (user != null) {
return const HomeScreen();
} else {
return const OnBoardingScreen();
}
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/authentication
|
mirrored_repositories/Hostel-Manager/lib/fetures/authentication/controllers/register_controller.dart
|
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:hostel_management_app/fetures/authentication/controllers/authentication_repository.dart';
import 'package:hostel_management_app/commens/functions/connection_checher.dart';
import 'package:hostel_management_app/commens/functions/loading_controller.dart';
import 'package:hostel_management_app/fetures/authentication/screens/signup_successfull_page.dart';
import 'package:provider/provider.dart';
class SignInController with ChangeNotifier {
GlobalKey<FormState> signupFormKey = GlobalKey<FormState>();
final nameController = TextEditingController();
final emailController = TextEditingController();
final passwordController = TextEditingController();
final confirmPasswordController = TextEditingController();
bool hidePassword = true;
final ConnectionChecker connection = ConnectionChecker();
final loadingController = FullScreenLoader();
//------------------------------------------------------------------------------Register
signin(context) async {
try {
FullScreenLoader.openLoadinDialog(context);
//chec internet connection
final isConnected = await connection.isConnected();
final authProvider =
Provider.of<AuthenticationRepository>(context, listen: false);
if (!isConnected) {
ScaffoldMessenger.of(context)
.showSnackBar(const SnackBar(content: Text("Network error")));
}
String? errorMessage = await authProvider.signInWithEmailAndPassword(
email: emailController.text.trim(),
password: passwordController.text.trim(),
name: nameController.text);
if (errorMessage == null) {
if (authProvider.userCredential.user?.uid != null) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const SignUpSuccessfullScree(),
),
);
}
} else {
FullScreenLoader.stopLoadin(context);
// Show error message to the user
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(errorMessage),
));
}
nameController.clear();
emailController.clear();
passwordController.clear();
confirmPasswordController.clear();
} on PlatformException catch (e) {
if (e.code == 'weak-password') {
return ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
content: Text('The password provided is too weak.')));
} else if (e.code == 'email-already-in-use') {
return ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
content: Text('The account already exists for that email.')));
}
} catch (e) {
return ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: Text("error $e")));
} finally {}
}
//------------------------------------------------------------------------------google signin
signInWithGoogle(context) async {
try {
//start loading animation
FullScreenLoader.openLoadinDialog(context);
//checking internet connection
final isConnected = await connection.isConnected();
final authProvider =
Provider.of<AuthenticationRepository>(context, listen: false);
if (!isConnected) {
ScaffoldMessenger.of(context)
.showSnackBar(const SnackBar(content: Text("Network error")));
}
//invoking signup function
String? errorMessage = await authProvider.signInWithGoogle(context);
// FullScreenLoader.stopLoadin(context);
if (errorMessage != null) {
// Show error message to the user
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(errorMessage),
));
}
} on PlatformException catch (e) {
if (e.code == 'weak-password') {
return ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
content: Text('The password provided is too weak.')));
} else if (e.code == 'email-already-in-use') {
return ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
content: Text('The account already exists for that email.')));
}
} catch (e) {
print('error :$e');
}
}
// -----------------------------------------------------------------------------hide password
togglePassword() {
hidePassword = !hidePassword;
notifyListeners();
}
//------------------------------------------------------------------------------name form valitator
nameValidation(value) {
if (value == null || value.isEmpty) {
return "Name is required.";
} else {
return null;
}
}
//------------------------------------------------------------------------------email validation
emailValidation(String value) {
if (value.isEmpty) {
return "Email is required.";
} else if (!RegExp(r"^[a-zA-Z0-9+_.-]+@[a-zA-Z0-9.-]+$").hasMatch(value)) {
return "Enter a valid email address.";
} else {
return null;
}
}
//------------------------------------------------------------------------------Password validation
passwordValidation(value) {
if (value == null || value.isEmpty) {
return "Password is required.";
} else if (value.length < 6) {
return "Password must be atleast 6 character long";
} else {
return null;
}
}
confirmPasswordValidaton(value) {
if (passwordController.text != value) {
return "Password not correct";
}
return null;
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/authentication
|
mirrored_repositories/Hostel-Manager/lib/fetures/authentication/controllers/forgotpassword_controller.dart
|
import 'package:flutter/material.dart';
import 'package:hostel_management_app/fetures/authentication/controllers/authentication_repository.dart';
import 'package:hostel_management_app/commens/functions/connection_checher.dart';
import 'package:hostel_management_app/commens/functions/loading_controller.dart';
import 'package:hostel_management_app/fetures/authentication/screens/password_changed_screen.dart';
class ForgotPasswordController with ChangeNotifier {
final emailController = TextEditingController();
GlobalKey<FormState> forgotPasswordFormKey = GlobalKey<FormState>();
final loadingController = FullScreenLoader();
final ConnectionChecker connection = ConnectionChecker();
final AuthenticationRepository auth = AuthenticationRepository();
//------------------------------------------------------------------------------Sent Reset Email
sendPasswordResetEmail(context) async {
try {
//loading animation
FullScreenLoader.openLoadinDialog(context);
final isConnected = await connection.isConnected();
if (!isConnected) {
FullScreenLoader.stopLoadin(context);
ScaffoldMessenger.of(context)
.showSnackBar(const SnackBar(content: Text("Network error")));
}
await auth.resetPassword(email: emailController.text.trim());
FullScreenLoader.stopLoadin(context);
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const PasswordChangedScreen(),
));
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
content: Text("Email Lisk Sent to reset your Password")));
} catch (e) {
FullScreenLoader.stopLoadin(context);
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: Text("oops ${e.toString()}")));
}
}
//------------------------------------------------------------------------------Email validation
emailValidation(String value) {
if (value.isEmpty) {
return "Email is required.";
} else if (!RegExp(r"^[a-zA-Z0-9+_.-]+@[a-zA-Z0-9.-]+$").hasMatch(value)) {
return "Enter a valid email address.";
} else {
return null;
}
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/authentication
|
mirrored_repositories/Hostel-Manager/lib/fetures/authentication/controllers/authentication_repository.dart
|
// ignore_for_file: avoid_print, use_build_context_synchronously
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:google_sign_in/google_sign_in.dart';
import 'package:hostel_management_app/fetures/profile/controllers/user_repository.dart';
import 'package:hostel_management_app/fetures/profile/models/owner_model.dart';
import 'package:hostel_management_app/fetures/profile/screens/account_setup_screen.dart';
import 'package:hostel_management_app/fetures/home/screen/home_screen.dart';
class AuthenticationRepository extends ChangeNotifier {
final FirebaseAuth _auth = FirebaseAuth.instance;
late UserCredential userCredential;
late UserCredential userCredentialGoogle;
final UserRepository user = UserRepository();
final FirebaseFirestore _firestore = FirebaseFirestore.instance;
//------------------------------------------------------------------------------sign in with Email and Password
Future<String?> signInWithEmailAndPassword(
{required String email,
required String password,
required String name}) async {
try {
userCredential = await _auth.createUserWithEmailAndPassword(
email: email,
password: password,
);
final newOwner = OwnerModel(
id: userCredential.user!.uid,
hostelName: '',
address: '',
emailAddress: email,
mobileNumber: '',
ownwerName: name,
profilePictuer: '',
noOfRooms: 0,
noOfBeds: 0,
noOfVacancy: 0,
isAccountSetupCompleted: false);
//saving owner data
await user.saveUserRecords(newOwner);
return null; // Return null for successful sign-up
} on FirebaseAuthException catch (e) {
if (e.code == 'weak-password') {
return 'The password provided is too weak.';
} else if (e.code == 'email-already-in-use') {
return 'The account already exists for that email.';
}
return e.message; // Return error message for other exceptions
} catch (e) {
return 'Error: ${e.toString()}'; // Return generic error message for other exceptions
}
}
//------------------------------------------------------------------------------signin with google
Future<String?> signInWithGoogle(BuildContext context) async {
try {
final GoogleSignInAccount? userAccount = await GoogleSignIn().signIn();
print(userAccount);
final GoogleSignInAuthentication? googleAuth =
await userAccount?.authentication;
print(googleAuth);
final credential = GoogleAuthProvider.credential(
accessToken: googleAuth?.accessToken, idToken: googleAuth?.idToken);
print(credential);
userCredentialGoogle = await _auth.signInWithCredential(credential);
print(userCredential);
notifyListeners();
// ignore: unnecessary_null_comparison
if (userCredentialGoogle != null) {
final userId = userCredentialGoogle.user!.uid;
final DocumentSnapshot userData =
await _firestore.collection("Owners").doc(userId).get();
if (!userData.exists) {
// New user, save owner records
final newOwner = OwnerModel(
id: userId,
hostelName: '',
address: '',
emailAddress: userCredentialGoogle.user!.email ?? "",
mobileNumber: userCredentialGoogle.user!.phoneNumber ?? "",
ownwerName: userCredentialGoogle.user!.displayName ?? "",
profilePictuer: userCredentialGoogle.user!.photoURL ?? "",
noOfRooms: 0,
noOfBeds: 0,
noOfVacancy: 0,
isAccountSetupCompleted: false,
);
// Save owner data
await user.saveUserRecords(newOwner);
}
final DocumentSnapshot newUserData =
await _firestore.collection("Owners").doc(userId).get();
final bool isFirstTime = await newUserData['AccountSetupcompleted'];
if (!isFirstTime) {
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(
builder: (context) => const AccountSetupScreen(),
),
(route) => false);
} else {
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(
builder: (context) => const HomeScreen(),
),
(route) => false);
}
// Return null for successful sign-up
return null;
}
return null;
} on FirebaseAuthException catch (e) {
if (e.code == 'weak-password') {
return 'The password provided is too weak.';
} else if (e.code == 'email-already-in-use') {
// Return 'The account already exists for that email.'
}
return e.message; // Return error message for other exceptions
} catch (e) {
print('Error: ${e.toString()}');
return 'Error: ${e.toString()}'; // Return generic error message for other exceptions
}
}
//----------------------------------------------------------------------------reset password
Future<void> resetPassword({required String email}) async {
try {
await _auth.sendPasswordResetEmail(email: email);
} catch (e) {
print('Error: ${e.toString()}');
}
}
//----------------------------------------------------------------------------Delete Account
Future<void> deleteAccount() async {
try {
final curentUser = _auth.currentUser;
await user.deleteOwnerRecords(curentUser!.uid);
await _auth.currentUser!.delete();
await GoogleSignIn().signOut();
await FirebaseAuth.instance.signOut();
} catch (e) {
print('Error: ${e.toString()}');
}
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/authentication
|
mirrored_repositories/Hostel-Manager/lib/fetures/authentication/controllers/login_controller.dart
|
// ignore_for_file: use_build_context_synchronously
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:hostel_management_app/commens/functions/connection_checher.dart';
import 'package:hostel_management_app/commens/functions/loading_controller.dart';
import 'package:hostel_management_app/fetures/profile/screens/account_setup_screen.dart';
import 'package:hostel_management_app/fetures/home/screen/home_screen.dart';
import 'package:shared_preferences/shared_preferences.dart';
class LoginController with ChangeNotifier {
final emailController = TextEditingController();
final passwordController = TextEditingController();
bool hidePassword = true;
bool rememberCredentials = false;
GlobalKey<FormState> loginFormKey = GlobalKey<FormState>();
final ConnectionChecker connection = ConnectionChecker();
final FirebaseAuth _auth = FirebaseAuth.instance;
final FirebaseFirestore _firestore = FirebaseFirestore.instance;
final loadingController = FullScreenLoader();
bool isLoading = false;
//----------------------------------------------------------------------------remember credentials
remember() {
rememberCredentials = !rememberCredentials;
notifyListeners();
}
//----------------------------------------------------------------------------fetch stored credential credential
fetchStordCredentials() async {
final SharedPreferences prefs = await SharedPreferences.getInstance();
emailController.text = prefs.getString('email') ?? "";
passwordController.text = prefs.getString('password') ?? "";
notifyListeners();
}
//----------------------------------------------------------------------------Login
Future<void> login(BuildContext context) async {
try {
// start loading screen
FullScreenLoader.openLoadinDialog(context);
print("started");
// store credentials in local storage
if (rememberCredentials) {
final SharedPreferences prefs = await SharedPreferences.getInstance();
prefs.setString('email', emailController.text.trim());
prefs.setString('password', passwordController.text.trim());
}
final credential = await _auth.signInWithEmailAndPassword(
email: emailController.text.trim(),
password: passwordController.text.trim(),
);
//Navigate to home page
if (credential.user?.uid != null) {
emailController.clear();
passwordController.clear();
final DocumentSnapshot userData = await _firestore
.collection("Owners")
.doc(credential.user?.uid)
.get();
final bool isFirstTime = await userData['AccountSetupcompleted'];
if (!isFirstTime) {
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(
builder: (context) => const AccountSetupScreen(),
),
(route) => false);
} else {
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(
builder: (context) => const HomeScreen(),
),
(route) => false);
}
} else {
FullScreenLoader.stopLoadin(context);
}
} on FirebaseAuthException catch (e) {
if (e.code == 'user-not-found') {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('No user found for that email.')));
} else if (e.code == 'wrong-password') {
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
content: Text('Wrong password provided for that user.')));
} else {
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: Text('OOps ${e.code.toString()}')));
}
FullScreenLoader.stopLoadin(context);
}
}
//------------------------------------------------------------------------------hide password
togglePassword() {
hidePassword = !hidePassword;
notifyListeners();
}
//------------------------------------------------------------------------------email validation
emailValidation(String value) {
if (value.isEmpty) {
return "Email is required.";
} else if (!RegExp(r"^[a-zA-Z0-9+_.-]+@[a-zA-Z0-9.-]+$").hasMatch(value)) {
return "Enter a valid email address.";
} else {
return null;
}
}
//------------------------------------------------------------------------------Password validation
passwordValidation(value) {
if (value == null || value.isEmpty) {
return "Password is required.";
} else if (value.length < 6) {
return "Password must be atleast 6 character long";
} else {
return null;
}
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/authentication/controllers
|
mirrored_repositories/Hostel-Manager/lib/fetures/authentication/controllers/onboarding/onboaring_controller.dart
|
import 'package:flutter/material.dart';
import 'package:hostel_management_app/utils/image_constants.dart';
import 'package:hostel_management_app/fetures/authentication/screens/login_screen.dart';
class OnBoardingController with ChangeNotifier {
PageController pageController = PageController();
List<Map> onBoardingScreens = [
{
"image": ImageConstants.onBoardingImage1,
"title1": "Your",
"title2": "Comfort Zone Awaits!",
"description":
"Discover the ease of room reservations, seamless communication, and a vibrant community."
},
{
"image": ImageConstants.onBoardingImage2,
"title1": "Elevate Your Hostel",
"title2": "Experience",
"description":
"Immerse yourself in a new era of hostel living. From intuitive bookings to community engagement, our hostel management system redefines convenience."
},
{
"image": ImageConstants.onBoardingImage3,
"title1": "Unlock a",
"title2": "World of Possibilities",
"description":
"Our hostel management system opens the gateway to seamless living, vibrant events, and lasting connections."
}
];
String title1 = "Your";
String title2 = "Comfort Zone Awaits!";
String description =
"Discover the ease of room reservations, seamless communication, and a vibrant community.";
//------------------------------------------------------------------------------On page change function
onPageChange({required int index}) {
title1 = onBoardingScreens[index]["title1"];
title2 = onBoardingScreens[index]["title2"];
description = onBoardingScreens[index]["description"];
notifyListeners();
}
//------------------------------------------------------------------------------On smooth indicator dot click
onDotClicked(index) {
pageController.jumpToPage(index);
notifyListeners();
}
onTap(context) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const LoginScreen(),
),
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/authentication
|
mirrored_repositories/Hostel-Manager/lib/fetures/authentication/widgets/signin_form.dart
|
import 'package:flutter/material.dart';
import 'package:hostel_management_app/fetures/authentication/controllers/register_controller.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
import 'package:hostel_management_app/utils/text_style_constatnts.dart';
import 'package:hostel_management_app/commens/widgets/form_field.dart';
import 'package:hostel_management_app/commens/widgets/login_button.dart';
import 'package:provider/provider.dart';
class SignupForm extends StatelessWidget {
const SignupForm({
super.key,
required this.controller,
});
final SignInController controller;
@override
Widget build(BuildContext context) {
return Form(
key: controller.signupFormKey,
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
"Name",
style: TextStyleConstants.dashboardBookingName,
)
],
),
const SizedBox(
height: 10,
),
CustomFormField(
controller: controller.nameController,
hitText: "Name",
validator: (p0) => controller.nameValidation(p0),
),
const SizedBox(
height: 10,
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
"Email",
style: TextStyleConstants.dashboardBookingName,
)
],
),
const SizedBox(
height: 10,
),
CustomFormField(
controller: controller.emailController,
hitText: "Email",
validator: (p0) => controller.emailValidation(p0!),
),
const SizedBox(
height: 10,
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
"Enter password",
style: TextStyleConstants.dashboardBookingName,
)
],
),
const SizedBox(
height: 10,
),
CustomFormField(
controller: controller.passwordController,
hitText: "password",
validator: (p0) => controller.passwordValidation(p0),
suffixIcon: IconButton(
onPressed: () {
Provider.of<SignInController>(context, listen: false)
.togglePassword();
},
icon: Icon(
Icons.remove_red_eye_outlined,
color: ColorConstants.primaryColor.withOpacity(0.5),
)),
hideText: controller.hidePassword,
),
const SizedBox(
height: 10,
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
"Confirm password",
style: TextStyleConstants.dashboardBookingName,
)
],
),
const SizedBox(
height: 10,
),
CustomFormField(
controller: controller.confirmPasswordController,
hitText: "password",
validator: (p0) => controller.confirmPasswordValidaton(p0),
suffixIcon: IconButton(
onPressed: () {
Provider.of<SignInController>(context, listen: false)
.togglePassword();
},
icon: Icon(
Icons.remove_red_eye_outlined,
color: ColorConstants.primaryColor.withOpacity(0.5),
)),
hideText: controller.hidePassword,
),
const SizedBox(
height: 20,
),
Center(
child: LoginButton(
buttonName: "Sign up",
onTap: () {
if (controller.signupFormKey.currentState!.validate()) {
Provider.of<SignInController>(context, listen: false)
.signin(context);
}
},
),
),
],
),
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/authentication
|
mirrored_repositories/Hostel-Manager/lib/fetures/authentication/widgets/custom_clipper.dart
|
import 'package:flutter/material.dart';
class MyCustomClipper extends CustomClipper<Path> {
@override
Path getClip(Size size) {
final path = Path();
path.moveTo(0, size.height * 0.2); // Start from top-left
path.lineTo(0, size.height); // Bottom-left
path.lineTo(size.width, size.height); // Bottom-right
path.lineTo(size.width, size.height * 0.2); // Right top corner
// Create a curved top using quadraticBezierTo to curve outside
path.quadraticBezierTo(
size.width / 2, size.height * 0.05, 0, size.height * 0.2);
path.close(); // Close the path
return path;
}
@override
bool shouldReclip(covariant CustomClipper<Path> oldClipper) {
return false;
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/authentication
|
mirrored_repositories/Hostel-Manager/lib/fetures/authentication/widgets/login_form.dart
|
import 'package:flutter/material.dart';
import 'package:hostel_management_app/fetures/authentication/controllers/login_controller.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
import 'package:hostel_management_app/utils/text_style_constatnts.dart';
import 'package:hostel_management_app/fetures/authentication/screens/fogot_password_screen.dart';
import 'package:hostel_management_app/commens/widgets/login_button.dart';
import 'package:provider/provider.dart';
class LoginForm extends StatelessWidget {
const LoginForm({
super.key,
});
@override
Widget build(BuildContext context) {
final controller = Provider.of<LoginController>(context);
return Form(
key: controller.loginFormKey,
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
"Email",
style: TextStyleConstants.dashboardBookingName,
)
],
),
const SizedBox(
height: 10,
),
TextFormField(
controller: controller.emailController,
decoration: InputDecoration(
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(15),
borderSide: BorderSide(
width: 2,
color: ColorConstants.colorGrey,
),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(15),
borderSide:
BorderSide(width: 2, color: ColorConstants.primaryColor),
),
hintText: "Enter your email",
hintStyle: TextStyle(
fontSize: 15,
color: ColorConstants.colorGrey,
fontWeight: FontWeight.w500),
suffixIcon: Icon(
Icons.email_outlined,
color: ColorConstants.primaryColor.withOpacity(0.5),
),
),
validator: (value) =>
Provider.of<LoginController>(context, listen: false)
.emailValidation(value!),
),
const SizedBox(
height: 30,
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
"Enter your password",
style: TextStyleConstants.dashboardBookingName,
)
],
),
const SizedBox(
height: 10,
),
TextFormField(
controller: controller.passwordController,
decoration: InputDecoration(
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(15),
borderSide:
BorderSide(width: 2, color: ColorConstants.colorGrey),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(15),
borderSide:
BorderSide(width: 2, color: ColorConstants.primaryColor),
),
hintText: "Pssword ",
hintStyle: TextStyle(
fontSize: 15,
color: ColorConstants.colorGrey,
fontWeight: FontWeight.w500),
suffixIcon: IconButton(
onPressed: () {
Provider.of<LoginController>(context, listen: false)
.togglePassword();
},
icon: Icon(
Icons.remove_red_eye_outlined,
color: ColorConstants.primaryColor.withOpacity(0.5),
),
),
),
obscureText: controller.hidePassword,
validator: (value) =>
Provider.of<LoginController>(context, listen: false)
.passwordValidation(value),
),
const SizedBox(
height: 20,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Checkbox(
activeColor: ColorConstants.primaryColor,
value: Provider.of<LoginController>(context)
.rememberCredentials,
onChanged: (value) {
Provider.of<LoginController>(context, listen: false)
.remember();
},
),
const Text("Remember")
],
),
InkWell(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const ForgotPasswordScreen(),
),
);
},
child: const Text("Forgot Password?"))
],
),
const SizedBox(
height: 15,
),
LoginButton(
buttonName: "Login",
onTap: () {
if (controller.loginFormKey.currentState!.validate()) {
Provider.of<LoginController>(context, listen: false)
.login(context);
}
},
),
],
),
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/authentication
|
mirrored_repositories/Hostel-Manager/lib/fetures/authentication/screens/signup_screen.dart
|
import 'package:flutter/material.dart';
import 'package:hostel_management_app/fetures/authentication/controllers/register_controller.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
import 'package:hostel_management_app/utils/image_constants.dart';
import 'package:hostel_management_app/utils/text_style_constatnts.dart';
import 'package:hostel_management_app/fetures/authentication/widgets/signin_form.dart';
import 'package:provider/provider.dart';
class SignupScreen extends StatelessWidget {
const SignupScreen({super.key});
@override
Widget build(BuildContext context) {
final controller = Provider.of<SignInController>(context);
return Scaffold(
body: Container(
height: double.infinity,
width: double.infinity,
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
ColorConstants.primaryWhiteColor,
ColorConstants.secondaryWhiteColor2,
],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
),
),
child: Center(
child: SafeArea(
child: Container(
height: MediaQuery.sizeOf(context).height * 85 / 100,
width: MediaQuery.sizeOf(context).width * 90 / 100,
decoration: BoxDecoration(
color: ColorConstants.primaryWhiteColor,
borderRadius: BorderRadius.circular(30),
),
padding: const EdgeInsets.only(left: 20, right: 20, bottom: 15),
child: SingleChildScrollView(
child: Column(
children: [
SizedBox(
height: 80,
width: 80,
child: Image.asset(ImageConstants.appLogo)),
const SizedBox(
height: 10,
),
Text(
"Sign up",
style: TextStyle(
color: ColorConstants.primaryColor,
fontSize: 25,
fontWeight: FontWeight.w700),
),
const SizedBox(
height: 10,
),
SignupForm(controller: controller),
const SizedBox(
height: 20,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
height: 1,
color: ColorConstants.colorGrey,
width: MediaQuery.sizeOf(context).width * 35 / 100,
),
Text(
"or",
style: TextStyle(color: ColorConstants.colorGrey),
),
Container(
height: 1,
width: MediaQuery.sizeOf(context).width * 35 / 100,
color: ColorConstants.colorGrey,
)
],
),
const SizedBox(
height: 10,
),
InkWell(
onTap: () =>
Provider.of<SignInController>(context, listen: false)
.signInWithGoogle(context),
child: Container(
height: 47,
padding: const EdgeInsets.symmetric(vertical: 14),
color: ColorConstants.secondaryWhiteColor,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset(ImageConstants.googleLogo),
const SizedBox(
width: 10,
),
Text(
"Sign in with Google",
style: TextStyleConstants.dashboardDate,
)
],
),
),
),
],
),
),
),
),
),
),
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/authentication
|
mirrored_repositories/Hostel-Manager/lib/fetures/authentication/screens/password_changed_screen.dart
|
import 'package:flutter/material.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
import 'package:hostel_management_app/utils/text_style_constatnts.dart';
import 'package:hostel_management_app/commens/widgets/login_button.dart';
import 'package:hostel_management_app/fetures/authentication/screens/login_screen.dart';
class PasswordChangedScreen extends StatelessWidget {
const PasswordChangedScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: ColorConstants.primaryWhiteColor,
body: Center(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
CircleAvatar(
radius: 50,
backgroundColor: ColorConstants.primaryColor,
child: Icon(
Icons.done,
size: 60,
color: ColorConstants.primaryWhiteColor,
),
),
const SizedBox(
height: 70,
),
Text(
"Password Changed !",
style: TextStyleConstants.loginTiltle,
),
const SizedBox(
height: 10,
),
Text(
"Your new password must be unique from those\n previously used",
textAlign: TextAlign.center,
style: TextStyleConstants.loginSubtitle1,
),
const SizedBox(
height: 70,
),
LoginButton(
buttonName: "Back to login",
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const LoginScreen(),
),
);
},
)
],
),
),
),
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/authentication
|
mirrored_repositories/Hostel-Manager/lib/fetures/authentication/screens/signup_successfull_page.dart
|
import 'package:flutter/material.dart';
import 'package:hostel_management_app/fetures/profile/screens/account_setup_screen.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
import 'package:hostel_management_app/utils/text_style_constatnts.dart';
class SignUpSuccessfullScree extends StatefulWidget {
const SignUpSuccessfullScree({super.key});
@override
State<SignUpSuccessfullScree> createState() => _SignUpSuccessfullScreeState();
}
class _SignUpSuccessfullScreeState extends State<SignUpSuccessfullScree> {
@override
void initState() {
Future.delayed(const Duration(seconds: 1)).then(
(value) {
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(
builder: (context) => const AccountSetupScreen(),
),
(route) => false);
},
);
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: ColorConstants.primaryWhiteColor,
body: Center(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
CircleAvatar(
radius: 50,
backgroundColor: ColorConstants.primaryColor,
child: Icon(
Icons.done,
size: 60,
color: ColorConstants.primaryWhiteColor,
),
),
const SizedBox(
height: 70,
),
Text(
"Sign Up \n Successfull",
style: TextStyleConstants.loginTiltle,
textAlign: TextAlign.center,
),
const SizedBox(
height: 10,
),
],
),
),
),
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/authentication
|
mirrored_repositories/Hostel-Manager/lib/fetures/authentication/screens/fogot_password_screen.dart
|
import 'package:flutter/material.dart';
import 'package:hostel_management_app/fetures/authentication/controllers/forgotpassword_controller.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
import 'package:hostel_management_app/utils/text_style_constatnts.dart';
import 'package:hostel_management_app/commens/widgets/login_button.dart';
import 'package:provider/provider.dart';
class ForgotPasswordScreen extends StatelessWidget {
const ForgotPasswordScreen({super.key});
@override
Widget build(BuildContext context) {
final controller = Provider.of<ForgotPasswordController>(context);
return Scaffold(
backgroundColor: ColorConstants.primaryWhiteColor,
body: Center(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Form(
key: controller.forgotPasswordFormKey,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
"Forgot Password?",
style: TextStyleConstants.loginTiltle,
),
const SizedBox(
height: 10,
),
Text(
"Don’t Worry ! It occurs . Please enter the email address \nlinked with your account",
textAlign: TextAlign.center,
style: TextStyleConstants.loginSubtitle1,
),
const SizedBox(
height: 70,
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
"Email",
style: TextStyleConstants.dashboardBookingName,
)
],
),
const SizedBox(
height: 10,
),
TextFormField(
controller: controller.emailController,
decoration: InputDecoration(
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(15),
borderSide: BorderSide(
width: 2,
color: ColorConstants.colorGrey,
),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(15),
borderSide: BorderSide(
width: 2, color: ColorConstants.primaryColor),
),
hintText: "Enter your email",
hintStyle: TextStyle(
fontSize: 15,
color: ColorConstants.colorGrey,
fontWeight: FontWeight.w500),
suffixIcon: Icon(
Icons.email_outlined,
color: ColorConstants.primaryColor.withOpacity(0.5),
),
),
validator: (value) => Provider.of<ForgotPasswordController>(
context,
listen: false)
.emailValidation(
value.toString(),
),
),
const SizedBox(
height: 20,
),
LoginButton(
buttonName: "Sent Code",
onTap: () {
if (controller.forgotPasswordFormKey.currentState!
.validate()) {
Provider.of<ForgotPasswordController>(context,
listen: false)
.sendPasswordResetEmail(context);
}
},
)
],
),
),
),
),
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/authentication
|
mirrored_repositories/Hostel-Manager/lib/fetures/authentication/screens/login_screen.dart
|
import 'package:flutter/material.dart';
import 'package:hostel_management_app/fetures/authentication/controllers/login_controller.dart';
import 'package:hostel_management_app/fetures/authentication/controllers/register_controller.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
import 'package:hostel_management_app/utils/image_constants.dart';
import 'package:hostel_management_app/utils/text_style_constatnts.dart';
import 'package:hostel_management_app/fetures/authentication/screens/signup_screen.dart';
import 'package:provider/provider.dart';
import '../widgets/login_form.dart';
class LoginScreen extends StatefulWidget {
const LoginScreen({super.key});
@override
State<LoginScreen> createState() => _LoginScreenState();
}
class _LoginScreenState extends State<LoginScreen> {
@override
void initState() {
Provider.of<LoginController>(context, listen: false)
.fetchStordCredentials();
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: ColorConstants.primaryWhiteColor,
body: SafeArea(
child: Padding(
padding: const EdgeInsets.only(left: 20, right: 20, top: 20),
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
"Welcome \n Back!",
style: TextStyleConstants.loginTiltle,
textAlign: TextAlign.center,
),
const SizedBox(
height: 20,
),
const LoginForm(),
const SizedBox(
height: 15,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text("Don't have an account? "),
TextButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const SignupScreen(),
),
);
},
child: const Text("Signup Now"))
],
),
const SizedBox(
height: 20,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
height: 1,
color: ColorConstants.colorGrey,
width: MediaQuery.sizeOf(context).width * 35 / 100,
),
Text(
"or",
style: TextStyle(color: ColorConstants.colorGrey),
),
Container(
height: 1,
width: MediaQuery.sizeOf(context).width * 35 / 100,
color: ColorConstants.colorGrey,
)
],
),
const SizedBox(
height: 20,
),
InkWell(
onTap: () {
Provider.of<SignInController>(context, listen: false)
.signInWithGoogle(context);
},
child: Container(
height: 47,
padding: const EdgeInsets.symmetric(vertical: 14),
color: ColorConstants.secondaryWhiteColor,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset(ImageConstants.googleLogo),
const SizedBox(
width: 10,
),
Text(
"Sign in with Google",
style: TextStyleConstants.dashboardDate,
)
],
),
),
),
const SizedBox(
height: 40,
),
],
),
),
),
),
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/authentication/screens
|
mirrored_repositories/Hostel-Manager/lib/fetures/authentication/screens/onboarding/onboarding_screen.dart
|
import 'package:flutter/material.dart';
import 'package:hostel_management_app/fetures/authentication/widgets/custom_clipper.dart';
import 'package:hostel_management_app/fetures/authentication/controllers/onboarding/onboaring_controller.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
import 'package:hostel_management_app/utils/text_style_constatnts.dart';
import 'package:provider/provider.dart';
import 'package:smooth_page_indicator/smooth_page_indicator.dart';
class OnBoardingScreen extends StatelessWidget {
const OnBoardingScreen({super.key});
@override
@override
Widget build(BuildContext context) {
OnBoardingController onBoardingController =
Provider.of<OnBoardingController>(context);
return Scaffold(
backgroundColor: ColorConstants.primaryWhiteColor,
body: Container(
height: MediaQuery.sizeOf(context).height,
width: MediaQuery.sizeOf(context).width,
color: ColorConstants.primaryWhiteColor,
child: Stack(
children: [
Positioned(
top: 0,
child: SizedBox(
width: MediaQuery.sizeOf(context).width,
height: MediaQuery.sizeOf(context).height * 2 / 3,
child: PageView(
onPageChanged: (value) {
Provider.of<OnBoardingController>(context, listen: false)
.onPageChange(index: value);
},
padEnds: true,
controller: onBoardingController.pageController,
children: List.generate(
onBoardingController.onBoardingScreens.length,
(index) => Image.asset(
onBoardingController.onBoardingScreens[index]['image'],
fit: BoxFit.cover,
),
),
),
),
),
Positioned(
top: MediaQuery.sizeOf(context).height * 50 / 100,
child: ClipPath(
clipper: MyCustomClipper(),
child: Container(
padding: const EdgeInsets.all(30),
width: MediaQuery.sizeOf(context).width,
height: MediaQuery.sizeOf(context).height * 50 / 100,
color: ColorConstants.primaryWhiteColor,
child: Column(
children: [
const SizedBox(
height: 55,
),
SmoothPageIndicator(
controller: onBoardingController.pageController,
count: 3,
onDotClicked: (index) =>
Provider.of<OnBoardingController>(context,
listen: false)
.onDotClicked(index),
effect: ExpandingDotsEffect(
activeDotColor: ColorConstants.primaryColor,
dotColor: ColorConstants.secondaryColor1,
dotHeight: 5,
dotWidth: 10.5,
),
),
const SizedBox(
height: 25,
),
SizedBox(
width: MediaQuery.sizeOf(context).width * 80 / 100,
child: Column(
children: [
SizedBox(
width:
MediaQuery.sizeOf(context).width * 65 / 100,
height:
MediaQuery.sizeOf(context).height * 10 / 100,
child: Column(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
onBoardingController.title1,
style: TextStyleConstants.onboardText1,
),
Text(
onBoardingController.title2,
style: TextStyleConstants.onboardText1,
)
],
),
),
const SizedBox(
height: 10,
),
SizedBox(
child: Text(
onBoardingController.description,
style: TextStyleConstants.onboardText2,
textAlign: TextAlign.center,
),
)
],
),
),
Expanded(
child: Center(
child: InkWell(
onTap: () => Provider.of<OnBoardingController>(
context,
listen: false)
.onTap(context),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: ColorConstants.primaryColor,
),
height: 40,
width: 150,
child: Center(
child: Text(
"Get now",
style: TextStyleConstants.buttonText,
),
),
),
),
),
)
],
),
),
),
)
],
),
),
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/authentication/screens
|
mirrored_repositories/Hostel-Manager/lib/fetures/authentication/screens/splash_screen/splash_screen.dart
|
import 'package:flutter/material.dart';
import 'package:hostel_management_app/fetures/authentication/controllers/screen_redirector.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
import 'package:hostel_management_app/utils/image_constants.dart';
class SplashScreen extends StatefulWidget {
const SplashScreen({super.key});
@override
State<SplashScreen> createState() => _SplashScreenState();
}
class _SplashScreenState extends State<SplashScreen> {
@override
void initState() {
Future.delayed(const Duration(seconds: 3))
.then((value) => Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(
builder: (context) => ScreenReDirector().redirectScreen(),
),
(route) => false));
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: ColorConstants.primaryWhiteColor,
body: Center(
child: SizedBox(
width: 150,
height: 142,
child: Image.asset(ImageConstants.appLogo)),
),
);
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/rooms
|
mirrored_repositories/Hostel-Manager/lib/fetures/rooms/controllers/rooms_repository.dart
|
// ignore_for_file: avoid_print
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:hostel_management_app/fetures/rooms/models/room_model.dart';
class RoomsRepository with ChangeNotifier {
final _db = FirebaseFirestore.instance;
final FirebaseAuth _auth = FirebaseAuth.instance;
//------------------------------------------------------------------------------fetch Rooms
Future<List<RoomModel>> fetchData() async {
try {
final userId = _auth.currentUser?.uid;
if (userId == null || userId.isEmpty) {
throw Exception("Unable to find user information, try again later");
}
final result =
await _db.collection("Owners").doc(userId).collection("Rooms").get();
final roomModels = result.docs
.map((documentSnapshot) => RoomModel.fromSnapshot(documentSnapshot))
.toList();
return roomModels;
} catch (e) {
print("Error: $e");
rethrow;
}
}
//----------------------------------------------------------------------------fetch single room
Future<RoomModel?> fetchSingleRoom({required String roomId}) async {
try {
final userId = _auth.currentUser?.uid;
if (userId == null || userId.isEmpty) {
throw Exception("Unable to find user information, try again later");
}
final result = await _db
.collection("Owners")
.doc(userId)
.collection("Rooms")
.doc(roomId)
.get();
if (result.exists) {
return RoomModel.fromSnapshot(result);
}
} catch (e) {
print("Error: $e");
rethrow;
}
return null;
}
Future<RoomModel?> getRoomByRoomNo(int roomNo) async {
try {
final userId = _auth.currentUser!.uid;
final querySnapshot = await _db
.collection("Owners")
.doc(userId)
.collection("Rooms")
.where("RoomNo", isEqualTo: roomNo)
.get();
if (querySnapshot.docs.isNotEmpty) {
// Room with the same number exists
final roomData = querySnapshot.docs.first;
return RoomModel.fromSnapshot(roomData);
} else {
// Room with the given number does not exist
return null;
}
} catch (e) {
print(e.toString());
return null;
}
}
//------------------------------------------------------------------------------Add new Room
addRoom(RoomModel room) async {
try {
final userId = _auth.currentUser!.uid;
await _db
.collection("Owners")
.doc(userId)
.collection("Rooms")
.add(room.toJson());
} catch (e) {
print(e.toString());
}
}
//----------------------------------------------------------------------------Update room
Future<void> updadatRoom(RoomModel room) async {
final userId = _auth.currentUser!.uid;
try {
await _db
.collection("Owners")
.doc(userId)
.collection("Rooms")
.doc(room.id)
.update(room.toJson());
} catch (e) {
print("Somthing went wrong");
}
}
//----------------------------------------------------------------------------update single field
Future<void> updateSingleField(
{required Map<String, dynamic> json, required String roomId}) async {
try {
final currentUser = _auth.currentUser;
await _db
.collection("Owners")
.doc(currentUser!.uid)
.collection("Rooms")
.doc(roomId)
.update(json);
} catch (e) {
print("Somthis went wrong");
print(e);
}
}
//--------------------------------------------------------------------------- Delete a room
Future<void> deleteRoom(String roomId) async {
try {
final userId = _auth.currentUser!.uid;
await _db
.collection("Owners")
.doc(userId)
.collection("Rooms")
.doc(roomId)
.delete();
} catch (e) {
print("somthing went wrong");
}
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/rooms
|
mirrored_repositories/Hostel-Manager/lib/fetures/rooms/controllers/rooms_controller.dart
|
// ignore_for_file: use_build_context_synchronously, avoid_print
import 'package:flutter/material.dart';
import 'package:hostel_management_app/fetures/bookings/controllers/bookings_repository.dart';
import 'package:hostel_management_app/commens/functions/connection_checher.dart';
import 'package:hostel_management_app/fetures/residents/controllers/residents_repository.dart';
import 'package:hostel_management_app/fetures/rooms/controllers/rooms_repository.dart';
import 'package:hostel_management_app/fetures/profile/controllers/user_repository.dart';
import 'package:hostel_management_app/fetures/profile/controllers/user_controller.dart';
import 'package:hostel_management_app/fetures/profile/models/owner_model.dart';
import 'package:hostel_management_app/fetures/residents/models/resident_model.dart';
import 'package:hostel_management_app/fetures/rooms/models/room_model.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
import 'package:hostel_management_app/utils/image_constants.dart';
class RoomsController with ChangeNotifier {
List<Map<String, String>> facilitiesList = [
{"Facility": "AC", "Image": ImageConstants.acIcon},
{"Facility": "WiFi", "Image": ImageConstants.wifiIcon},
{"Facility": "Washingmachine", "Image": ImageConstants.washingMachineIcon},
{"Facility": "Attached Bathroom", "Image": ImageConstants.bathroomIcon},
];
List<String> filters = [
"All Rooms",
"Vacant Rooms",
"Filled Rooms",
];
String selctedFilter = "All Rooms";
GlobalKey<FormState> formKey = GlobalKey<FormState>();
final roomNoController = TextEditingController();
final capacityController = TextEditingController();
final rentController = TextEditingController();
final RoomsRepository controller = RoomsRepository();
final ConnectionChecker connection = ConnectionChecker();
final UserController userController = UserController();
final UserRepository userRepoController = UserRepository();
final ResidentsRepository residentsRepository = ResidentsRepository();
final BookingRepository bookingRepository = BookingRepository();
int? oldRoomCapacity;
int? oldRoomVacancy;
int? currentNoOfResidents;
int? oldRoomNo;
String? editingRoomId;
bool isEditing = false;
bool isResidentLoading = false;
List<RoomModel> allRooms = [];
List<RoomModel> rooms = [];
List<RoomModel> vacantRooms = [];
List<int> facilities = [];
List<ResidentModel>? residents = [];
List<String> oldResidents = [];
bool isRoomsLoading = false;
bool acSelected = false;
bool wmSelected = false;
bool abSelected = false;
bool wfSelected = false;
//-------------------------------------------------------------------------------fetch room data
fetchRoomsData() async {
try {
isRoomsLoading = true;
allRooms = await controller.fetchData();
allRooms.sort((a, b) => a.roomNo.compareTo(b.roomNo));
rooms = allRooms;
isRoomsLoading = false;
} catch (e) {
rethrow;
} finally {
isRoomsLoading = false;
notifyListeners();
}
}
//----------------------------------------------------------------------------- fetching vacant rooms
fetchVacantRooms() async {
try {
isRoomsLoading = true;
List<RoomModel> allRooms = await controller.fetchData();
// Filter out vacant rooms (Vacancy > 0)
vacantRooms = allRooms.where((room) => room.vacancy > 0).toList();
vacantRooms.sort((a, b) => a.roomNo.compareTo(b.roomNo));
} catch (e) {
rethrow;
} finally {
isRoomsLoading = false;
notifyListeners();
}
}
//------------------------------------------------------------------------------fetch single room
Future<RoomModel?> fetchRoom(int roomNo) async {
try {
return await controller.getRoomByRoomNo(roomNo);
} catch (e) {
print(e);
}
return null;
}
//------------------------------------------------------------------------------fetchResidents
fetchResidents(List<String> residentIds) async {
try {
isResidentLoading = true;
residents = await residentsRepository.fetchResidentsByIds(residentIds);
} catch (e) {
rethrow;
} finally {
isResidentLoading = false;
notifyListeners();
}
}
//------------------------------------------------------------------------------clear residents
clearResidents() {
residents!.clear();
}
//----------------------------------------------------------------------------- add new room
addRoom(
{required BuildContext context,
required int currentCapacity,
required int currentVacancy}) async {
try {
final isConnected = await connection.isConnected();
if (!isConnected) {
ScaffoldMessenger.of(context)
.showSnackBar(const SnackBar(content: Text("Network error")));
}
final roomNo = int.parse(roomNoController.text.trim());
// Check if the room with the same number already exists
final existingRoom = await controller.getRoomByRoomNo(roomNo);
if (existingRoom != null) {
// Room with the same number already exists, handle accordingly
Navigator.pop(context);
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text("Room with the same number already exists")),
);
roomNoController.clear();
capacityController.clear();
rentController.clear();
userController.fetchData();
facilities = [];
acSelected = false;
wmSelected = false;
abSelected = false;
wfSelected = false;
notifyListeners();
return;
}
int noOfBeds = currentCapacity + int.parse(capacityController.text);
int noOfVacancy = currentVacancy + int.parse(capacityController.text);
await userRepoController
.accountSetup({"NoOfBeds": noOfBeds, "NoOfVacancy": noOfVacancy});
if (acSelected) {
facilities.add(0);
}
if (wfSelected) {
facilities.add(1);
}
if (wmSelected) {
facilities.add(2);
}
if (abSelected) {
facilities.add(3);
}
final room = RoomModel(
roomNo: int.parse(roomNoController.text.trim()),
capacity: int.parse(capacityController.text.trim()),
vacancy: int.parse(capacityController.text.trim()),
rent: int.parse(rentController.text.trim()),
residents: <String>[],
facilities: facilities);
//adding room
await controller.addRoom(room);
fetchRoomsData();
roomNoController.clear();
capacityController.clear();
rentController.clear();
facilities = [];
acSelected = false;
wmSelected = false;
abSelected = false;
wfSelected = false;
notifyListeners();
fetchRoomsData();
userController.fetchData();
Navigator.pop(context);
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text("Room Added Successfull")));
} catch (e) {
print(e.toString());
}
}
//----------------------------------------------------------------------------- Delete a room
deleteRoom(
{required BuildContext context,
required int currentCapacity,
required int currentVacancy,
required RoomModel room}) async {
try {
final isConnected = await connection.isConnected();
if (!isConnected) {
ScaffoldMessenger.of(context)
.showSnackBar(const SnackBar(content: Text("Network error")));
}
int noOfBeds = currentCapacity - room.capacity;
int vacacy = currentVacancy - room.vacancy;
await userRepoController
.accountSetup({"NoOfBeds": noOfBeds, "NoOfVacancy": vacacy});
if (room.residents.isEmpty) {
await residentsRepository.deleteListOfResidents(room.residents);
}
await bookingRepository.deleteBookingsByRoomNo(room.roomNo);
await residentsRepository.deleteResidentsByRoomNo(room.roomNo);
await controller.deleteRoom(room.id!);
Navigator.pop(context);
fetchRoomsData();
userController.fetchData();
} catch (e) {
print(e.toString());
}
}
//----------------------------------------------------------------------------Edit a room
editRoom(BuildContext context) async {
try {
if (currentNoOfResidents! > int.parse(capacityController.text.trim())) {
showDialog(
context: context,
builder: (context) => AlertDialog(
title: Text(
"Can't Edit the Room",
style: TextStyle(color: ColorConstants.colorRed),
),
content: const Text(
"This room has more occupents than the given capacity.change the capacity and try again!"),
actions: [
OutlinedButton(
onPressed: () {
Navigator.pop(context);
},
child: const Text("Try Again"))
],
));
return;
}
final isConnected = await connection.isConnected();
if (!isConnected) {
ScaffoldMessenger.of(context)
.showSnackBar(const SnackBar(content: Text("Network error")));
}
if (acSelected) {
facilities.add(0);
}
if (wfSelected) {
facilities.add(1);
}
if (wmSelected) {
facilities.add(2);
}
if (abSelected) {
facilities.add(3);
}
final roomVacancy =
int.parse(capacityController.text.trim()) - currentNoOfResidents!;
final OwnerModel? owner = await userRepoController.fetchOwnerRecords();
final currentHostelVacancy = owner!.noOfVacancy;
final currentHostelbeds = owner.noOfBeds;
final int hostelVacancy =
currentHostelVacancy - oldRoomVacancy! + roomVacancy;
final int noOfBeds = currentHostelbeds -
oldRoomCapacity! +
int.parse(capacityController.text);
await userRepoController
.accountSetup({"NoOfBeds": noOfBeds, "NoOfVacancy": hostelVacancy});
if (oldRoomNo != int.parse(roomNoController.text)) {
await residentsRepository.updateResidentsRoomNo(
oldRoomNo!, int.parse(roomNoController.text));
await bookingRepository.updateBookingsRoomNo(
oldRoomNo!, int.parse(roomNoController.text));
}
final room = RoomModel(
id: editingRoomId!,
roomNo: int.parse(roomNoController.text.trim()),
capacity: int.parse(capacityController.text.trim()),
vacancy: roomVacancy,
rent: int.parse(rentController.text.trim()),
residents: oldResidents,
facilities: facilities);
await controller.updadatRoom(room);
fetchRoomsData();
userController.fetchData();
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text("Room Edited Successfully")));
Navigator.pop(context);
facilities = [];
roomNoController.clear();
rentController.clear();
capacityController.clear();
acSelected = false;
wfSelected = false;
wmSelected = false;
abSelected = false;
isEditing = false;
notifyListeners();
userController.fetchData();
} catch (e) {
print("Somthing went wrong : $e");
}
}
//----------------------------------------------------------------------------edit tap
onEditTap({
required RoomModel room,
}) {
isEditing = true;
roomNoController.text = room.roomNo.toString();
capacityController.text = room.capacity.toString();
rentController.text = room.rent.toString();
oldRoomNo = room.roomNo;
oldRoomCapacity = room.capacity;
oldRoomVacancy = room.vacancy;
oldResidents = room.residents;
editingRoomId = room.id;
currentNoOfResidents = room.residents.length;
notifyListeners();
if (room.facilities.contains(0)) {
acSelected = true;
}
if (room.facilities.contains(1)) {
wfSelected = true;
}
if (room.facilities.contains(2)) {
wmSelected = true;
}
if (room.facilities.contains(3)) {
abSelected = true;
}
notifyListeners();
}
//------------------------------------------------------------------------------cancel button
cancel(BuildContext context) {
roomNoController.clear();
capacityController.clear();
rentController.clear();
facilities = [];
acSelected = false;
wmSelected = false;
abSelected = false;
wfSelected = false;
notifyListeners();
Navigator.pop(context);
}
onSelect(int num) {
switch (num) {
case 0:
{
acSelected = !acSelected;
notifyListeners();
}
break;
case 1:
{
wfSelected = !wfSelected;
notifyListeners();
}
break;
case 2:
{
wmSelected = !wmSelected;
notifyListeners();
}
break;
case 3:
{
abSelected = !abSelected;
notifyListeners();
}
break;
}
}
fieldValidation(value) {
if (value == null || value.isEmpty) {
return "this Field is required.";
} else {
return null;
}
}
//----------------------------------------------------------------------------filter Rooms
selectFilter(filter) async {
isResidentLoading = true;
selctedFilter = filter;
if (selctedFilter == "All Rooms") {
rooms = allRooms;
} else if (selctedFilter == "Vacant Rooms") {
rooms = allRooms.where((room) => room.vacancy > 0).toList();
} else if (selctedFilter == "Filled Rooms") {
rooms = allRooms.where((room) => room.vacancy == 0).toList();
}
isResidentLoading = false;
notifyListeners();
}
}
| 0
|
mirrored_repositories/Hostel-Manager/lib/fetures/rooms
|
mirrored_repositories/Hostel-Manager/lib/fetures/rooms/widgets/room_facilities_card.dart
|
import 'package:flutter/material.dart';
import 'package:hostel_management_app/utils/color_constants.dart';
import 'package:hostel_management_app/utils/text_style_constatnts.dart';
class RoomFacilitiesCard extends StatelessWidget {
const RoomFacilitiesCard({super.key, required this.name, required this.icon});
final String name;
final String icon;
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.only(right: 10),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(25),
color: ColorConstants.primaryWhiteColor),
padding: const EdgeInsets.only(right: 15),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
CircleAvatar(
radius: 20,
backgroundColor: ColorConstants.secondaryColor5,
child: SizedBox(
height: 22,
width: 22,
child: Image.asset(
icon,
color: ColorConstants.primaryWhiteColor,
)),
),
Text(
" $name",
style: TextStyleConstants.dashboardBookingName,
)
],
),
),
);
}
}
| 0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.