repo_id
stringlengths 21
168
| file_path
stringlengths 36
210
| content
stringlengths 1
9.98M
| __index_level_0__
int64 0
0
|
---|---|---|---|
mirrored_repositories/barber-booking/lib/app/modules | mirrored_repositories/barber-booking/lib/app/modules/profile/controller.dart | import 'package:barber_booking/app/data/enums/pages_states/profile_state.dart';
import 'package:barber_booking/app/data/model/user/user_extra_info.dart';
import 'package:barber_booking/app/data/services/firebase_service.dart';
import 'package:barber_booking/app/global_widgets/global_snackbar.dart';
import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
import '../../exports.dart';
class ProfileController extends GetxController
with GetTickerProviderStateMixin {
TextEditingController nameController = TextEditingController();
TextEditingController emailController = TextEditingController();
TextEditingController ageController = TextEditingController();
Rx<ProfileState> pageState = ProfileState.loadingToGetData.obs;
final Routes _routes = Get.find();
double pixelHolder = 0.0;
RxInt gender = 3.obs;
late AnimationController animationController;
late Animation<Offset> avatarAnimation;
late Animation<double> avatarFadeAnimation;
late Animation<Offset> fieldAnimation1;
late Animation<double> fieldFadeAnimation1;
late Animation<Offset> fieldAnimation2;
late Animation<double> fieldFadeAnimation2;
late Animation<Offset> emailFieldSlideAnimation;
late Animation<double> emailFieldFadeAnimation;
late Animation<Offset> genderSelectorAnimation;
late Animation<double> genderSelectorFadeAnimation;
late Animation<Offset> ageFieldAnimation;
late Animation<double> ageFieldFadeAnimation;
late Animation<Offset> buttonAnimation;
late Animation<double> buttonFadeAnimation;
final FirebaseService _firebaseService = Get.find();
@override
void onInit() {
getInitData().then((value) => initializeAnimations());
super.onInit();
}
@override
void onClose() {
animationController.dispose();
emailController.dispose();
nameController.dispose();
ageController.dispose();
super.onClose();
}
Future getInitData() async {
pageState(ProfileState.loadingToGetData);
getDisplayName();
getUserEmail();
getUserExtraInfo();
}
logout() async {
await _firebaseService.logout();
Get.offAllNamed(_routes.authRoute);
}
void getUserEmail() =>
emailController.text = _firebaseService.getUser()?.email ?? "";
String getPhotoUrl() =>
_firebaseService.getUser()?.photoURL ??
"https://media.istockphoto.com/vectors/avatar-5-vector-id1131164548?k=20&m=1131164548&s=612x612&w=0&h=ODVFrdVqpWMNA1_uAHX_WJu2Xj3HLikEnbof6M_lccA=";
void getDisplayName() =>
nameController.text = _firebaseService.getUser()?.displayName ?? "";
void getUserExtraInfo() async {
try {
UserExtraInfo? userInfo = await _firebaseService.getUserExtraInfo();
if (userInfo != null) {
ageController.text = userInfo.age.toString();
gender(userInfo.gender);
}
} catch (e) {
globalSnackbar(content: e.toString());
}
}
void updateProfile({email, name, photoUrl}) async {
try {
pageState(ProfileState.loadingToSubmitData);
bool status = await _firebaseService.updateUserBaseInfo(
email: email, name: name, photo: photoUrl);
bool extraStatus = await _firebaseService.updateUserExtraInfo(
age: int.parse(ageController.text), gender: gender.value);
if (status || extraStatus) {
Get.back();
} else {
globalSnackbar(content: "Failed please try again!");
}
pageState(ProfileState.submitDataSuccess);
} catch (e) {
pageState(ProfileState.submitDataFailed);
globalSnackbar(content: e.toString());
}
}
setManAsGender() => gender(1);
setWomanAsGender() => gender(0);
initializeAnimations() {
pageState(ProfileState.dataFetchedSuccess);
const duration = Duration(milliseconds: 800);
const beginOffset = Offset(0, .6);
animationController = AnimationController(vsync: this, duration: duration)
..forward();
avatarAnimation =
Tween<Offset>(begin: beginOffset, end: Offset.zero).animate(
CurvedAnimation(
parent: animationController,
curve: const Interval(.13, 1, curve: Curves.ease),
),
);
avatarFadeAnimation = Tween<double>(begin: 0, end: 1).animate(
CurvedAnimation(
parent: animationController,
curve: const Interval(.13, 1, curve: Curves.ease),
),
);
fieldAnimation1 =
Tween<Offset>(begin: beginOffset, end: Offset.zero).animate(
CurvedAnimation(
parent: animationController,
curve: const Interval(.33, 1, curve: Curves.ease),
),
);
fieldFadeAnimation1 = Tween<double>(begin: 0, end: 1).animate(
CurvedAnimation(
parent: animationController,
curve: const Interval(.33, 1, curve: Curves.ease),
),
);
fieldAnimation2 =
Tween<Offset>(begin: beginOffset, end: Offset.zero).animate(
CurvedAnimation(
parent: animationController,
curve: const Interval(.46, 1, curve: Curves.ease),
),
);
fieldFadeAnimation2 = Tween<double>(begin: 0, end: 1).animate(
CurvedAnimation(
parent: animationController,
curve: const Interval(.46, 1, curve: Curves.ease),
),
);
emailFieldSlideAnimation =
Tween<Offset>(begin: beginOffset, end: Offset.zero).animate(
CurvedAnimation(
parent: animationController,
curve: const Interval(.52, 1, curve: Curves.ease),
),
);
emailFieldFadeAnimation = Tween<double>(begin: 0, end: 1).animate(
CurvedAnimation(
parent: animationController,
curve: const Interval(.52, 1, curve: Curves.ease),
),
);
ageFieldAnimation =
Tween<Offset>(begin: beginOffset, end: Offset.zero).animate(
CurvedAnimation(
parent: animationController,
curve: const Interval(.59, 1, curve: Curves.ease),
),
);
ageFieldFadeAnimation = Tween<double>(begin: 0, end: 1).animate(
CurvedAnimation(
parent: animationController,
curve: const Interval(.59, 1, curve: Curves.ease),
),
);
genderSelectorAnimation =
Tween<Offset>(begin: beginOffset, end: Offset.zero).animate(
CurvedAnimation(
parent: animationController,
curve: const Interval(.72, 1, curve: Curves.ease),
),
);
genderSelectorFadeAnimation = Tween<double>(begin: 0, end: 1).animate(
CurvedAnimation(
parent: animationController,
curve: const Interval(.72, 1, curve: Curves.ease),
),
);
buttonAnimation =
Tween<Offset>(begin: beginOffset, end: Offset.zero).animate(
CurvedAnimation(
parent: animationController,
curve: const Interval(.85, 1, curve: Curves.ease),
),
);
buttonFadeAnimation = Tween<double>(begin: 0, end: 1).animate(
CurvedAnimation(
parent: animationController,
curve: const Interval(.85, 1, curve: Curves.ease),
),
);
}
}
| 0 |
mirrored_repositories/barber-booking/lib/app/modules | mirrored_repositories/barber-booking/lib/app/modules/profile/page.dart | import 'package:barber_booking/app/core/utils/size_config_helper.dart';
import 'package:barber_booking/app/core/values/dimes.dart';
import 'package:barber_booking/app/data/enums/pages_states/profile_state.dart';
import 'package:barber_booking/app/global_widgets/global_button.dart';
import 'package:barber_booking/app/global_widgets/global_form_field.dart';
import 'package:barber_booking/app/global_widgets/global_indicator.dart';
import 'package:barber_booking/app/global_widgets/optimized_text.dart';
import 'package:barber_booking/app/global_widgets/parent_widget.dart';
import 'package:barber_booking/app/modules/profile/local_widget/gender_selector.dart';
import 'package:barber_booking/app/modules/profile/local_widget/profile_avatar.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:ionicons/ionicons.dart';
import '../../core/values/colors.dart';
import '../../core/values/strings.dart';
import '../../routes/routes.dart';
import 'controller.dart';
// todo : create custom document for store gender and age
class ProfilePage extends StatelessWidget {
ProfilePage({Key? key}) : super(key: key);
final AppColors _colors = Get.find();
final Strings _strings = Get.find();
final Routes _routes = Get.find();
final Dimens _dimens = Get.find();
final ProfileController _profileController = Get.find();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(
_strings.profileTitle,
),
actions: [
IconButton(
onPressed: () {
_profileController.logout();
},
icon: Icon(
Ionicons.log_out_outline,
size: _dimens.defaultIconSize * 1.2,
),
),
],
),
body: Padding(
padding: EdgeInsets.symmetric(
horizontal: _dimens.defaultPadding * 4,
),
child: Obx(
() {
bool isLoading = _profileController.pageState.value ==
ProfileState.loadingToGetData;
return isLoading
? const Center(child: GlobalIndicator())
: ParentWidget(
child: Column(
children: [
SizedBox(
height: SizeConfig.heightMultiplier * 4,
),
Center(
child: FadeTransition(
opacity: _profileController.avatarFadeAnimation,
child: SlideTransition(
position: _profileController.avatarAnimation,
child: ProfileAvatar(),
),
),
),
SizedBox(
height: SizeConfig.heightMultiplier * 5,
),
FadeTransition(
opacity: _profileController.fieldFadeAnimation1,
child: SlideTransition(
position: _profileController.fieldAnimation1,
child: GlobalTextFormField(
controller: _profileController.nameController,
label: _strings.nameHint,
),
),
),
SizedBox(
height: SizeConfig.heightMultiplier * 1,
),
FadeTransition(
opacity: _profileController.fieldFadeAnimation2,
child: SlideTransition(
position: _profileController.fieldAnimation2,
child: GlobalTextFormField(
controller: _profileController.emailController,
label: _strings.emailHint,
),
),
),
SizedBox(
height: SizeConfig.heightMultiplier * 1,
),
FadeTransition(
opacity: _profileController.ageFieldFadeAnimation,
child: SlideTransition(
position: _profileController.ageFieldAnimation,
child: GlobalTextFormField(
controller: _profileController.ageController,
label: _strings.ageHint,
),
),
),
SizedBox(
height: SizeConfig.heightMultiplier * 2,
),
FadeTransition(
opacity:
_profileController.genderSelectorFadeAnimation,
child: SlideTransition(
position:
_profileController.genderSelectorAnimation,
child: GenderSelector(),
),
),
SizedBox(
height: SizeConfig.heightMultiplier * 4,
),
FadeTransition(
opacity: _profileController.buttonFadeAnimation,
child: SlideTransition(
position: _profileController.buttonAnimation,
child: GlobalButton(
child: Obx(
() => _profileController.pageState.value ==
ProfileState.loadingToSubmitData
? GlobalIndicator(
color: _colors.frostedBlack,
)
: OptimizedText(
_strings.profileSubmitBtn,
fontWeight: FontWeight.bold,
),
),
color: _colors.pastelCyan,
onPressed: () {
_profileController.updateProfile(
email:
_profileController.emailController.text,
name: _profileController.nameController.text,
);
},
height: _dimens.defaultButtonHeight,
radius: _dimens.defaultRadius,
),
),
),
SizedBox(
height: SizeConfig.heightMultiplier * 4,
),
],
),
);
},
),
),
);
}
}
| 0 |
mirrored_repositories/barber-booking/lib/app/modules/profile | mirrored_repositories/barber-booking/lib/app/modules/profile/local_widget/gender_selector.dart | import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:ionicons/ionicons.dart';
import '../../../core/values/colors.dart';
import '../../../core/values/dimes.dart';
import '../../../core/values/strings.dart';
import '../../../routes/routes.dart';
import '../controller.dart';
class GenderSelector extends StatelessWidget {
GenderSelector({Key? key}) : super(key: key);
final AppColors _colors = Get.find();
final Strings _strings = Get.find();
final Routes _routes = Get.find();
final Dimens _dimens = Get.find();
final ProfileController _profileController = Get.find();
@override
Widget build(BuildContext context) {
const duration = Duration(milliseconds: 300);
return Container(
margin: EdgeInsets.symmetric(vertical: _dimens.defaultMargin),
child: Obx(
() => Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
GestureDetector(
onTap: () => _profileController.setManAsGender(),
child: AnimatedContainer(
curve: Curves.easeOut,
decoration: BoxDecoration(
color: (_profileController.gender.value != 1)
? _colors.pastelCyan.withOpacity(.05)
: _colors.pastelCyan,
shape: BoxShape.circle,
),
duration: duration,
child: Padding(
padding: EdgeInsets.all(_dimens.defaultPadding * 3),
child: Icon(
Ionicons.man_outline,
size: _dimens.defaultIconSize * 2.5,
color: (_profileController.gender.value != 1)
? _colors.pastelCyan
: _colors.frostedBlack,
),
),
),
),
GestureDetector(
onTap: () => _profileController.setWomanAsGender(),
child: AnimatedContainer(
curve: Curves.easeOut,
duration: duration,
decoration: BoxDecoration(
color: (_profileController.gender.value != 0)
? _colors.pastelCyan.withOpacity(.05)
: _colors.pastelCyan,
shape: BoxShape.circle,
),
child: Padding(
padding: EdgeInsets.all(_dimens.defaultPadding * 3),
child: Icon(
Ionicons.woman_outline,
size: _dimens.defaultIconSize * 2.5,
color: (_profileController.gender.value != 0)
? _colors.pastelCyan
: _colors.frostedBlack,
),
),
),
),
],
),
),
);
}
}
| 0 |
mirrored_repositories/barber-booking/lib/app/modules/profile | mirrored_repositories/barber-booking/lib/app/modules/profile/local_widget/profile_avatar.dart | import 'package:barber_booking/app/core/values/dimes.dart';
import 'package:barber_booking/app/modules/profile/controller.dart';
import 'package:extended_image/extended_image.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../../core/utils/size_config_helper.dart';
import '../../../core/values/colors.dart';
import '../../../core/values/strings.dart';
class ProfileAvatar extends StatelessWidget {
ProfileAvatar({Key? key}) : super(key: key);
final Strings _strings = Get.find();
final AppColors _colors = Get.find();
final Dimens _dimens = Get.find();
final ProfileController _profileController = Get.find();
@override
Widget build(BuildContext context) {
return Hero(
tag: _strings.profileImageTag,
child: Material(
elevation: 0,
color: Colors.transparent,
borderRadius: BorderRadius.circular(_dimens.defaultRadius * 2),
clipBehavior: Clip.hardEdge,
child: ExtendedImage.network(
_profileController.getPhotoUrl(),
width: SizeConfig.widthMultiplier * 35,
height: SizeConfig.widthMultiplier * 35,
fit: BoxFit.contain,
cache: true,
shape: BoxShape.circle,
handleLoadingProgress: true,
),
),
);
}
}
| 0 |
mirrored_repositories/barber-booking/lib/app/modules | mirrored_repositories/barber-booking/lib/app/modules/barber_shop_profile/controller.dart | import 'package:barber_booking/app/data/services/firebase_service.dart';
import 'package:barber_booking/app/global_widgets/global_snackbar.dart';
import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
import '../../data/model/barber_shop/barber_shop.dart';
import '../../exports.dart';
class BarberShopProfileController extends GetxController
with GetTickerProviderStateMixin {
final BarberShopModel _barberShopItemModel = Get.arguments;
final FirebaseService _firebaseService = Get.find();
final Routes _routes = Get.find();
late AnimationController animationController;
late Animation<double> fadeLikeButtonAnimation;
late Animation<Offset> slideLikeButtonAnimation;
late Animation<double> fadeTagsAnimation;
late Animation<Offset> slideTagsAnimation;
late Animation<double> fadeDescriptionAnimation;
late Animation<Offset> slideDescriptionAnimation;
late Animation<double> fadeBookButtonAnimation;
late Animation<Offset> slideBookButtonAnimation;
RxBool likeStatus = false.obs;
@override
void onInit() {
initializeAnimatoins();
getBarberShopStatus();
super.onInit();
}
@override
void onClose() {
animationController.dispose();
super.onClose();
}
void submitAppointment(barberShopId) async {
try {
_firebaseService
.submitNewBooking(barberShopId)
.then((value) => Get.toNamed(_routes.announce, arguments: false))
.catchError((e) {
globalSnackbar(content: e.toString());
});
} catch (e) {
globalSnackbar(content: e.toString());
}
}
void getBarberShopStatus() async => likeStatus(await _firebaseService
.checkBarberShopLikeStatus(_barberShopItemModel.id));
void likeBarberShop() async {
_firebaseService
.likeBarberShop(_barberShopItemModel.id)
.then((value) => likeStatus(!likeStatus.value))
.catchError((error) {
globalSnackbar(content: error);
});
}
void initializeAnimatoins() {
const duration = Duration(milliseconds: 600);
const beginOffset = Offset(0, .6);
animationController = AnimationController(vsync: this, duration: duration)
..forward();
slideLikeButtonAnimation =
Tween<Offset>(begin: beginOffset, end: Offset.zero).animate(
CurvedAnimation(
parent: animationController,
curve: const Interval(.13, 1, curve: Curves.ease),
),
);
fadeLikeButtonAnimation = Tween<double>(begin: 0, end: 1).animate(
CurvedAnimation(
parent: animationController,
curve: const Interval(.13, 1, curve: Curves.ease),
),
);
slideTagsAnimation =
Tween<Offset>(begin: beginOffset, end: Offset.zero).animate(
CurvedAnimation(
parent: animationController,
curve: const Interval(.33, 1, curve: Curves.ease),
),
);
fadeTagsAnimation = Tween<double>(begin: 0, end: 1).animate(
CurvedAnimation(
parent: animationController,
curve: const Interval(.33, 1, curve: Curves.ease),
),
);
slideDescriptionAnimation =
Tween<Offset>(begin: beginOffset, end: Offset.zero).animate(
CurvedAnimation(
parent: animationController,
curve: const Interval(.46, 1, curve: Curves.ease),
),
);
fadeDescriptionAnimation = Tween<double>(begin: 0, end: 1).animate(
CurvedAnimation(
parent: animationController,
curve: const Interval(.46, 1, curve: Curves.ease),
),
);
slideBookButtonAnimation =
Tween<Offset>(begin: beginOffset, end: Offset.zero).animate(
CurvedAnimation(
parent: animationController,
curve: const Interval(.59, 1, curve: Curves.ease),
),
);
fadeBookButtonAnimation = Tween<double>(begin: 0, end: 1).animate(
CurvedAnimation(
parent: animationController,
curve: const Interval(.59, 1, curve: Curves.ease),
),
);
}
}
| 0 |
mirrored_repositories/barber-booking/lib/app/modules | mirrored_repositories/barber-booking/lib/app/modules/barber_shop_profile/page.dart | import 'package:barber_booking/app/core/utils/size_config_helper.dart';
import 'package:barber_booking/app/core/values/dimes.dart';
import 'package:barber_booking/app/data/model/barber_shop/barber_shop.dart';
import 'package:barber_booking/app/global_widgets/global_button.dart';
import 'package:barber_booking/app/global_widgets/optimized_text.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../core/values/colors.dart';
import '../../core/values/strings.dart';
import '../../routes/routes.dart';
import 'controller.dart';
import 'local_widget/barber_shop_description.dart';
class BarberShopProfile extends StatelessWidget {
BarberShopProfile({Key? key, required this.item}) : super(key: key);
final BarberShopModel item;
final AppColors _colors = Get.find();
final Strings _strings = Get.find();
final Routes _routes = Get.find();
final Dimens _dimens = Get.find();
final BarberShopProfileController _profileController = Get.find();
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
children: [
CustomScrollView(
slivers: [
SliverAppBar(
expandedHeight: 250.0,
pinned: true,
floating: true,
backgroundColor: _colors.frostedBlack,
flexibleSpace: FlexibleSpaceBar(
centerTitle: true,
title: Text(
item.title,
style: TextStyle(color: _colors.lightTxtColor),
),
background: Stack(
children: [
Image.network(
item.imageUrl,
fit: BoxFit.fill,
),
Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Colors.transparent,
_colors.frostedBlack,
],
),
),
),
],
),
),
),
SliverList(
delegate: SliverChildListDelegate([
BarberShopDescriptionWidget(item: item),
]),
),
],
),
SlideTransition(
position: _profileController.slideBookButtonAnimation,
child: FadeTransition(
opacity: _profileController.fadeBookButtonAnimation,
child: Align(
alignment: Alignment.bottomCenter,
child: GlobalButton(
width: SizeConfig.widthMultiplier * 80,
height: _dimens.defaultButtonHeight,
child: OptimizedText("Booking"),
color: _colors.pastelCyan,
onPressed: () {
_profileController.submitAppointment(item.id);
},
radius: _dimens.defaultRadius,
),
),
),
),
],
),
);
}
}
| 0 |
mirrored_repositories/barber-booking/lib/app/modules/barber_shop_profile | mirrored_repositories/barber-booking/lib/app/modules/barber_shop_profile/local_widget/barber_shop_description.dart | import 'package:barber_booking/app/data/model/barber_shop/barber_shop.dart';
import 'package:barber_booking/app/exports.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:ionicons/ionicons.dart';
import '../../../core/utils/size_config_helper.dart';
import '../../../data/enums/text_color_option.dart';
import '../../../data/enums/text_size_option.dart';
import '../../../global_widgets/optimized_text.dart';
import '../controller.dart';
class BarberShopDescriptionWidget extends StatelessWidget {
BarberShopDescriptionWidget({Key? key, required this.item}) : super(key: key);
final BarberShopModel item;
final AppColors _colors = Get.find();
final Strings _strings = Get.find();
final Routes _routes = Get.find();
final Dimens _dimens = Get.find();
final BarberShopProfileController _profileController = Get.find();
@override
Widget build(BuildContext context) {
return Padding(
padding: EdgeInsets.all(_dimens.defaultPadding * 3),
child: Column(
children: [
SlideTransition(
position: _profileController.slideLikeButtonAnimation,
child: FadeTransition(
opacity: _profileController.fadeLikeButtonAnimation,
child: Row(
children: [
Expanded(
child: Column(
children: [
OptimizedText(
item.subTitle,
colorOption: TextColorOptions.light,
textAlign: TextAlign.start,
sizeOption: TextSizeOptions.caption,
maxLine: 2,
),
ratingWidget(),
],
),
),
SizedBox(
width: SizeConfig.widthMultiplier * 2,
),
// likeButton(),
],
),
),
),
SizedBox(height: SizeConfig.heightMultiplier * 2),
tagsWidget(),
SizedBox(height: SizeConfig.heightMultiplier * 2),
SlideTransition(
position: _profileController.slideDescriptionAnimation,
child: FadeTransition(
opacity: _profileController.fadeDescriptionAnimation,
child: OptimizedText(
item.description,
colorOption: TextColorOptions.light,
maxLine: 100,
textAlign: TextAlign.justify,
),
),
),
SizedBox(
height: SizeConfig.heightMultiplier * 8,
),
],
),
);
}
tagsWidget() => SlideTransition(
position: _profileController.slideTagsAnimation,
child: FadeTransition(
opacity: _profileController.fadeTagsAnimation,
child: Wrap(
alignment: WrapAlignment.start,
crossAxisAlignment: WrapCrossAlignment.start,
runAlignment: WrapAlignment.start,
children: [
for (int i = 0; i < item.tags.length; i++)
Container(
margin: EdgeInsets.all(_dimens.defaultMargin * .3),
padding: EdgeInsets.all(_dimens.defaultPadding),
decoration: BoxDecoration(
color: _colors.pastelCyan.withOpacity(.2),
borderRadius: BorderRadius.circular(
_dimens.defaultRadius,
),
),
child: Text(
" ${item.tags[i]} ",
style: TextStyle(
color: _colors.pastelCyan,
fontWeight: FontWeight.bold,
),
),
),
],
),
),
);
ratingWidget() => Row(
children: [
for (int i = 0; i < 5; i++)
Icon(
Ionicons.star,
color: _colors.starColor,
size: 12,
),
const SizedBox(
width: 5,
),
const Text("37 ratings")
],
);
likeButton() => Obx(
() => GestureDetector(
onTap: () => _profileController.likeBarberShop(),
child: Container(
decoration: BoxDecoration(
color: _colors.pastelCyan,
shape: BoxShape.circle,
),
child: Padding(
padding: EdgeInsets.all(_dimens.defaultPadding * 2),
child: Icon(
Ionicons.heart,
color: _profileController.likeStatus.value
? _colors.likedHearth
: _colors.frostedBlack,
)),
),
),
);
}
| 0 |
mirrored_repositories/barber-booking/lib/app/modules | mirrored_repositories/barber-booking/lib/app/modules/story/controller.dart | import 'dart:async';
import 'package:barber_booking/app/data/model/story/story.dart';
import 'package:barber_booking/app/data/services/firebase_service.dart';
import 'package:barber_booking/app/global_widgets/global_snackbar.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:get/get.dart';
class StoryController extends GetxController {
late Timer _timer;
RxInt timerLimit = 0.obs;
final FirebaseService _firebaseService = Get.find();
final StoryModel item = Get.arguments;
RxBool storyLiked = false.obs;
@override
void onInit() {
calculateLikeStatus().then((value) => timerInitialize());
super.onInit();
}
@override
void onClose() {
_timer.cancel();
super.onClose();
}
Future calculateLikeStatus() async {
try {
User? user = _firebaseService.getUser();
print(item.likes);
if (item.likes.contains(user?.uid)) {
storyLiked(true);
} else {
storyLiked(false);
}
} catch (e) {
globalSnackbar(content: e.toString());
}
}
Future likeStory() async {
try {
storyLiked(!storyLiked.value);
await _firebaseService.likeStory(item.id);
} catch (e) {
globalSnackbar(content: e.toString());
}
}
Future seenStory() async {
try {
await _firebaseService.seenStory(item.id);
} catch (e) {
globalSnackbar(content: e.toString());
}
}
timerInitialize() {
const onSecond = Duration(seconds: 1);
_timer = Timer.periodic(onSecond, (timer) {
if (timerLimit.value == 10) {
seenStory().then((value) {
Get.back();
onClose();
}).catchError((e) {
globalSnackbar(
content:
"Internet connection error , please check your connection");
});
} else {
timerLimit++;
}
});
}
}
| 0 |
mirrored_repositories/barber-booking/lib/app/modules | mirrored_repositories/barber-booking/lib/app/modules/story/page.dart | import 'package:barber_booking/app/core/utils/size_config_helper.dart';
import 'package:barber_booking/app/data/model/story/story.dart';
import 'package:barber_booking/app/modules/story/controller.dart';
import 'package:barber_booking/app/modules/story/local_widget/bottom_bar.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../core/values/colors.dart';
import '../../core/values/dimes.dart';
import '../../core/values/strings.dart';
import '../../routes/routes.dart';
import 'local_widget/back_button.dart';
class StoryPage extends StatelessWidget {
StoryPage({
Key? key,
required this.item,
}) : super(key: key);
final StoryModel item;
final AppColors _colors = Get.find();
final Strings _strings = Get.find();
final Routes _routes = Get.find();
final Dimens _dimens = Get.find();
final StoryController _storyController = Get.find();
@override
Widget build(BuildContext context) {
return Stack(
children: [
SizedBox(
height: SizeConfig.heightMultiplier * 100,
child: Image.network(
item.image,
fit: BoxFit.cover,
),
),
StoryBackButton(),
BottomBar(),
],
);
}
}
| 0 |
mirrored_repositories/barber-booking/lib/app/modules/story | mirrored_repositories/barber-booking/lib/app/modules/story/local_widget/bottom_bar.dart | import 'package:barber_booking/app/modules/story/local_widget/comments_bottom_sheet.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:ionicons/ionicons.dart';
import '../../../core/utils/size_config_helper.dart';
import '../../../core/values/colors.dart';
import '../../../core/values/dimes.dart';
import '../../../core/values/strings.dart';
import '../../../routes/routes.dart';
import '../controller.dart';
class BottomBar extends StatelessWidget {
BottomBar({Key? key}) : super(key: key);
final AppColors _colors = Get.find();
final Strings _strings = Get.find();
final Routes _routes = Get.find();
final Dimens _dimens = Get.find();
final StoryController _storyController = Get.find();
showBottomSheet(child, context) {
showModalBottomSheet(
isScrollControlled: true,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(
top: Radius.circular(_dimens.defaultRadius),
),
),
context: context,
builder: (context) => child);
}
@override
Widget build(BuildContext context) {
return Align(
alignment: Alignment.bottomCenter,
child: SizedBox(
width: SizeConfig.widthMultiplier * 100,
height: SizeConfig.heightMultiplier * 8,
child: Stack(
children: [
Align(
alignment: Alignment.bottomCenter,
child: SizedBox(
width: SizeConfig.widthMultiplier * 100,
height: SizeConfig.heightMultiplier * 8,
child: Material(
color: _colors.frostedBlack,
elevation: 0,
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: _dimens.defaultPadding * 2),
child: Row(
children: [
IconButton(
onPressed: () {
_storyController.likeStory();
},
icon: Obx(
() => Icon(
_storyController.storyLiked.value
? Ionicons.heart
: Ionicons.heart_outline,
color: _storyController.storyLiked.value
? _colors.likedHearth
: null,
size: _dimens.defaultIconSize * 1.2,
),
),
),
SizedBox(
width: SizeConfig.widthMultiplier * 3,
),
IconButton(
onPressed: () {
showBottomSheet(CommentsBottomSheet(), context);
},
icon: Icon(
Ionicons.chatbox_ellipses_outline,
size: _dimens.defaultIconSize * 1.2,
),
),
],
),
),
),
),
),
Obx(() => Align(
alignment: Alignment.topLeft,
child: AnimatedContainer(
width: SizeConfig.widthMultiplier *
(_storyController.timerLimit.value * 10),
height: 5,
decoration: BoxDecoration(
color: _colors.pastelCyan,
borderRadius: BorderRadius.circular(
_dimens.defaultRadius,
),
),
duration: const Duration(seconds: 1),
),
)),
],
),
),
);
}
}
| 0 |
mirrored_repositories/barber-booking/lib/app/modules/story | mirrored_repositories/barber-booking/lib/app/modules/story/local_widget/comments_bottom_sheet.dart | import 'package:barber_booking/app/core/utils/size_config_helper.dart';
import 'package:barber_booking/app/global_widgets/global_form_field.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../../core/values/colors.dart';
import '../../../core/values/dimes.dart';
import '../../../core/values/strings.dart';
import '../../../global_widgets/bottom_sheet_line.dart';
class CommentsBottomSheet extends StatelessWidget {
CommentsBottomSheet({Key? key}) : super(key: key);
final AppColors _colors = Get.find();
final Strings _strings = Get.find();
final Dimens _dimens = Get.find();
@override
Widget build(BuildContext context) {
return SizedBox(
height: SizeConfig.heightMultiplier * 50,
child: Padding(
padding: EdgeInsets.all(_dimens.defaultPadding),
child: Stack(
children: [
Align(alignment: Alignment.topCenter, child: BottomSheetLine()),
Column(
children: [
Padding(
padding: EdgeInsets.symmetric(
vertical: _dimens.defaultPadding * 4,
horizontal: _dimens.defaultPadding,
),
child: GlobalTextFormField(
controller: TextEditingController(), label: "Comment"),
),
],
),
],
),
),
);
}
}
| 0 |
mirrored_repositories/barber-booking/lib/app/modules/story | mirrored_repositories/barber-booking/lib/app/modules/story/local_widget/back_button.dart | import 'dart:io';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../../core/values/colors.dart';
import '../../../core/values/dimes.dart';
class StoryBackButton extends StatelessWidget {
StoryBackButton({Key? key}) : super(key: key);
final AppColors _colors = Get.find();
final Dimens _dimens = Get.find();
@override
Widget build(BuildContext context) {
return SafeArea(
child: Container(
margin: EdgeInsets.all(_dimens.defaultMargin),
child: GestureDetector(
onTap: () => Get.back(),
child: ClipRRect(
borderRadius: BorderRadius.circular(_dimens.defaultRadius * 100),
child: Container(
color: _colors.frostedBlack,
child: Padding(
padding: EdgeInsets.all(_dimens.defaultPadding * 3),
child: Icon(
(Platform.isIOS || Platform.isMacOS)
? Icons.arrow_back_ios
: Icons.arrow_back,
color: _colors.lightTxtColor,
),
),
),
),
),
),
);
}
}
| 0 |
mirrored_repositories/barber-booking/lib/app/modules | mirrored_repositories/barber-booking/lib/app/modules/home/controller.dart | import 'dart:math';
import 'package:barber_booking/app/data/services/firebase_service.dart';
import 'package:barber_booking/app/data/services/location_service.dart';
import 'package:barber_booking/app/global_widgets/global_snackbar.dart';
import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:get/get.dart';
import 'package:ionicons/ionicons.dart';
import "package:latlong2/latlong.dart";
import '../../core/utils/size_config_helper.dart';
import '../../data/enums/pages_states/home_state.dart';
import '../../exports.dart';
class HomeController extends GetxController {
final FirebaseService _firebaseService = Get.find();
final CustomLocationService _customLocationService = Get.find();
late MapController mapController;
RxBool navItemPressed = false.obs;
RxBool getLocationLoading = true.obs;
Set<Marker> markers = {};
Rx<HomeState> pageState = HomeState.initial.obs;
final AppColors _colors = Get.find();
final Strings _strings = Get.find();
final Routes _routes = Get.find();
@override
void onInit() {
createExtraInfoDocument();
initializeMapController();
checkLocationStatus();
checkUserVerificationState();
super.onInit();
}
String getPhotoUrl() => _firebaseService.getUser()?.photoURL ?? "";
void createExtraInfoDocument() async =>
_firebaseService.createExtraInfoDocumetnation();
initializeMapController() => mapController = MapController();
checkUserVerificationState() async {
try {
bool verificationState =
await _firebaseService.checkUserVerificationState();
if (verificationState) {
pageState(HomeState.userVerified);
} else {
_firebaseService.sendVerificationEmail().then((value) {
globalSnackbar(
content: _strings.verificationEmailSentTitle,
snackPosition: SnackPosition.BOTTOM,
);
});
showVerificationSnackBar();
pageState(HomeState.userNotVerified);
}
} catch (e) {
pageState(HomeState.userNotVerified);
globalSnackbar(content: e.toString());
}
}
showVerificationSnackBar() {
if (!Get.isSnackbarOpen) {
globalSnackbar(
content:
"User not verified , please verify email and press check button",
isPermanet: true,
snackPosition: SnackPosition.TOP,
dismissDirection: DismissDirection.up,
onTap: () {
checkUserVerificationState();
},
);
}
}
createListOfRandomDistance() {
var rng = Random();
var list = List.generate(3, (_) => rng.nextInt(10));
return list.map((e) => e / 200);
}
addUserLocationMarker() {
Marker userLocationMarker = Marker(
width: 80.0,
height: 80.0,
point: LatLng(
userPosition.latitude,
userPosition.longitude,
),
builder: (ctx) => Icon(
Ionicons.pin_sharp,
color: _colors.pastelCyan,
size: SizeConfig.widthMultiplier * 10,
),
);
markers.add(userLocationMarker);
}
createFakeBarberShopNearUser() {
var distances = createListOfRandomDistance();
for (var element in distances) {
Marker newMarker = Marker(
width: 80.0,
height: 80.0,
point: LatLng(
userPosition.latitude + element,
userPosition.longitude - element,
),
builder: (ctx) => GestureDetector(
onTap: () => mapController.move(
LatLng(userPosition.latitude + element,
userPosition.longitude - element),
12),
child: Icon(
Ionicons.location,
color: _colors.pastelCyan,
size: SizeConfig.widthMultiplier * 10,
),
),
);
markers.add(newMarker);
}
}
checkLocationStatus() async {
try {
await addUserLocationMarker();
await createFakeBarberShopNearUser();
getLocationLoading(false);
} catch (e, s) {
getLocationLoading(false);
print(e);
print(s);
}
}
pressNavItem() => navItemPressed(true);
releaseNavItem() => navItemPressed(false);
}
| 0 |
mirrored_repositories/barber-booking/lib/app/modules | mirrored_repositories/barber-booking/lib/app/modules/home/page.dart | import 'package:barber_booking/app/core/values/secret.dart';
import 'package:barber_booking/app/global_widgets/global_indicator.dart';
import 'package:barber_booking/app/modules/home/controller.dart';
import 'package:barber_booking/app/modules/home/local_widget/custom_bottom_nav.dart';
import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:get/get.dart';
import "package:latlong2/latlong.dart";
import '../../core/values/colors.dart';
import '../../core/values/strings.dart';
import '../../data/services/location_service.dart';
import '../../routes/routes.dart';
class HomePage extends StatelessWidget {
HomePage({Key? key}) : super(key: key);
final AppColors _colors = Get.find();
final Strings _strings = Get.find();
final Routes _routes = Get.find();
final HomeController _homeController = Get.find();
final CustomLocationService _customLocationService = Get.find();
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
children: [
Obx(
() {
if (_homeController.getLocationLoading.value) {
return const GlobalIndicator();
}
return FlutterMap(
mapController: _homeController.mapController,
options: MapOptions(
center: LatLng(
userPosition.latitude,
userPosition.longitude,
),
zoom: 13.0,
),
layers: [
TileLayerOptions(
urlTemplate: darkMapUrl,
subdomains: ['a', 'b', 'c'],
attributionBuilder: (_) {
return Container();
},
),
MarkerLayerOptions(
markers: _homeController.markers.toList(),
),
],
);
},
),
Align(alignment: Alignment.bottomCenter, child: CustomBottomNav()),
],
),
);
}
}
| 0 |
mirrored_repositories/barber-booking/lib/app/modules/home | mirrored_repositories/barber-booking/lib/app/modules/home/local_widget/bottom_nav_item.dart | import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:ionicons/ionicons.dart';
import '../../../core/values/colors.dart';
import '../../../core/values/dimes.dart';
import '../../../core/values/strings.dart';
import '../../../routes/routes.dart';
import '../controller.dart';
class BottomNavItem extends StatelessWidget {
BottomNavItem(
{Key? key, this.customWidget, this.iconData, required this.onTap})
: super(key: key);
final Widget? customWidget;
final IconData? iconData;
final VoidCallback onTap;
final AppColors _colors = Get.find();
final Strings _strings = Get.find();
final Routes _routes = Get.find();
final Dimens _dimens = Get.find();
final HomeController _homeController = Get.find();
@override
Widget build(BuildContext context) {
return GestureDetector(
onTapDown: (details) {
_homeController.pressNavItem();
},
onTapUp: (details) {
_homeController.releaseNavItem();
},
onTap: onTap,
child: customWidget ??
Icon(
iconData ?? Ionicons.sad_outline,
size: _dimens.defaultIconSize,
),
);
}
}
| 0 |
mirrored_repositories/barber-booking/lib/app/modules/home | mirrored_repositories/barber-booking/lib/app/modules/home/local_widget/custom_bottom_nav.dart | import 'dart:ui';
import 'package:barber_booking/app/core/values/dimes.dart';
import 'package:barber_booking/app/modules/home/controller.dart';
import 'package:barber_booking/app/modules/home/local_widget/bottom_nav_item.dart';
import 'package:barber_booking/app/modules/home/local_widget/profile_nav_item.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:ionicons/ionicons.dart';
import '../../../core/values/colors.dart';
import '../../../core/values/strings.dart';
import '../../../data/enums/pages_states/home_state.dart';
import '../../../routes/routes.dart';
class CustomBottomNav extends StatelessWidget {
CustomBottomNav({Key? key}) : super(key: key);
final AppColors _colors = Get.find();
final Strings _strings = Get.find();
final Routes _routes = Get.find();
final Dimens _dimens = Get.find();
final HomeController _homeController = Get.find();
@override
Widget build(BuildContext context) {
return SafeArea(
child: Padding(
padding: EdgeInsets.symmetric(horizontal: _dimens.defaultPadding * 3),
child: Obx(
() => AnimatedScale(
scale: _homeController.navItemPressed.value ? .90 : 1,
duration: const Duration(seconds: 1),
child: Container(
margin: EdgeInsets.all(_dimens.defaultMargin * 2),
height: _dimens.defaultButtonHeight,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(_dimens.defaultRadius),
// color: _colors.ericBlack,
color: Colors.white.withOpacity(.08),
),
child: ClipRRect(
borderRadius: BorderRadius.circular(_dimens.defaultRadius),
child: BackdropFilter(
filter: ImageFilter.blur(
sigmaX: 20,
sigmaY: 20,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
BottomNavItem(
onTap: () {
if (_homeController.pageState.value ==
HomeState.userVerified) {
Get.toNamed(_routes.appointments);
} else {
_homeController.showVerificationSnackBar();
}
},
iconData: Ionicons.time_sharp,
),
BottomNavItem(
onTap: () {
if (_homeController.pageState.value ==
HomeState.userVerified) {
Get.toNamed(_routes.newsRoute);
} else {
_homeController.showVerificationSnackBar();
}
},
iconData: Ionicons.newspaper,
),
BottomNavItem(
onTap: () {
if (_homeController.pageState.value ==
HomeState.userVerified) {
Get.toNamed(_routes.nearestBarberShop);
} else {
_homeController.showVerificationSnackBar();
}
},
iconData: Ionicons.navigate,
),
BottomNavItem(
onTap: () {
Get.toNamed(_routes.profileRoute);
},
customWidget: ProfileNavItem(),
),
],
),
),
),
),
),
),
),
);
}
}
| 0 |
mirrored_repositories/barber-booking/lib/app/modules/home | mirrored_repositories/barber-booking/lib/app/modules/home/local_widget/profile_nav_item.dart | import 'package:barber_booking/app/core/utils/size_config_helper.dart';
import 'package:barber_booking/app/modules/home/controller.dart';
import 'package:extended_image/extended_image.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../../core/values/colors.dart';
import '../../../core/values/dimes.dart';
import '../../../core/values/strings.dart';
import '../../../routes/routes.dart';
class ProfileNavItem extends StatelessWidget {
ProfileNavItem({Key? key}) : super(key: key);
final AppColors _colors = Get.find();
final Strings _strings = Get.find();
final Routes _routes = Get.find();
final Dimens _dimens = Get.find();
final HomeController _homeController = Get.find();
@override
Widget build(BuildContext context) {
return Hero(
tag: _strings.profileImageTag,
child: Material(
elevation: 0,
color: Colors.transparent,
borderRadius: BorderRadius.circular(_dimens.defaultRadius * 2),
clipBehavior: Clip.hardEdge,
child: ExtendedImage.network(
_homeController.getPhotoUrl(),
width: SizeConfig.widthMultiplier * 8,
height: SizeConfig.widthMultiplier * 8,
fit: BoxFit.contain,
cache: true,
shape: BoxShape.circle,
handleLoadingProgress: true,
loadStateChanged: (ExtendedImageState state) {
if (state.extendedImageLoadState == LoadState.failed) {
return Image.asset("assets/images/user.png");
}
},
),
),
);
}
}
| 0 |
mirrored_repositories/barber-booking/lib/app/modules | mirrored_repositories/barber-booking/lib/app/modules/splash/controller.dart | import 'package:barber_booking/app/data/services/firebase_service.dart';
import 'package:barber_booking/app/global_widgets/global_snackbar.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../data/enums/pages_states/splash_state.dart';
import '../../exports.dart';
class SplashController extends GetxController with GetTickerProviderStateMixin {
final FirebaseService _firebaseService = Get.find();
final Routes _routes = Get.find();
late Animation<double> scaleAnimation;
late AnimationController scaleAnimationController;
late Animation<double> fadeAnimationText;
late Animation<Offset> alignAnimationText;
late Animation<double> fadeAnimationButton;
late Animation<Offset> alignAnimationButton;
late AnimationController fadeAnimationController;
Rx<SplashState> pageState = SplashState.initial.obs;
@override
void onClose() {
disposeAnimations();
super.onClose();
}
@override
void onInit() {
initilizedAnimations();
super.onInit();
}
void checkUserAuthentication() async {
try {
bool authState = await _firebaseService.checkUserState();
if (authState) {
Get.offAndToNamed(_routes.homeRoute);
} else {
Get.offAndToNamed(_routes.authRoute);
}
} catch (e) {
globalSnackbar(content: e.toString());
}
}
void disposeAnimations() {
scaleAnimationController.dispose();
fadeAnimationController.dispose();
}
void initilizedAnimations() {
const Duration scaleDuration = Duration(seconds: 2);
const Duration fadeDuration = Duration(milliseconds: 800);
fadeAnimationController =
AnimationController(vsync: this, duration: fadeDuration);
scaleAnimationController =
AnimationController(vsync: this, duration: scaleDuration)
..forward().whenComplete(() {
fadeAnimationController.forward();
scaleAnimationController.reverse();
});
fadeAnimationText = Tween<double>(begin: 0, end: 1).animate(
CurvedAnimation(
parent: fadeAnimationController,
curve: const Interval(.2, 1, curve: Curves.ease),
),
);
alignAnimationText =
Tween<Offset>(begin: const Offset(0.0, 0.05), end: Offset.zero).animate(
CurvedAnimation(
parent: fadeAnimationController,
curve: const Interval(.2, 1, curve: Curves.ease),
),
);
fadeAnimationButton = Tween<double>(begin: 0, end: 1).animate(
CurvedAnimation(
parent: fadeAnimationController,
curve: const Interval(.8, 1, curve: Curves.ease),
),
);
alignAnimationButton =
Tween<Offset>(begin: const Offset(0.0, 0.05), end: Offset.zero).animate(
CurvedAnimation(
parent: fadeAnimationController,
curve: const Interval(.8, 1, curve: Curves.ease),
),
);
scaleAnimation =
Tween<double>(begin: 1.1, end: 1).animate(scaleAnimationController);
}
}
| 0 |
mirrored_repositories/barber-booking/lib/app/modules | mirrored_repositories/barber-booking/lib/app/modules/splash/page.dart | import 'package:barber_booking/app/core/utils/size_config_helper.dart';
import 'package:barber_booking/app/core/values/colors.dart';
import 'package:barber_booking/app/core/values/dimes.dart';
import 'package:barber_booking/app/core/values/strings.dart';
import 'package:barber_booking/app/global_widgets/optimized_text.dart';
import 'package:barber_booking/app/modules/splash/controller.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../global_widgets/global_button.dart';
import '../../routes/routes.dart';
class SplashPage extends StatelessWidget {
final AppColors _colors = Get.find();
final Strings _strings = Get.find();
final Routes _routes = Get.find();
final Dimens _dimens = Get.find();
final SplashController _splashController = Get.find();
SplashPage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
children: [
ScaleTransition(
scale: _splashController.scaleAnimation,
child: Image.asset(
"assets/images/barber_splash.png",
fit: BoxFit.cover,
height: SizeConfig.heightMultiplier * 100,
),
),
SlideTransition(
position: _splashController.alignAnimationText,
child: FadeTransition(
opacity: _splashController.fadeAnimationText,
child: SafeArea(
child: Align(
alignment: Alignment.bottomCenter,
child: Container(
margin: EdgeInsets.only(bottom: _dimens.defaultMargin * 15),
child: OptimizedText(
_strings.startDescription,
customColor: _colors.lightTxtColor,
maxLine: 3,
),
),
),
),
),
),
SlideTransition(
position: _splashController.alignAnimationButton,
child: FadeTransition(
opacity: _splashController.fadeAnimationButton,
child: Padding(
padding: EdgeInsets.all(_dimens.defaultPadding),
child: SafeArea(
child: Align(
alignment: Alignment.bottomCenter,
child: GlobalButton(
child: OptimizedText(
_strings.startButton,
fontWeight: FontWeight.bold,
),
color: _colors.pastelCyan,
onPressed: () {
_splashController.checkUserAuthentication();
},
radius: _dimens.defaultRadius,
height: _dimens.defaultButtonHeight,
width: SizeConfig.widthMultiplier * 70,
),
),
),
),
),
),
],
),
);
}
}
| 0 |
mirrored_repositories/barber-booking/lib/app/modules | mirrored_repositories/barber-booking/lib/app/modules/nearest_barber_shop/controller.dart | import 'package:barber_booking/app/data/model/barber_shop/barber_shop.dart';
import 'package:barber_booking/app/data/services/firebase_service.dart';
import 'package:barber_booking/app/data/services/location_service.dart';
import 'package:barber_booking/app/global_widgets/global_snackbar.dart';
import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
import '../../data/enums/pages_states/nearest_barber_state.dart';
class NearestBarberShopController extends GetxController
with GetTickerProviderStateMixin {
final FirebaseService _firebaseService = Get.find();
final CustomLocationService _customLocationService = Get.find();
late AnimationController animationController;
late Animation<double> fadeSearchBarAnimation;
late Animation<Offset> slideSearchBarAnimation;
late Animation<double> fadeSearchResultAnimation;
late Animation<Offset> slideSearchResultAnimation;
RxList<BarberShopModel> barberShopsList = <BarberShopModel>[].obs;
RxList<BarberShopModel> filteredList = <BarberShopModel>[].obs;
RxString searchQuery = ''.obs;
Rx<NearestBarberState> pageState = NearestBarberState.init.obs;
getFilteredItems(String query) {
clearFilteredList();
List<BarberShopModel> temp = barberShopsList;
filteredList(temp
.where((element) =>
element.title.toLowerCase().contains(query.toLowerCase()))
.toList());
}
bool getStateOfBarberShop(String startTime, String endTime) {
DateTime now = DateTime.now();
DateTime start = DateTime(now.year, now.month, now.day,
int.parse(startTime.split(":")[0]), int.parse(startTime.split(":")[1]));
DateTime end = DateTime(now.year, now.month, now.day,
int.parse(endTime.split(":")[0]), int.parse(endTime.split(":")[1]));
if (start.isBefore(now) && end.isAfter(now)) {
return true;
} else {
return false;
}
}
clearQuery() => searchQuery("");
updateQuery(String query) => searchQuery(query);
clearFilteredList() => filteredList.clear();
getAllBarberShops() async {
try {
pageState(NearestBarberState.barberShopsLoading);
List<BarberShopModel> data = await _firebaseService.getAllBarberShops();
barberShopsList.addAll(data);
pageState(NearestBarberState.barberShopsLoadedSuccess);
} catch (e) {
pageState(NearestBarberState.barberShopsLoadingFailed);
globalSnackbar(content: e.toString());
}
}
@override
void onInit() {
getAllBarberShops();
getStateOfBarberShop("10:00", "23:00");
const duration = Duration(milliseconds: 600);
const beginOffset = Offset(0, .6);
animationController = AnimationController(vsync: this, duration: duration)
..forward();
slideSearchBarAnimation =
Tween<Offset>(begin: beginOffset, end: Offset.zero).animate(
CurvedAnimation(
parent: animationController,
curve: const Interval(.13, 1, curve: Curves.ease),
),
);
fadeSearchBarAnimation = Tween<double>(begin: 0, end: 1).animate(
CurvedAnimation(
parent: animationController,
curve: const Interval(.13, 1, curve: Curves.ease),
),
);
slideSearchResultAnimation =
Tween<Offset>(begin: beginOffset, end: Offset.zero).animate(
CurvedAnimation(
parent: animationController,
curve: const Interval(.33, 1, curve: Curves.ease),
),
);
fadeSearchResultAnimation = Tween<double>(begin: 0, end: 1).animate(
CurvedAnimation(
parent: animationController,
curve: const Interval(.33, 1, curve: Curves.ease),
),
);
super.onInit();
}
@override
void onClose() {
animationController.dispose();
super.onClose();
}
}
| 0 |
mirrored_repositories/barber-booking/lib/app/modules | mirrored_repositories/barber-booking/lib/app/modules/nearest_barber_shop/page.dart | import 'package:barber_booking/app/core/utils/size_config_helper.dart';
import 'package:barber_booking/app/core/values/dimes.dart';
import 'package:barber_booking/app/data/enums/text_color_option.dart';
import 'package:barber_booking/app/data/enums/text_size_option.dart';
import 'package:barber_booking/app/global_widgets/optimized_text.dart';
import 'package:barber_booking/app/modules/nearest_barber_shop/controller.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../core/values/colors.dart';
import '../../core/values/strings.dart';
import '../../routes/routes.dart';
import 'local_widget/barber_shops_line.dart';
import 'local_widget/nearest_barber_shop_search_bar.dart';
class NearestBarberShop extends StatelessWidget {
NearestBarberShop({Key? key}) : super(key: key);
final AppColors _colors = Get.find();
final Strings _strings = Get.find();
final Routes _routes = Get.find();
final Dimens _dimens = Get.find();
final NearestBarberShopController _nearestBarberShopController = Get.find();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: Padding(
padding: EdgeInsets.symmetric(horizontal: _dimens.defaultPadding * 2),
child: Column(
children: [
SlideTransition(
position: _nearestBarberShopController.slideSearchBarAnimation,
child: FadeTransition(
opacity: _nearestBarberShopController.fadeSearchBarAnimation,
child: NearBarberShopSearchBar(),
),
),
SizedBox(
height: SizeConfig.heightMultiplier * 2,
),
SlideTransition(
position: _nearestBarberShopController.slideSearchResultAnimation,
child: FadeTransition(
opacity: _nearestBarberShopController.fadeSearchResultAnimation,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: OptimizedText(
"Search results",
colorOption: TextColorOptions.light,
textAlign: TextAlign.start,
fontWeight: FontWeight.bold,
sizeOption: TextSizeOptions.bigBody,
),
),
Expanded(
child: Obx(() => OptimizedText(
"${_nearestBarberShopController.barberShopsList.length} results",
colorOption: TextColorOptions.light,
textAlign: TextAlign.end,
sizeOption: TextSizeOptions.caption,
)),
),
],
),
),
),
BarberShopsItemsList(),
],
),
),
);
}
}
| 0 |
mirrored_repositories/barber-booking/lib/app/modules/nearest_barber_shop | mirrored_repositories/barber-booking/lib/app/modules/nearest_barber_shop/local_widget/barber_shop_item.dart | import 'package:barber_booking/app/data/enums/text_color_option.dart';
import 'package:barber_booking/app/data/model/barber_shop/barber_shop.dart';
import 'package:barber_booking/app/global_widgets/optimized_text.dart';
import 'package:barber_booking/app/modules/nearest_barber_shop/controller.dart';
import 'package:extended_image/extended_image.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:ionicons/ionicons.dart';
import '../../../core/utils/distance_calculator.dart';
import '../../../core/utils/size_config_helper.dart';
import '../../../core/values/colors.dart';
import '../../../core/values/dimes.dart';
import '../../../data/services/location_service.dart';
import '../../../routes/routes.dart';
import 'barber_shop_item_painter.dart';
class BarberShopItem extends StatelessWidget {
final bool isUpperWidget;
final BarberShopModel item;
BarberShopItem({Key? key, required this.isUpperWidget, required this.item})
: super(key: key);
final Dimens _dimens = Get.find();
final AppColors _colors = Get.find();
final Routes _routes = Get.find();
final NearestBarberShopController _nearestBarberShopController = Get.find();
final CustomLocationService _customLocationService = Get.find();
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () => Get.toNamed(_routes.barberShopProfile, arguments: item),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Container(
width: SizeConfig.widthMultiplier * 100,
height: 190,
color: Colors.transparent,
child: CustomPaint(
painter: BarberShopItemPainter(isUpperWidget: isUpperWidget),
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: _dimens.defaultPadding * 3),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Material(
borderRadius:
BorderRadius.circular(_dimens.defaultRadius * .4),
clipBehavior: Clip.hardEdge,
child: ExtendedImage.network(
item.imageUrl,
height: 130,
width: 90,
fit: BoxFit.cover,
),
),
Expanded(
child: Container(
margin:
EdgeInsets.only(left: _dimens.defaultMargin * 2),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
titleWidget(),
SizedBox(
height: SizeConfig.heightMultiplier * 2,
),
Row(
children: [
openStatusWidget(),
SizedBox(
width: SizeConfig.widthMultiplier * 4,
),
workTimeWidget(),
],
),
SizedBox(
height: SizeConfig.heightMultiplier,
),
ratingWidget(),
SizedBox(
height: SizeConfig.heightMultiplier,
),
separatorWidget(),
SizedBox(
height: SizeConfig.heightMultiplier,
),
locationWidget(),
],
),
),
),
],
),
),
),
),
if (!isUpperWidget) const SizedBox(height: 20),
],
),
);
}
separatorWidget() => Row(
children: [
Container(
width: 50,
height: 2,
decoration: BoxDecoration(
color: _colors.pastelCyan,
borderRadius: BorderRadius.circular(
_dimens.defaultRadius,
),
),
),
],
);
titleWidget() => OptimizedText(
item.title,
colorOption: TextColorOptions.light,
textAlign: TextAlign.start,
fontWeight: FontWeight.bold,
);
// todo : calculate rating for here
ratingWidget() => Row(
children: [
for (int i = 0; i < 5; i++)
Icon(
Ionicons.star,
color: _colors.starColor,
size: 12,
),
const SizedBox(
width: 5,
),
const Text("37 ratings")
],
);
openStatusWidget() {
bool status = _nearestBarberShopController.getStateOfBarberShop(
item.startWorkTime, item.endWorkTime);
return Row(
children: [
Container(
width: 10,
height: 10,
decoration: BoxDecoration(
color: status ? _colors.barberOpen : _colors.barberClose,
shape: BoxShape.circle,
),
),
const SizedBox(
width: 5,
),
Text(_nearestBarberShopController.getStateOfBarberShop(
item.startWorkTime, item.endWorkTime)
? "Open"
: "Close")
],
);
}
workTimeWidget() => Row(
children: [
const Icon(
Ionicons.time,
size: 13,
),
const SizedBox(
width: 5,
),
Text(
"${item.startWorkTime.toString()} - ${item.endWorkTime.toString()}"),
],
);
locationWidget() => Row(
children: [
const Icon(
Ionicons.location_outline,
size: 15,
),
const SizedBox(
width: 5,
),
Text(
distanceBetweenTwoPoints(
lat1: item.lat,
lon1: item.long,
myLat: userPosition.latitude,
mylon: userPosition.longitude,
),
),
],
);
}
| 0 |
mirrored_repositories/barber-booking/lib/app/modules/nearest_barber_shop | mirrored_repositories/barber-booking/lib/app/modules/nearest_barber_shop/local_widget/nearest_barber_shop_search_bar.dart | import 'package:barber_booking/app/modules/nearest_barber_shop/controller.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:ionicons/ionicons.dart';
import '../../../core/values/colors.dart';
import '../../../core/values/strings.dart';
import '../../../routes/routes.dart';
class NearBarberShopSearchBar extends StatelessWidget {
NearBarberShopSearchBar({Key? key}) : super(key: key);
final AppColors _colors = Get.find();
final Strings _strings = Get.find();
final Routes _routes = Get.find();
final NearestBarberShopController _nearestBarberShopController = Get.find();
@override
Widget build(BuildContext context) {
return TextFormField(
decoration: const InputDecoration(
prefixIcon: Icon(Ionicons.search),
label: Text("Barber shop"),
contentPadding: EdgeInsets.zero,
floatingLabelAlignment: FloatingLabelAlignment.start,
),
onChanged: (value) {
if (value.isEmpty) {
_nearestBarberShopController.clearQuery();
_nearestBarberShopController.clearFilteredList();
} else {
_nearestBarberShopController.updateQuery(value);
_nearestBarberShopController.getFilteredItems(value);
}
},
);
}
}
| 0 |
mirrored_repositories/barber-booking/lib/app/modules/nearest_barber_shop | mirrored_repositories/barber-booking/lib/app/modules/nearest_barber_shop/local_widget/barber_shop_item_painter.dart | import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../../core/values/colors.dart';
import '../../../core/values/dimes.dart';
class BarberShopItemPainter extends CustomPainter {
final bool isUpperWidget;
final AppColors _colors = Get.find();
final Dimens _dimens = Get.find();
BarberShopItemPainter({required this.isUpperWidget});
@override
void paint(Canvas canvas, Size size) {
var paint = Paint();
var path = Path();
paint
..color = _colors.lightBorder.withOpacity(.1)
..style = PaintingStyle.fill;
const radiusStop = 30.0;
if (isUpperWidget) {
path.moveTo(0, radiusStop);
path.quadraticBezierTo(0, 0, size.width * .1, 0);
path.lineTo(size.width * .9, 0);
path.quadraticBezierTo(size.width, 0, size.width * 1, radiusStop);
path.lineTo(size.width, size.height * .75);
path.quadraticBezierTo(size.width, size.height * .90,
size.width - radiusStop, size.height * .90);
path.lineTo(radiusStop, size.height);
path.quadraticBezierTo(0, size.height, 0, size.height - radiusStop);
} else {
path.moveTo(size.width, size.height - radiusStop);
path.quadraticBezierTo(
size.width, size.height, size.width - radiusStop, size.height);
path.lineTo(radiusStop, size.height);
path.quadraticBezierTo(0, size.height, 0, size.height - radiusStop);
path.lineTo(0, size.height * .25);
path.quadraticBezierTo(0, size.height * .1, radiusStop, size.height * .1);
path.lineTo(size.width - radiusStop, 0);
path.quadraticBezierTo(size.width, 0, size.width, radiusStop);
}
path.close();
canvas.drawPath(path, paint);
}
@override
bool shouldRepaint(covariant CustomPainter oldDelegate) => true;
}
| 0 |
mirrored_repositories/barber-booking/lib/app/modules/nearest_barber_shop | mirrored_repositories/barber-booking/lib/app/modules/nearest_barber_shop/local_widget/barber_shops_line.dart | import 'package:barber_booking/app/global_widgets/global_error.dart';
import 'package:barber_booking/app/global_widgets/global_indicator.dart';
import 'package:barber_booking/app/modules/nearest_barber_shop/controller.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../../core/values/dimes.dart';
import '../../../data/enums/pages_states/nearest_barber_state.dart';
import 'barber_shop_item.dart';
class BarberShopsItemsList extends StatelessWidget {
BarberShopsItemsList({Key? key}) : super(key: key);
final Dimens _dimens = Get.find();
final NearestBarberShopController _nearestBarberShopController = Get.find();
@override
Widget build(BuildContext context) {
return Expanded(
child: Obx(() {
bool loading = _nearestBarberShopController.pageState.value ==
NearestBarberState.barberShopsLoading;
bool failed = _nearestBarberShopController.pageState.value ==
NearestBarberState.barberShopsLoadingFailed;
List itemsList = (_nearestBarberShopController.searchQuery.value == "")
? _nearestBarberShopController.barberShopsList
: _nearestBarberShopController.filteredList;
return loading
? const GlobalIndicator()
: failed
? GlobalErrorWidget(
onTap: (() =>
_nearestBarberShopController.getAllBarberShops()))
: ListView.builder(
padding: EdgeInsets.only(top: _dimens.defaultPadding * 3),
itemCount: itemsList.length,
itemBuilder: (context, index) {
return BarberShopItem(
isUpperWidget: (index % 2 == 0),
item: itemsList[index],
);
},
);
}),
);
}
}
| 0 |
mirrored_repositories/barber-booking/lib/app/modules | mirrored_repositories/barber-booking/lib/app/modules/authentication/controller.dart | import 'package:barber_booking/app/data/services/firebase_service.dart';
import 'package:barber_booking/app/data/services/location_service.dart';
import 'package:barber_booking/app/global_widgets/global_snackbar.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../data/enums/pages_states/authentication_state.dart';
import '../../exports.dart';
class AuthenticationController extends GetxController
with GetTickerProviderStateMixin {
final Strings _strings = Get.find();
final Routes _routes = Get.find();
final FirebaseService _firebaseService = Get.find();
// animations variables
late Animation<double> titleAnimation;
late Animation<double> imageAnimation;
late Animation<double> descriptionAnimation;
late Animation<double> registerBtnAnimation;
late Animation<double> loginBtnAnimation;
late Animation<double> termsAnimation;
late Animation<Offset> titleSlideAnimation;
late Animation<Offset> imageSlideAnimation;
late Animation<Offset> descriptionSlideAnimation;
late Animation<Offset> registerBtnSlideAnimation;
late Animation<Offset> loginBtnSlideAnimation;
late Animation<Offset> termsSlideAnimation;
late AnimationController fadeAnimationController;
// animations variables
late TextEditingController emailController;
late TextEditingController passwordController;
Rx<AuthenticationState> pageState = AuthenticationState.initial.obs;
@override
void onInit() {
emailController = TextEditingController();
passwordController = TextEditingController();
initializeAnimation();
super.onInit();
}
@override
void onClose() {
clearControllers();
super.onClose();
}
void login(String email, String password) async {
try {
pageState(AuthenticationState.loginLoading);
CustomLocationService.determinePosition().then((value) async {
UserCredential? userCredential =
await _firebaseService.loginUser(email: email, password: password);
if (userCredential != null) {
if (userCredential.user!.emailVerified) {
Get.offAndToNamed(_routes.homeRoute);
} else {
pageState(AuthenticationState.loginError);
globalSnackbar(content: "Please verify email!");
}
} else {
pageState(AuthenticationState.loginError);
}
}).catchError((e) {
globalSnackbar(content: e.toString());
pageState(AuthenticationState.loginError);
});
} catch (e) {
globalSnackbar(content: e.toString());
pageState(AuthenticationState.loginError);
}
}
void socialLogin() async {
try {
pageState(AuthenticationState.socialLoading);
UserCredential? userCredential =
await _firebaseService.signInWithGoogle();
if (userCredential != null) {
Get.offAndToNamed(_routes.homeRoute);
} else {
pageState(AuthenticationState.socialError);
}
} catch (e) {
globalSnackbar(content: e.toString());
pageState(AuthenticationState.socialError);
}
}
void register(String email, String password) async {
try {
pageState(AuthenticationState.registerLoading);
UserCredential? userCredential =
await _firebaseService.registerUser(email: email, password: password);
if (userCredential != null) {
await _firebaseService.sendVerificationEmail();
Get.back();
globalSnackbar(content: _strings.verificationEmailAlarmTitle);
pageState(AuthenticationState.registerSuccessful);
} else {
pageState(AuthenticationState.registerError);
}
} catch (e) {
globalSnackbar(content: e.toString());
pageState(AuthenticationState.registerError);
}
}
void clearControllers() {
fadeAnimationController.dispose();
emailController.dispose();
passwordController.dispose();
}
void initializeAnimation() {
const duration = Duration(milliseconds: 600);
const startOffset = Offset(0.0, .2);
const endOffset = Offset.zero;
fadeAnimationController =
AnimationController(vsync: this, duration: duration)..forward();
titleAnimation = Tween<double>(begin: 0, end: 1).animate(CurvedAnimation(
parent: fadeAnimationController,
curve: const Interval(0.2, 1, curve: Curves.easeInExpo),
));
titleSlideAnimation = Tween<Offset>(begin: startOffset, end: endOffset)
.animate(CurvedAnimation(
parent: fadeAnimationController,
curve: const Interval(0.2, 1, curve: Curves.ease),
));
imageAnimation = Tween<double>(begin: 0, end: 1).animate(CurvedAnimation(
parent: fadeAnimationController,
curve: const Interval(0.4, 1, curve: Curves.ease),
));
imageSlideAnimation = Tween<Offset>(begin: startOffset, end: endOffset)
.animate(CurvedAnimation(
parent: fadeAnimationController,
curve: const Interval(0.4, 1, curve: Curves.ease),
));
descriptionAnimation =
Tween<double>(begin: 0, end: 1).animate(CurvedAnimation(
parent: fadeAnimationController,
curve: const Interval(0.6, 1, curve: Curves.ease),
));
descriptionSlideAnimation =
Tween<Offset>(begin: startOffset, end: endOffset)
.animate(CurvedAnimation(
parent: fadeAnimationController,
curve: const Interval(0.6, 1, curve: Curves.ease),
));
registerBtnAnimation =
Tween<double>(begin: 0, end: 1).animate(CurvedAnimation(
parent: fadeAnimationController,
curve: const Interval(0.7, 1, curve: Curves.ease),
));
registerBtnSlideAnimation =
Tween<Offset>(begin: startOffset, end: endOffset)
.animate(CurvedAnimation(
parent: fadeAnimationController,
curve: const Interval(0.7, 1, curve: Curves.ease),
));
loginBtnAnimation = Tween<double>(begin: 0, end: 1).animate(CurvedAnimation(
parent: fadeAnimationController,
curve: const Interval(0.8, 1, curve: Curves.ease),
));
loginBtnSlideAnimation = Tween<Offset>(begin: startOffset, end: endOffset)
.animate(CurvedAnimation(
parent: fadeAnimationController,
curve: const Interval(0.8, 1, curve: Curves.ease),
));
termsAnimation = Tween<double>(begin: 0, end: 1).animate(CurvedAnimation(
parent: fadeAnimationController,
curve: const Interval(0.9, 1, curve: Curves.ease),
));
termsSlideAnimation = Tween<Offset>(begin: startOffset, end: endOffset)
.animate(CurvedAnimation(
parent: fadeAnimationController,
curve: const Interval(0.9, 1, curve: Curves.ease),
));
}
}
| 0 |
mirrored_repositories/barber-booking/lib/app/modules | mirrored_repositories/barber-booking/lib/app/modules/authentication/page.dart | import 'package:barber_booking/app/core/utils/size_config_helper.dart';
import 'package:barber_booking/app/core/values/dimes.dart';
import 'package:barber_booking/app/global_widgets/global_button.dart';
import 'package:barber_booking/app/global_widgets/optimized_text.dart';
import 'package:barber_booking/app/global_widgets/parent_widget.dart';
import 'package:barber_booking/app/modules/authentication/controller.dart';
import 'package:barber_booking/app/modules/authentication/local_widget/auth_bottom_sheet.dart';
import 'package:barber_booking/app/modules/authentication/local_widget/barber_title.dart';
import 'package:barber_booking/app/modules/authentication/local_widget/terms_conditions_section.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../core/values/colors.dart';
import '../../core/values/strings.dart';
import '../../routes/routes.dart';
class AuthenticationPage extends StatelessWidget {
AuthenticationPage({Key? key}) : super(key: key);
final AppColors _colors = Get.find();
final Strings _strings = Get.find();
final Routes _routes = Get.find();
final Dimens _dimens = Get.find();
final AuthenticationController _authenticationController = Get.find();
showBottomSheet(child, context) {
showModalBottomSheet(
isScrollControlled: true,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(
top: Radius.circular(_dimens.defaultRadius),
),
),
context: context,
builder: (context) => child);
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: ParentWidget(
child: Padding(
padding: EdgeInsets.all(_dimens.defaultPadding),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SlideTransition(
position: _authenticationController.titleSlideAnimation,
child: FadeTransition(
opacity: _authenticationController.titleAnimation,
child: Center(
child: BarberTitle(),
),
),
),
SlideTransition(
position: _authenticationController.imageSlideAnimation,
child: FadeTransition(
opacity: _authenticationController.imageAnimation,
child: Image.asset(
"assets/images/hairstyle.png",
height: SizeConfig.heightMultiplier * 30,
),
),
),
SlideTransition(
position: _authenticationController.descriptionSlideAnimation,
child: FadeTransition(
opacity: _authenticationController.descriptionAnimation,
child: OptimizedText(
_strings.findBarberDescription,
customColor: _colors.lightTxtColor,
maxLine: 2,
),
),
),
Column(
children: [
SlideTransition(
position:
_authenticationController.registerBtnSlideAnimation,
child: FadeTransition(
opacity: _authenticationController.registerBtnAnimation,
child: GlobalButton(
child: OptimizedText(
_strings.registerTitle,
fontWeight: FontWeight.bold,
),
color: _colors.pastelCyan,
onPressed: () {
showBottomSheet(
AuthBottomSheet(isRegister: true), context);
},
radius: _dimens.defaultRadius,
height: _dimens.defaultButtonHeight,
width: SizeConfig.widthMultiplier * 70,
),
),
),
const SizedBox(
height: 10,
),
SlideTransition(
position:
_authenticationController.loginBtnSlideAnimation,
child: FadeTransition(
opacity: _authenticationController.loginBtnAnimation,
child: GlobalButton(
child: OptimizedText(
_strings.loginTitle,
customColor: _colors.lightTxtColor,
fontWeight: FontWeight.bold,
),
color: _colors.pastelCyan,
elevation: 0,
onPressed: () {
showBottomSheet(
AuthBottomSheet(isRegister: false), context);
},
borderedButton: true,
borderColor: _colors.lightTxtColor,
radius: _dimens.defaultRadius,
height: _dimens.defaultButtonHeight,
width: SizeConfig.widthMultiplier * 70,
),
),
),
],
),
SlideTransition(
position: _authenticationController.termsSlideAnimation,
child: FadeTransition(
opacity: _authenticationController.termsAnimation,
child: TermsConditionsSection(),
),
),
],
),
),
),
),
);
}
}
| 0 |
mirrored_repositories/barber-booking/lib/app/modules/authentication | mirrored_repositories/barber-booking/lib/app/modules/authentication/local_widget/auth_bottom_sheet.dart | import 'package:barber_booking/app/core/utils/size_config_helper.dart';
import 'package:barber_booking/app/core/values/colors.dart';
import 'package:barber_booking/app/core/values/strings.dart';
import 'package:barber_booking/app/data/enums/text_color_option.dart';
import 'package:barber_booking/app/data/enums/text_size_option.dart';
import 'package:barber_booking/app/global_widgets/bottom_sheet_line.dart';
import 'package:barber_booking/app/global_widgets/global_button.dart';
import 'package:barber_booking/app/global_widgets/global_form_field.dart';
import 'package:barber_booking/app/global_widgets/global_indicator.dart';
import 'package:barber_booking/app/global_widgets/optimized_text.dart';
import 'package:barber_booking/app/modules/authentication/controller.dart';
import 'package:barber_booking/app/modules/authentication/local_widget/terms_conditions_section.dart';
import 'package:barber_booking/app/routes/routes.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:ionicons/ionicons.dart';
import '../../../core/values/dimes.dart';
import '../../../data/enums/pages_states/authentication_state.dart';
class AuthBottomSheet extends StatelessWidget {
final bool isRegister;
final Strings _strings = Get.find();
final AppColors _colors = Get.find();
final Dimens _dimens = Get.find();
final Routes _routes = Get.find();
final AuthenticationController _authenticationController = Get.find();
AuthBottomSheet({
Key? key,
required this.isRegister,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return SingleChildScrollView(
child: AnimatedPadding(
padding: MediaQuery.of(context).viewInsets,
duration: const Duration(milliseconds: 100),
child: Padding(
padding: EdgeInsets.all(_dimens.defaultPadding),
child: Stack(
children: [
Align(alignment: Alignment.topCenter, child: BottomSheetLine()),
Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(height: SizeConfig.heightMultiplier * 4),
OptimizedText(
isRegister
? _strings.registerDescription
: _strings.loginDescription,
customColor: _colors.lightTxtColor,
sizeOption: TextSizeOptions.bigBody,
maxLine: 2,
),
SizedBox(
height: SizeConfig.heightMultiplier * 4,
),
GlobalTextFormField(
controller: _authenticationController.emailController,
isEmailField: true,
label: _strings.emailHint,
),
SizedBox(
height: SizeConfig.heightMultiplier * 1,
),
GlobalTextFormField(
controller: _authenticationController.passwordController,
label: _strings.passwordHint,
isPasswordField: true,
),
SizedBox(
height: SizeConfig.heightMultiplier * 1,
),
GlobalButton(
child: Obx(
() => (_authenticationController.pageState.value ==
AuthenticationState.loginLoading ||
_authenticationController.pageState.value ==
AuthenticationState.registerLoading)
? GlobalIndicator(
color: _colors.darkTxtColor,
)
: OptimizedText(
isRegister
? _strings.registerTitle
: _strings.loginTitle,
fontWeight: FontWeight.bold,
),
),
color: _colors.pastelCyan,
onPressed: () {
if (isRegister) {
_authenticationController.register(
_authenticationController.emailController.text,
_authenticationController.passwordController.text);
} else {
_authenticationController.login(
_authenticationController.emailController.text,
_authenticationController.passwordController.text);
}
},
radius: _dimens.defaultRadius,
height: _dimens.defaultButtonHeight,
),
Wrap(
direction: Axis.vertical,
children: [
SizedBox(
height: SizeConfig.heightMultiplier * 1,
),
GlobalButton(
width: SizeConfig.widthMultiplier * 95,
child: Obx(() =>
(_authenticationController.pageState.value ==
AuthenticationState.socialLoading)
? const GlobalIndicator()
: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Ionicons.logo_google,
color: _colors.lightTxtColor,
),
SizedBox(
width: SizeConfig.widthMultiplier * 35,
child: OptimizedText(
(isRegister)
? _strings.googleSignupTitle
: _strings.googleSigninTitle,
fontWeight: FontWeight.bold,
colorOption: TextColorOptions.light,
maxLine: 2,
),
),
],
)),
color: _colors.lightTxtColor,
borderedButton: true,
elevation: 0,
onPressed: () {
_authenticationController.socialLogin();
},
radius: _dimens.defaultRadius,
height: _dimens.defaultButtonHeight,
),
],
),
SizedBox(
height: SizeConfig.heightMultiplier * 7,
),
TermsConditionsSection(),
],
),
],
),
),
),
);
}
}
| 0 |
mirrored_repositories/barber-booking/lib/app/modules/authentication | mirrored_repositories/barber-booking/lib/app/modules/authentication/local_widget/barber_title.dart | import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:ionicons/ionicons.dart';
import '../../../core/utils/size_config_helper.dart';
import '../../../core/values/colors.dart';
import '../../../core/values/strings.dart';
import '../../../data/enums/text_size_option.dart';
import '../../../global_widgets/optimized_text.dart';
class BarberTitle extends StatelessWidget {
BarberTitle({Key? key}) : super(key: key);
final AppColors _colors = Get.find();
final Strings _strings = Get.find();
@override
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Ionicons.cut, color: _colors.lightTxtColor),
SizedBox(
width: SizeConfig.widthMultiplier * 65,
child: OptimizedText(
_strings.barberBookingTitle,
customColor: _colors.lightTxtColor,
fontWeight: FontWeight.bold,
textAlign: TextAlign.center,
sizeOption: TextSizeOptions.title,
),
),
],
);
}
}
| 0 |
mirrored_repositories/barber-booking/lib/app/modules/authentication | mirrored_repositories/barber-booking/lib/app/modules/authentication/local_widget/terms_conditions_section.dart | import 'package:barber_booking/app/routes/routes.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../../core/values/colors.dart';
class TermsConditionsSection extends StatelessWidget {
TermsConditionsSection({Key? key}) : super(key: key);
final AppColors _colors = Get.find();
final Routes _routes = Get.find();
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 40),
child: GestureDetector(
onTap: () => Get.toNamed(_routes.termsConditionsRoute),
child: RichText(
textAlign: TextAlign.center,
text: TextSpan(
children: [
TextSpan(
text: "By signing up you accept the ",
style: TextStyle(
color: _colors.lightTxtColor, fontFamily: "bitter"),
),
TextSpan(
text: "Term of service",
style: TextStyle(
color: _colors.greenTxtColor,
fontFamily: "bitter",
fontWeight: FontWeight.bold,
),
),
TextSpan(
text: " and ",
style: TextStyle(
color: _colors.lightTxtColor, fontFamily: "bitter"),
),
TextSpan(
text: "Privacy policy",
style: TextStyle(
color: _colors.greenTxtColor,
fontFamily: "bitter",
fontWeight: FontWeight.bold,
),
),
],
),
),
),
);
}
}
| 0 |
mirrored_repositories/barber-booking/lib/app/modules/authentication | mirrored_repositories/barber-booking/lib/app/modules/authentication/local_widget/social_bottom_sheet.dart | import 'package:flutter/material.dart';
import '../../../global_widgets/bottom_sheet_line.dart';
class SocialBottomSheets extends StatelessWidget {
const SocialBottomSheets({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Column(
children: [
BottomSheetLine(),
],
);
}
}
| 0 |
mirrored_repositories/barber-booking/lib/app/modules | mirrored_repositories/barber-booking/lib/app/modules/add_story/controller.dart | import 'package:barber_booking/app/data/services/camera_service.dart';
import 'package:camera/camera.dart';
import 'package:get/get.dart';
class AddStoryController extends GetxController {
late CameraController cameraController;
RxBool cameraInitialized = false.obs;
@override
void onInit() {
initializeCamera();
super.onInit();
}
@override
void onClose() {
cameraController.dispose();
super.onClose();
}
initializeCamera() async {
try {
cameraInitialized(false);
cameraController = CameraController(
CustomCameraService.cameras[0], ResolutionPreset.max);
await cameraController.initialize();
cameraInitialized(true);
} catch (e, s) {
cameraInitialized(false);
print(e);
print(s);
}
}
}
| 0 |
mirrored_repositories/barber-booking/lib/app/modules | mirrored_repositories/barber-booking/lib/app/modules/add_story/page.dart | import 'package:barber_booking/app/core/values/strings.dart';
import 'package:barber_booking/app/modules/add_story/controller.dart';
import 'package:camera/camera.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../core/values/colors.dart';
import '../../core/values/dimes.dart';
class AddStory extends StatelessWidget {
AddStory({Key? key}) : super(key: key);
final AppColors _colors = Get.find();
final Strings _strings = Get.find();
final Dimens _dimens = Get.find();
final AddStoryController _addStoryController = Get.find();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(_strings.addStoryAppBarTitle),
),
body: Obx(
() {
final scale = 1 /
(_addStoryController.cameraController.value.aspectRatio *
MediaQuery.of(context).size.aspectRatio);
return !_addStoryController.cameraInitialized.value
? Center(child: CircularProgressIndicator())
: Transform.scale(
scale: scale,
child: CameraPreview(_addStoryController.cameraController),
);
},
),
);
}
}
| 0 |
mirrored_repositories/barber-booking/lib/app/modules | mirrored_repositories/barber-booking/lib/app/modules/barber_profile/controller.dart | import 'package:flutter/material.dart';
import 'package:get/get.dart';
class BarberProfileController extends GetxController
with GetTickerProviderStateMixin {
late AnimationController animationController;
late Animation<double> fadeLikeButtonAnimation;
late Animation<Offset> slideLikeButtonAnimation;
late Animation<double> fadeDescriptionAnimation;
late Animation<Offset> slideDescriptionAnimation;
late Animation<double> fadeBookButtonAnimation;
late Animation<Offset> slideBookButtonAnimation;
@override
void onInit() {
const duration = Duration(milliseconds: 600);
const beginOffset = Offset(0, .6);
animationController = AnimationController(vsync: this, duration: duration)
..forward();
slideLikeButtonAnimation =
Tween<Offset>(begin: beginOffset, end: Offset.zero).animate(
CurvedAnimation(
parent: animationController,
curve: const Interval(.13, 1, curve: Curves.ease),
),
);
fadeLikeButtonAnimation = Tween<double>(begin: 0, end: 1).animate(
CurvedAnimation(
parent: animationController,
curve: const Interval(.13, 1, curve: Curves.ease),
),
);
slideDescriptionAnimation =
Tween<Offset>(begin: beginOffset, end: Offset.zero).animate(
CurvedAnimation(
parent: animationController,
curve: const Interval(.46, 1, curve: Curves.ease),
),
);
fadeDescriptionAnimation = Tween<double>(begin: 0, end: 1).animate(
CurvedAnimation(
parent: animationController,
curve: const Interval(.46, 1, curve: Curves.ease),
),
);
slideBookButtonAnimation =
Tween<Offset>(begin: beginOffset, end: Offset.zero).animate(
CurvedAnimation(
parent: animationController,
curve: const Interval(.59, 1, curve: Curves.ease),
),
);
fadeBookButtonAnimation = Tween<double>(begin: 0, end: 1).animate(
CurvedAnimation(
parent: animationController,
curve: const Interval(.59, 1, curve: Curves.ease),
),
);
super.onInit();
}
@override
void onClose() {
animationController.dispose();
super.onClose();
}
}
| 0 |
mirrored_repositories/barber-booking/lib/app/modules | mirrored_repositories/barber-booking/lib/app/modules/barber_profile/page.dart | import 'package:barber_booking/app/core/utils/size_config_helper.dart';
import 'package:barber_booking/app/core/values/dimes.dart';
import 'package:barber_booking/app/data/model/barber/barber.dart';
import 'package:extended_image/extended_image.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../core/values/colors.dart';
import '../../core/values/strings.dart';
import '../../routes/routes.dart';
import 'controller.dart';
import 'local_widget/barber_description.dart';
class BarberProfile extends StatelessWidget {
BarberProfile({Key? key, required this.barber}) : super(key: key);
final BarberModel barber;
final AppColors _colors = Get.find();
final Strings _strings = Get.find();
final Routes _routes = Get.find();
final Dimens _dimens = Get.find();
final BarberProfileController _profileController = Get.find();
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
children: [
CustomScrollView(
slivers: [
SliverAppBar(
expandedHeight: 250.0,
pinned: true,
floating: true,
backgroundColor: _colors.frostedBlack,
flexibleSpace: FlexibleSpaceBar(
centerTitle: true,
title: Text(
barber.name,
style: TextStyle(color: _colors.lightTxtColor),
),
background: Stack(
children: [
ExtendedImage.network(
barber.image,
width: SizeConfig.widthMultiplier * 100,
fit: BoxFit.cover,
),
Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Colors.transparent,
_colors.frostedBlack,
],
),
),
),
],
),
),
),
SliverList(
delegate: SliverChildListDelegate([
BarberDescriptionWidget(barber: barber),
]),
),
],
),
],
),
);
}
}
| 0 |
mirrored_repositories/barber-booking/lib/app/modules/barber_profile | mirrored_repositories/barber-booking/lib/app/modules/barber_profile/local_widget/barber_description.dart | import 'package:barber_booking/app/data/model/barber/barber.dart';
import 'package:barber_booking/app/exports.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:ionicons/ionicons.dart';
import '../../../core/utils/size_config_helper.dart';
import '../../../data/enums/text_color_option.dart';
import '../../../data/enums/text_size_option.dart';
import '../../../global_widgets/optimized_text.dart';
import '../controller.dart';
class BarberDescriptionWidget extends StatelessWidget {
BarberDescriptionWidget({Key? key, required this.barber}) : super(key: key);
final BarberModel barber;
final AppColors _colors = Get.find();
final Strings _strings = Get.find();
final Routes _routes = Get.find();
final Dimens _dimens = Get.find();
final BarberProfileController _profileController = Get.find();
@override
Widget build(BuildContext context) {
return Padding(
padding: EdgeInsets.all(_dimens.defaultPadding * 3),
child: Column(
children: [
SlideTransition(
position: _profileController.slideLikeButtonAnimation,
child: FadeTransition(
opacity: _profileController.fadeLikeButtonAnimation,
child: OptimizedText(
barber.location,
colorOption: TextColorOptions.light,
textAlign: TextAlign.start,
sizeOption: TextSizeOptions.button,
maxLine: 2,
),
),
),
SizedBox(height: SizeConfig.heightMultiplier * 2),
SlideTransition(
position: _profileController.slideDescriptionAnimation,
child: FadeTransition(
opacity: _profileController.fadeDescriptionAnimation,
child: OptimizedText(
barber.description,
colorOption: TextColorOptions.light,
maxLine: 100,
textAlign: TextAlign.justify,
),
),
),
SizedBox(
height: SizeConfig.heightMultiplier * 8,
),
],
),
);
}
likeButton() => Container(
decoration: BoxDecoration(
color: _colors.pastelCyan,
shape: BoxShape.circle,
),
child: Padding(
padding: EdgeInsets.all(_dimens.defaultPadding * 2),
child: Icon(
Ionicons.heart,
color: _colors.frostedBlack,
),
),
);
}
| 0 |
mirrored_repositories/barber-booking/lib/app/data/model | mirrored_repositories/barber-booking/lib/app/data/model/appointments/appointments_item_data.dart | import 'package:barber_booking/app/data/model/appointments/appointments.dart';
class AppointmentsItemModel {
final AppointmentsModel item;
final bool isUpper;
AppointmentsItemModel({required this.item, required this.isUpper});
}
| 0 |
mirrored_repositories/barber-booking/lib/app/data/model | mirrored_repositories/barber-booking/lib/app/data/model/appointments/appointments.dart | import 'package:barber_booking/app/data/model/barber_shop/barber_shop.dart';
class AppointmentsModel {
final BarberShopModel barberShopModel;
final String appointmentTime;
final String id;
AppointmentsModel({
required this.barberShopModel,
required this.appointmentTime,
required this.id,
});
factory AppointmentsModel.fromJson(doc) => AppointmentsModel(
barberShopModel: BarberShopModel.fromJson(doc["barberShop"]),
appointmentTime: doc["appointmentTime"],
id: doc["id"],
);
}
| 0 |
mirrored_repositories/barber-booking/lib/app/data/model | mirrored_repositories/barber-booking/lib/app/data/model/post/post.dart | import 'package:barber_booking/app/data/model/barber/barber.dart';
class PostModel {
final String title;
final String description;
final String image;
final String releaseTime;
final String timeToRead;
final BarberModel barber;
PostModel({
required this.title,
required this.description,
required this.image,
required this.releaseTime,
required this.timeToRead,
required this.barber,
});
factory PostModel.fromJson({required doc, required barberData}) => PostModel(
title: doc["title"],
description: doc["description"],
image: doc["image"],
releaseTime: doc["releaseTime"],
timeToRead: doc["timeToRead"],
barber: BarberModel.fromJson(barberData),
);
}
| 0 |
mirrored_repositories/barber-booking/lib/app/data/model | mirrored_repositories/barber-booking/lib/app/data/model/barber_shop/barber_shop.dart | class BarberShopModel {
final String id;
final String title;
final String subTitle;
final List<String> tags;
final String description;
final double lat, long;
final String imageUrl;
final String startWorkTime, endWorkTime;
BarberShopModel({
required this.id,
required this.title,
required this.subTitle,
required this.tags,
required this.description,
required this.lat,
required this.long,
required this.imageUrl,
required this.startWorkTime,
required this.endWorkTime,
});
factory BarberShopModel.fromJson(doc) => BarberShopModel(
id: doc["id"],
title: doc["title"],
subTitle: doc["subTitle"],
tags: converTagsToStringList(doc["tags"]),
description: doc["description"],
lat: double.parse(doc["lat"]),
long: double.parse(doc["long"]),
imageUrl: doc["image"],
startWorkTime: doc["startWorkTime"],
endWorkTime: doc["endWorkTime"],
);
static converTagsToStringList(List<dynamic> list) {
List<String> stringList = [];
for (var element in list) {
stringList.add(element.toString());
}
return stringList;
}
}
| 0 |
mirrored_repositories/barber-booking/lib/app/data/model | mirrored_repositories/barber-booking/lib/app/data/model/user/user_extra_info.dart | class UserExtraInfo {
final int? gender;
final int? age;
UserExtraInfo({this.gender, this.age});
factory UserExtraInfo.fromJson(doc) =>
UserExtraInfo(age: doc["age"], gender: doc["gender"]);
}
| 0 |
mirrored_repositories/barber-booking/lib/app/data/model | mirrored_repositories/barber-booking/lib/app/data/model/barber/barber.dart | class BarberModel {
final String name;
final String location;
final String description;
final String image;
BarberModel({
required this.name,
required this.image,
required this.location,
required this.description,
});
factory BarberModel.fromJson(doc) => BarberModel(
image: doc["image"],
name: doc["name"],
location: doc["location"],
description: doc["description"],
);
}
| 0 |
mirrored_repositories/barber-booking/lib/app/data/model | mirrored_repositories/barber-booking/lib/app/data/model/story/story.dart | class StoryModel {
final String thumbnail;
final String image;
final String id;
final List<String> comments;
final List<String> likes;
final List<String> seens;
StoryModel({
required this.thumbnail,
required this.image,
required this.id,
required this.comments,
required this.likes,
required this.seens,
});
factory StoryModel.fromJson(doc) => StoryModel(
thumbnail: doc["thumbnail"],
image: doc["image"],
id: doc["id"],
comments: converDynamicListToStringList(doc["comments"]),
likes: converDynamicListToStringList(doc["likes"]),
seens: converDynamicListToStringList(doc["seens"]),
);
static converDynamicListToStringList(List<dynamic> list) {
List<String> stringList = [];
for (var element in list) {
stringList.add(element.toString());
}
return stringList;
}
}
| 0 |
mirrored_repositories/barber-booking/lib/app/data | mirrored_repositories/barber-booking/lib/app/data/enums/text_size_option.dart | enum TextSizeOptions {
button,
title,
caption,
underline,
body,
bigBody,
small,
}
| 0 |
mirrored_repositories/barber-booking/lib/app/data | mirrored_repositories/barber-booking/lib/app/data/enums/text_color_option.dart | enum TextColorOptions {
dark,
light,
hint,
}
| 0 |
mirrored_repositories/barber-booking/lib/app/data/enums | mirrored_repositories/barber-booking/lib/app/data/enums/pages_states/news_state.dart | enum NewsState {
init,
loadingStories,
getStoriesSuccess,
getStoriesFailed,
loadingBarberShops,
getBarberShopsSuccess,
getBarberShopsFailed,
getPostsLoading,
getPostsSuccess,
getPostsFailed,
}
| 0 |
mirrored_repositories/barber-booking/lib/app/data/enums | mirrored_repositories/barber-booking/lib/app/data/enums/pages_states/authentication_state.dart | enum AuthenticationState {
initial,
loginLoading,
loginError,
registerLoading,
registerError,
registerSuccessful,
socialLoading,
socialError,
authenticated,
unaAuthenticated,
}
| 0 |
mirrored_repositories/barber-booking/lib/app/data/enums | mirrored_repositories/barber-booking/lib/app/data/enums/pages_states/home_state.dart | enum HomeState {
initial,
userVerified,
userNotVerified,
}
| 0 |
mirrored_repositories/barber-booking/lib/app/data/enums | mirrored_repositories/barber-booking/lib/app/data/enums/pages_states/app_state.dart | enum AppState {
initial,
authenticated,
unaAuthenticated,
}
| 0 |
mirrored_repositories/barber-booking/lib/app/data/enums | mirrored_repositories/barber-booking/lib/app/data/enums/pages_states/appointments_state.dart | enum AppointmentsState {
init,
loading,
success,
failed,
}
| 0 |
mirrored_repositories/barber-booking/lib/app/data/enums | mirrored_repositories/barber-booking/lib/app/data/enums/pages_states/profile_state.dart | enum ProfileState {
init,
loadingToGetData,
dataFetchedSuccess,
dataFetchedFailed,
loadingToSubmitData,
submitDataSuccess,
submitDataFailed,
}
| 0 |
mirrored_repositories/barber-booking/lib/app/data/enums | mirrored_repositories/barber-booking/lib/app/data/enums/pages_states/splash_state.dart | enum SplashState {
initial,
loading,
success,
failed,
}
| 0 |
mirrored_repositories/barber-booking/lib/app/data/enums | mirrored_repositories/barber-booking/lib/app/data/enums/pages_states/nearest_barber_state.dart | enum NearestBarberState {
init,
barberShopsLoadedSuccess,
barberShopsLoading,
barberShopsLoadingFailed,
}
| 0 |
mirrored_repositories/barber-booking/lib/app/data | mirrored_repositories/barber-booking/lib/app/data/services/camera_service.dart | import 'package:camera/camera.dart';
class CustomCameraService {
static List<CameraDescription> cameras = [];
static initializeCamera() async {
cameras = await availableCameras();
}
}
| 0 |
mirrored_repositories/barber-booking/lib/app/data | mirrored_repositories/barber-booking/lib/app/data/services/location_service.dart | import 'dart:async';
import 'package:geolocator/geolocator.dart';
import 'package:get/get.dart';
late Position userPosition;
class CustomLocationService extends GetxController {
late StreamSubscription<Position> positionStream;
@override
void onInit() {
init();
super.onInit();
}
init() async {
userPosition = await determinePosition();
const LocationSettings locationSettings = LocationSettings(
accuracy: LocationAccuracy.high,
distanceFilter: 100,
);
positionStream =
Geolocator.getPositionStream(locationSettings: locationSettings)
.listen((Position? position) {
if (position != null) {
userPosition = position;
}
});
}
static Future<Position> determinePosition() async {
bool serviceEnabled;
LocationPermission permission;
serviceEnabled = await Geolocator.isLocationServiceEnabled();
if (!serviceEnabled) {
return Future.error('Location services are disabled.');
}
permission = await Geolocator.checkPermission();
if (permission == LocationPermission.denied) {
permission = await Geolocator.requestPermission();
if (permission == LocationPermission.denied) {
return Future.error('Location permissions are denied');
}
}
if (permission == LocationPermission.deniedForever) {
return Future.error(
'Location permissions are permanently denied, we cannot request permissions.');
}
return await Geolocator.getCurrentPosition();
}
}
| 0 |
mirrored_repositories/barber-booking/lib/app/data | mirrored_repositories/barber-booking/lib/app/data/services/firebase_service.dart | import 'dart:async';
import 'dart:io';
import 'package:barber_booking/app/data/model/appointments/appointments.dart';
import 'package:barber_booking/app/data/model/barber/barber.dart';
import 'package:barber_booking/app/data/model/barber_shop/barber_shop.dart';
import 'package:barber_booking/app/data/model/post/post.dart';
import 'package:barber_booking/app/data/model/story/story.dart';
import 'package:barber_booking/app/data/model/user/user_extra_info.dart';
import 'package:barber_booking/app/global_widgets/global_snackbar.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:get/get.dart';
import 'package:google_sign_in/google_sign_in.dart';
class FirebaseService {
final FirebaseAuth _auth = Get.find();
final FirebaseFirestore _firestore = Get.find();
// errors strings
String weakPwdError = 'The password provided is too weak.';
String emailUseError = 'The account already exists for that email.';
String internetConnectionError = 'Please check your internet connection';
String unknownError = "Operation failed. Please try again.";
String userNotFoundError = 'No user found for that email.';
String wrongPwdError = 'Wrong password provided for that user.';
String userNotExistError = "No user found with this email.";
firebaseErrorHandler(e, s) {
print(e);
print(s);
if (e is FirebaseAuthException) {
switch (e.code) {
case "ERROR_EMAIL_ALREADY_IN_USE":
case "account-exists-with-different-credential":
case "email-already-in-use":
throw emailUseError;
case "ERROR_WRONG_PASSWORD":
case "wrong-password":
throw wrongPwdError;
case "ERROR_USER_NOT_FOUND":
case "user-not-found":
throw userNotExistError;
case "ERROR_USER_DISABLED":
case "user-disabled":
throw "User disabled.";
case "ERROR_TOO_MANY_REQUESTS":
case "operation-not-allowed":
throw "Too many requests to log into this account.";
case "ERROR_OPERATION_NOT_ALLOWED":
throw "Server error, please try again later.";
case "ERROR_INVALID_EMAIL":
case "invalid-email":
throw "Email address is invalid.";
default:
throw unknownError;
}
} else if (e is SocketException) {
throw internetConnectionError;
} else {
throw e.toString();
}
}
Future submitNewBooking(String barberShopId) async {
try {
User? user = _auth.currentUser;
if (user == null) throw "User not exist";
DocumentReference barber =
_firestore.collection("barbershops").doc(barberShopId);
String docId = DateTime.now().toIso8601String();
_firestore
.collection("users")
.doc(user.uid)
.collection("appointments")
.doc(docId)
.set({
"barberShop": barber,
"appointmentTime": "${DateTime.now().hour}:${DateTime.now().minute}",
"id": docId,
}).then((value) {
print("appointment created");
}).catchError((e) {
throw e;
});
} catch (e, s) {
firebaseErrorHandler(e, s);
}
}
Future cancelBooking(String appointmentId) async {
try {
User? user = _auth.currentUser;
if (user == null) throw "User not exist";
_firestore
.collection("users")
.doc(user.uid)
.collection("appointments")
.doc(appointmentId)
.delete()
.then((value) {
print("appointment canceled");
}).catchError((e) {
throw e;
});
} catch (e, s) {
firebaseErrorHandler(e, s);
}
}
Future<DocumentSnapshot?> getSnapShotFromReference(
DocumentReference reference) async {
try {
return await reference.get();
} catch (e, s) {
firebaseErrorHandler(e, s);
return null;
}
}
Future<List<AppointmentsModel>> getAppointments() async {
List<AppointmentsModel> appointmentsList = [];
List<Map> rawData = [];
List<Future> rawFutures = [];
List completedFutures = [];
try {
User? user = _auth.currentUser;
if (user == null) throw "User not exist";
QuerySnapshot appointments = await _firestore
.collection("users")
.doc(user.uid)
.collection("appointments")
.get();
// add all futures to a raw list
for (var element in appointments.docs) {
Map data = element.data() as Map;
rawFutures.add(getSnapShotFromReference(data["barberShop"]));
}
// get list of completed futures
completedFutures.addAll(await Future.wait(rawFutures));
for (var i = 0; i < appointments.docs.length; i++) {
Map data = appointments.docs[i].data() as Map;
rawData.add({
"appointmentTime": data["appointmentTime"],
"barberShop": completedFutures[i],
"id": data["id"]
});
}
for (var element in rawData) {
appointmentsList.add(AppointmentsModel.fromJson(element));
}
} catch (e, s) {
firebaseErrorHandler(e, s);
}
return appointmentsList;
}
Future<StoryModel?> getSpeceficData(String storyId) async {
try {
DocumentSnapshot story =
await _firestore.collection("story").doc(storyId).get();
return StoryModel.fromJson(story);
} catch (e, s) {
firebaseErrorHandler(e, s);
}
return null;
}
Future<bool?> checkBarberShopLikeStatus(String id) async {
try {
User? user = _auth.currentUser;
if (user == null) throw "User not exist";
DocumentSnapshot doc =
await _firestore.collection("users").doc(user.uid).get();
List favBarberShops = doc["favouriteBarberShops"];
return (favBarberShops.contains(id)) ? true : false;
} catch (e, s) {
firebaseErrorHandler(e, s);
return null;
}
}
Future<void> likeBarberShop(String id) async {
try {
User? user = _auth.currentUser;
if (user == null) throw "User not exist";
bool? isExist = await checkBarberShopLikeStatus(id);
if (isExist == null) throw unknownError;
if (isExist) {
await _firestore.collection("users").doc(user.uid).update({
'favouriteBarberShops': FieldValue.arrayRemove([id]),
});
} else {
await _firestore.collection("users").doc(user.uid).update({
'favouriteBarberShops': FieldValue.arrayUnion([id]),
});
}
} catch (e, s) {
firebaseErrorHandler(e, s);
}
}
Future<bool> seenStory(String storyId) async {
try {
User? user = _auth.currentUser;
if (user == null) {
throw "Please first login";
} else {
return _firestore.collection("story").doc(storyId).update({
"seens": FieldValue.arrayUnion([user.uid])
}).then((value) => true);
}
} catch (e, s) {
firebaseErrorHandler(e, s);
return false;
}
}
Future likeStory(String storyId) async {
try {
User? user = _auth.currentUser;
if (user == null) {
throw "Please first login";
} else {
DocumentSnapshot storyData =
await _firestore.collection("story").doc(storyId).get();
List likes = storyData["likes"];
if (likes.contains(user.uid)) {
await _firestore.collection("story").doc(storyId).update({
"likes": FieldValue.arrayRemove([user.uid])
}).then((value) => true);
} else {
await _firestore.collection("story").doc(storyId).update({
"likes": FieldValue.arrayUnion([user.uid])
}).then((value) => true);
}
}
} catch (e, s) {
firebaseErrorHandler(e, s);
return false;
}
}
Future commentOnStory(String storyId, String comment) async {
try {
User? user = _auth.currentUser;
if (user == null) {
throw "Please first login";
} else {
return _firestore.collection("story").doc(storyId).update({
"comments": FieldValue.arrayUnion(["${user.uid}/$comment"])
}).then((value) => true);
}
} catch (e, s) {
firebaseErrorHandler(e, s);
return false;
}
}
Future<List<StoryModel>> getAllStories() async {
List<StoryModel> list = [];
try {
QuerySnapshot docs = await _firestore.collection("story").get();
for (var element in docs.docs) {
list.add(StoryModel.fromJson(element));
}
} catch (e, s) {
firebaseErrorHandler(e, s);
}
return list;
}
Future<List<PostModel>> getAllPosts() async {
List<PostModel> list = [];
List<Future> rawFutures = [];
List completedFutures = [];
try {
QuerySnapshot posts = await _firestore.collection('posts').get();
// add refrence to raw list
for (var element in posts.docs) {
Map data = element.data() as Map;
rawFutures.add(getSnapShotFromReference(data["barber"]));
}
completedFutures.addAll(await Future.wait(rawFutures));
for (var i = 0; i < posts.docs.length; i++) {
list.add(
PostModel.fromJson(
doc: posts.docs[i],
barberData: completedFutures[i],
),
);
}
} catch (e, s) {
firebaseErrorHandler(e, s);
}
return list;
}
Future<BarberModel?> getSpeceficProfile(String docId) async {
try {
DocumentSnapshot document =
await _firestore.collection("barber").doc(docId).get();
if (!document.exists) {
throw "This profile not existed";
}
return BarberModel.fromJson(document);
} catch (e, s) {
firebaseErrorHandler(e, s);
return null;
}
}
Future<List<BarberShopModel>> getAllBarberShops() async {
List<BarberShopModel> barbersList = [];
try {
QuerySnapshot barberShops =
await _firestore.collection("barbershops").get();
for (var element in barberShops.docs) {
barbersList.add(BarberShopModel.fromJson(element.data()));
}
} catch (e, s) {
firebaseErrorHandler(e, s);
}
return barbersList;
}
Future signInWithGoogle() async {
try {
final GoogleSignInAccount? googleUser = await GoogleSignIn().signIn();
final GoogleSignInAuthentication? googleAuth =
await googleUser?.authentication;
final credential = GoogleAuthProvider.credential(
accessToken: googleAuth?.accessToken,
idToken: googleAuth?.idToken,
);
return await _auth.signInWithCredential(credential);
} on SocketException {
throw internetConnectionError;
} catch (e, s) {
firebaseErrorHandler(e, s);
}
}
Future registerUser({required email, required password}) async {
try {
UserCredential userCredential = await FirebaseAuth.instance
.createUserWithEmailAndPassword(email: email, password: password);
return userCredential;
} on SocketException {
throw internetConnectionError;
} catch (e, s) {
firebaseErrorHandler(e, s);
}
}
Future loginUser({required email, required password}) async {
try {
UserCredential userCredential = await FirebaseAuth.instance
.signInWithEmailAndPassword(email: email, password: password);
return userCredential;
} on SocketException {
throw internetConnectionError;
} catch (e, s) {
firebaseErrorHandler(e, s);
}
}
User? getUser() {
try {
User? user = _auth.currentUser;
if (user != null) {
return user;
} else {
return null;
}
} catch (e, s) {
firebaseErrorHandler(e, s);
}
return null;
}
Future<UserExtraInfo?> getUserExtraInfo() async {
try {
DocumentSnapshot userDoc =
await _firestore.collection("users").doc(getUser()?.uid).get();
UserExtraInfo userExtraInfo = UserExtraInfo.fromJson(userDoc.data());
return userExtraInfo;
} catch (e, s) {
firebaseErrorHandler(e, s);
}
return null;
}
Future<bool> updateUserBaseInfo(
{String? email, String? name, String? photo}) async {
try {
User? user = _auth.currentUser;
if (user != null) {
if (email != null) user.updateEmail(email);
if (name != null) user.updateDisplayName(name);
if (photo != null) user.updatePhotoURL(photo);
}
return true;
} catch (e, s) {
firebaseErrorHandler(e, s);
return false;
}
}
Future<bool> updateUserExtraInfo({int? gender, int? age}) async {
try {
User? user = _auth.currentUser;
if (user != null) {
String uid = user.uid;
if (gender != null) {
await _firestore
.collection("users")
.doc(uid)
.update({"gender": gender});
}
if (age != null) {
await _firestore.collection("users").doc(uid).update({"age": age});
}
} else {
throw "User not active please logout and login again";
}
return true;
} catch (e, s) {
firebaseErrorHandler(e, s);
return false;
}
}
Future createExtraInfoDocumetnation() async {
try {
User? user = _auth.currentUser;
if (user != null) {
DocumentSnapshot doc =
await _firestore.collection("users").doc(user.uid).get();
if (!doc.exists) {
await _firestore
.collection("users")
.doc(user.uid)
.set({"gender": 3, "age": 0});
}
} else {
throw "User not exist";
}
} catch (e, s) {
firebaseErrorHandler(e, s);
return false;
}
}
Future checkUserState() async {
try {
User? user = FirebaseAuth.instance.currentUser;
if (user != null) {
return true;
} else {
return false;
}
} catch (e, s) {
firebaseErrorHandler(e, s);
}
}
Future checkUserVerificationState() async {
try {
User? user = FirebaseAuth.instance.currentUser;
if (user != null) {
if (user.emailVerified) {
return true;
} else {
return false;
}
} else {
throw userNotExistError;
}
} catch (e, s) {
firebaseErrorHandler(e, s);
}
}
Future sendVerificationEmail() async {
try {
User? user = FirebaseAuth.instance.currentUser;
if (user != null) {
await user.sendEmailVerification();
} else {
throw userNotExistError;
}
} catch (e, s) {
firebaseErrorHandler(e, s);
}
}
Future logout() async {
try {
await FirebaseAuth.instance.signOut();
} catch (e) {}
}
}
| 0 |
mirrored_repositories/barber-booking/lib/app/core | mirrored_repositories/barber-booking/lib/app/core/values/secret.dart | var mapBoxUrl =
"https://api.mapbox.com/styles/v1/mapbox/streets-v11/tiles/{z}/{x}/{y}?access_token=pk.eyJ1IjoibWFobW91ZC1lc2xhbWkiLCJhIjoiY2wwazJhb3g5MGljNzNwa2NqcTB2cDdtbiJ9.mMwvYfEnD_YY44C4njkRzw";
var darkMapUrl =
"https://api.mapbox.com/styles/v1/mahmoud-eslami/cl0k2k3hc001e15qs1qzzmdsn/tiles/256/{z}/{x}/{y}@2x?access_token=pk.eyJ1IjoibWFobW91ZC1lc2xhbWkiLCJhIjoiY2wwazJhb3g5MGljNzNwa2NqcTB2cDdtbiJ9.mMwvYfEnD_YY44C4njkRzw";
| 0 |
mirrored_repositories/barber-booking/lib/app/core | mirrored_repositories/barber-booking/lib/app/core/values/dimes.dart | class Dimens {
double defaultRadius = 50.0;
double defaultPadding = 8.0;
double defaultMargin = 10.0;
double defaultButtonHeight = 60.0;
double defaultIconSize = 25;
double storyItemBorderSize = 3.0;
double storyLineHeight = 100.0;
double storyItemHeight = 80.0;
}
| 0 |
mirrored_repositories/barber-booking/lib/app/core | mirrored_repositories/barber-booking/lib/app/core/values/colors.dart | import 'package:flutter/material.dart';
class AppColors {
// main colors
Color pastelCyan = const Color(0xff13DAE9);
Color frostedBlack = const Color(0xff10171D);
Color hintTextColor = const Color(0xffffffff);
Color lightTxtColor = const Color(0xffffffff);
Color darkTxtColor = const Color(0xff10171D);
Color greenTxtColor = const Color(0xff13DAE9);
Color lightBorder = Colors.white24;
Color coloredBorder = const Color(0xff13DAE9);
Color starColor = Colors.amber;
Color barberShopsLocationColors = Colors.amber;
Color barberOpen = const Color(0xff13DAE9);
Color barberClose = const Color(0xffFF0000);
Color likedHearth = const Color(0xffFF0000);
Color enableBorderFormFieldColor = const Color(0xffffffff);
Color focusBorderFormFieldColor = const Color(0xff13DAE9);
Color errorBorderFormFieldColor = const Color(0xffFF0000);
}
| 0 |
mirrored_repositories/barber-booking/lib/app/core | mirrored_repositories/barber-booking/lib/app/core/values/strings.dart | class Strings {
// hero tags
String profileImageTag = "profile_image";
String storyTag = "story_image";
// app strings
String title = "Barber Booking";
String startDescription =
"Find the perfect Barberman at your door step\n and nearest Barbershop";
String startButton = "Get Started";
String barberBookingTitle = "Barber Booking";
String findBarberDescription = "Let's find Best and Nearest \nbarber Shop";
String registerTitle = "Sign up";
String loginTitle = "Sign in";
String googleSigninTitle = "Google sign in";
String googleSignupTitle = "Google sign up";
String termsAndConditionsTitle = "Terms and Conditions";
String profileTitle = "Personal Data";
String profileSubmitBtn = "Submit";
String nameHint = "Your name";
String emailHint = "Email";
String ageHint = "Age";
String passwordHint = "Password";
String birthHint = "Date of birth";
String newsPageTitle = "News";
String barberShopNewsTitle = "Barber Shops news";
String trendingBarberTitle = "Trending Barber Shops";
String addStoryAppBarTitle = "Add Story";
String noticeTitle = "Notice!";
String loginDescription = "Enter your email and password";
String registerDescription = "Enter your email and set a password";
String errorWidgetTitle = "Uh... Error !";
String errorWidgetDescription = "Something went wrong, please try again.";
String errorWidgetButtonTitle = "try again";
String appointmentsTitle = "Appointments";
String noAppointmentTitle = "There is no appointment right now";
String bookedSuccessTitle = "Booked successful";
String bookingCanceledTitle = "Booking canceled";
String successEmoji = "✅";
String cancelEmoji = "🚫";
String verificationEmailSentTitle = "Verification email sent successful";
String verificationEmailAlarmTitle =
"Verification email sent please verify your email and then sign in to your account.";
// lorem
String lorem =
"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.";
// term and conditions
String termAndConditions = '''Terms and Conditions
Welcome to Website Name!
These terms and conditions outline the rules and regulations for the use of Company Name's Website, located at Website.com.
By accessing this website we assume you accept these terms and conditions. Do not continue to use Website Name if you do not agree to take all of the terms and conditions stated on this page.
The following terminology applies to these Terms and Conditions, Privacy Statement and Disclaimer Notice and all Agreements: “Client”, “You” and “Your” refers to you, the person log on this website and compliant to the Company's terms and conditions. “The Company”, “Ourselves”, “We”, “Our” and “Us”, refers to our Company. “Party”, “Parties”, or “Us”, refers to both the Client and ourselves. All terms refer to the offer, acceptance and consideration of payment necessary to undertake the process of our assistance to the Client in the most appropriate manner for the express purpose of meeting the Client's needs in respect of provision of the Company's stated services, in accordance with and subject to, prevailing law of Netherlands. Any use of the above terminology or other words in the singular, plural, capitalization and/or he/she or they, are taken as interchangeable and therefore as referring to same.
Cookies
We employ the use of cookies. By accessing Website Name, you agreed to use cookies in agreement with the Company Name's Privacy Policy.
Most interactive websites use cookies to let us retrieve the user's details for each visit. Cookies are used by our website to enable the functionality of certain areas to make it easier for people visiting our website. Some of our affiliate/advertising partners may also use cookies.
License
Unless otherwise stated, Company Name and/or its licensors own the intellectual property rights for all material on Website Name. All intellectual property rights are reserved. You may access this from Website Name for your own personal use subjected to restrictions set in these terms and conditions.
You must not:
Republish material from Website Name
Sell, rent or sub-license material from Website Name
Reproduce, duplicate or copy material from Website Name
Redistribute content from Website Name
This Agreement shall begin on the date hereof.
Parts of this website offer an opportunity for users to post and exchange opinions and information in certain areas of the website. Company Name does not filter, edit, publish or review Comments prior to their presence on the website. Comments do not reflect the views and opinions of Company Name,its agents and/or affiliates. Comments reflect the views and opinions of the person who post their views and opinions. To the extent permitted by applicable laws, Company Name shall not be liable for the Comments or for any liability, damages or expenses caused and/or suffered as a result of any use of and/or posting of and/or appearance of the Comments on this website.
Company Name reserves the right to monitor all Comments and to remove any Comments which can be considered inappropriate, offensive or causes breach of these Terms and Conditions.
You warrant and represent that:
You are entitled to post the Comments on our website and have all necessary licenses and consents to do so;
The Comments do not invade any intellectual property right, including without limitation copyright, patent or trademark of any third party;
The Comments do not contain any defamatory, libelous, offensive, indecent or otherwise unlawful material which is an invasion of privacy
The Comments will not be used to solicit or promote business or custom or present commercial activities or unlawful activity.
You hereby grant Company Name a non-exclusive license to use, reproduce, edit and authorize others to use, reproduce and edit any of your Comments in any and all forms, formats or media.
Hyperlinking to our Content
The following organizations may link to our Website without prior written approval:
Government agencies;
Search engines;
News organizations;
Online directory distributors may link to our Website in the same manner as they hyperlink to the Websites of other listed businesses; and
System wide Accredited Businesses except soliciting non-profit organizations, charity shopping malls, and charity fundraising groups which may not hyperlink to our Web site.
These organizations may link to our home page, to publications or to other Website information so long as the link: (a) is not in any way deceptive; (b) does not falsely imply sponsorship, endorsement or approval of the linking party and its products and/or services; and (c) fits within the context of the linking party's site.
We may consider and approve other link requests from the following types of organizations:
commonly-known consumer and/or business information sources;
dot.com community sites;
associations or other groups representing charities;
online directory distributors;
internet portals;
accounting, law and consulting firms; and
educational institutions and trade associations.
We will approve link requests from these organizations if we decide that: (a) the link would not make us look unfavorably to ourselves or to our accredited businesses; (b) the organization does not have any negative records with us; (c) the benefit to us from the visibility of the hyperlink compensates the absence of Company Name; and (d) the link is in the context of general resource information.
These organizations may link to our home page so long as the link: (a) is not in any way deceptive; (b) does not falsely imply sponsorship, endorsement or approval of the linking party and its products or services; and (c) fits within the context of the linking party's site.
If you are one of the organizations listed in paragraph 2 above and are interested in linking to our website, you must inform us by sending an e-mail to Company Name. Please include your name, your organization name, contact information as well as the URL of your site, a list of any URLs from which you intend to link to our Website, and a list of the URLs on our site to which you would like to link. Wait 2-3 weeks for a response.
Approved organizations may hyperlink to our Website as follows:
By use of our corporate name; or
By use of the uniform resource locator being linked to; or
By use of any other description of our Website being linked to that makes sense within the context and format of content on the linking party's site.
No use of Company Name's logo or other artwork will be allowed for linking absent a trademark license agreement.
iFrames
Without prior approval and written permission, you may not create frames around our Webpages that alter in any way the visual presentation or appearance of our Website.
Content Liability
We shall not be hold responsible for any content that appears on your Website. You agree to protect and defend us against all claims that is rising on your Website. No link(s) should appear on any Website that may be interpreted as libelous, obscene or criminal, or which infringes, otherwise violates, or advocates the infringement or other violation of, any third party rights.
Reservation of Rights
We reserve the right to request that you remove all links or any particular link to our Website. You approve to immediately remove all links to our Website upon request. We also reserve the right to amen these terms and conditions and it's linking policy at any time. By continuously linking to our Website, you agree to be bound to and follow these linking terms and conditions.
Removal of links from our website
If you find any link on our Website that is offensive for any reason, you are free to contact and inform us any moment. We will consider requests to remove links but we are not obligated to or so or to respond to you directly.
We do not ensure that the information on this website is correct, we do not warrant its completeness or accuracy; nor do we promise to ensure that the website remains available or that the material on the website is kept up to date.
Disclaimer
To the maximum extent permitted by applicable law, we exclude all representations, warranties and conditions relating to our website and the use of this website. Nothing in this disclaimer will:
limit or exclude our or your liability for death or personal injury;
limit or exclude our or your liability for fraud or fraudulent misrepresentation;
limit any of our or your liabilities in any way that is not permitted under applicable law; or
exclude any of our or your liabilities that may not be excluded under applicable law.
The limitations and prohibitions of liability set in this Section and elsewhere in this disclaimer: (a) are subject to the preceding paragraph; and (b) govern all liabilities arising under the disclaimer, including liabilities arising in contract, in tort and for breach of statutory duty.
As long as the website and the information and services on the website are provided free of charge, we will not be liable for any loss or damage of any nature.
''';
}
| 0 |
mirrored_repositories/barber-booking/lib/app/core | mirrored_repositories/barber-booking/lib/app/core/theme/app_theme.dart | import 'package:barber_booking/app/core/utils/material_color_creator_helper.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../values/colors.dart';
class Theming {
static final AppColors _colors = Get.find();
ThemeData appTheme = ThemeData(
primarySwatch: materialColorCreator(_colors.pastelCyan),
primaryColor: _colors.pastelCyan,
brightness: Brightness.dark,
fontFamily: "bitter",
scaffoldBackgroundColor: _colors.frostedBlack,
appBarTheme: const AppBarTheme(
backgroundColor: Colors.transparent,
elevation: 0,
centerTitle: true,
titleTextStyle: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 25,
fontFamily: "bitter",
),
),
);
}
| 0 |
mirrored_repositories/barber-booking/lib/app/core | mirrored_repositories/barber-booking/lib/app/core/utils/material_color_creator_helper.dart | import 'package:flutter/material.dart';
MaterialColor materialColorCreator(Color color) {
List strengths = <double>[.05];
Map<int, Color> swatch = {};
final int r = color.red, g = color.green, b = color.blue;
for (int i = 1; i < 10; i++) {
strengths.add(0.1 * i);
}
for (var strength in strengths) {
final double ds = 0.5 - strength;
swatch[(strength * 1000).round()] = Color.fromRGBO(
r + ((ds < 0 ? r : (255 - r)) * ds).round(),
g + ((ds < 0 ? g : (255 - g)) * ds).round(),
b + ((ds < 0 ? b : (255 - b)) * ds).round(),
1,
);
}
return MaterialColor(color.value, swatch);
}
| 0 |
mirrored_repositories/barber-booking/lib/app/core | mirrored_repositories/barber-booking/lib/app/core/utils/size_config_helper.dart | import 'package:flutter/material.dart';
class SizeConfig {
static late double _screenWidth;
static late double _screenHeight;
static double _blockWidth = 0;
static double _blockHeight = 0;
static late double textMultiplier;
static late double imageSizeMultiplier;
static late double heightMultiplier;
static late double widthMultiplier;
static bool isPortrait = true;
static bool isMobilePortrait = false;
void init(BoxConstraints constraints, Orientation orientation) {
if (orientation == Orientation.portrait) {
_screenWidth = constraints.maxWidth;
_screenHeight = constraints.maxHeight;
isPortrait = true;
if (_screenWidth < 450) {
isMobilePortrait = true;
}
} else {
_screenWidth = constraints.maxHeight;
_screenHeight = constraints.maxWidth;
isPortrait = false;
isMobilePortrait = false;
}
_blockWidth = _screenWidth / 100;
_blockHeight = _screenHeight / 100;
textMultiplier = _blockHeight;
imageSizeMultiplier = _blockWidth;
heightMultiplier = _blockHeight;
widthMultiplier = _blockWidth;
}
}
| 0 |
mirrored_repositories/barber-booking/lib/app/core | mirrored_repositories/barber-booking/lib/app/core/utils/custom_error.dart | class CustomError {
final String title;
final String description;
CustomError({required this.title, required this.description});
}
| 0 |
mirrored_repositories/barber-booking/lib/app/core | mirrored_repositories/barber-booking/lib/app/core/utils/distance_calculator.dart | import 'dart:math';
String distanceBetweenTwoPoints(
{required myLat, required mylon, required lat1, required lon1}) {
var p = 0.017453292519943295;
var c = cos;
var a = 0.5 -
c((myLat - lat1) * p) / 2 +
c(lat1 * p) * c(myLat * p) * (1 - c((mylon - lon1) * p)) / 2;
var kmResult = 12742 * asin(sqrt(a));
var meterResult = 1000 * kmResult;
// check for distance and return ditance per meter if distance in less than one kilometer
return (kmResult >= 1)
? "${kmResult.toStringAsFixed(2)} Kilometers away"
: "${meterResult.toStringAsFixed(2)} meters away";
}
| 0 |
mirrored_repositories/barber-booking/lib/app | mirrored_repositories/barber-booking/lib/app/global_widgets/global_button.dart | import 'package:flutter/material.dart';
class GlobalButton extends StatelessWidget {
const GlobalButton({
Key? key,
required this.child,
required this.color,
required this.onPressed,
this.elevation,
this.height,
this.width,
required this.radius,
this.borderColor,
this.borderedButton = false,
}) : super(key: key);
final Widget child;
final Color color;
final VoidCallback onPressed;
final double? elevation, height, width;
final double radius;
final bool borderedButton;
final Color? borderColor;
@override
Widget build(BuildContext context) {
return SizedBox(
width: width,
height: height,
child: ElevatedButton(
onPressed: onPressed,
child: child,
style: ElevatedButton.styleFrom(
primary: borderedButton ? Colors.transparent : color,
shape: borderedButton
? RoundedRectangleBorder(
borderRadius: BorderRadius.circular(radius),
side: BorderSide(
color: borderColor ?? color,
width: 2,
),
)
: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(radius),
),
elevation: elevation,
),
),
);
}
}
| 0 |
mirrored_repositories/barber-booking/lib/app | mirrored_repositories/barber-booking/lib/app/global_widgets/global_form_field.dart | import 'package:barber_booking/app/core/values/colors.dart';
import 'package:barber_booking/app/core/values/dimes.dart';
import 'package:barber_booking/app/data/enums/text_size_option.dart';
import 'package:barber_booking/app/global_widgets/optimized_text.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class GlobalTextFormField extends StatelessWidget {
GlobalTextFormField({
Key? key,
required this.controller,
required this.label,
this.isEmailField = false,
this.isPasswordField = false,
this.isEnable = true,
}) : super(key: key);
final AppColors _colors = Get.find();
final Dimens _dimens = Get.find();
final TextEditingController controller;
final String label;
final bool isEmailField;
final bool isPasswordField;
final bool isEnable;
@override
Widget build(BuildContext context) {
return TextFormField(
enabled: isEnable,
controller: controller,
autovalidateMode: AutovalidateMode.onUserInteraction,
validator: (val) {
if (val != null) {
if (val.isEmpty) {
return "Field Cannot be empty";
} else if (!GetUtils.isEmail(val) && isEmailField) {
return "Email is not valid";
} else if (isPasswordField && val.length < 6) {
return "Enter 6 character or more as password";
}
} else {
return "Field Cannot be empty";
}
return null;
},
decoration: InputDecoration(
label: OptimizedText(
label,
textAlign: TextAlign.left,
sizeOption: TextSizeOptions.caption,
customColor: _colors.hintTextColor,
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(_dimens.defaultRadius),
borderSide:
BorderSide(color: _colors.focusBorderFormFieldColor, width: 1.0),
),
disabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(_dimens.defaultRadius),
borderSide:
BorderSide(color: _colors.enableBorderFormFieldColor, width: 1.0),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(_dimens.defaultRadius),
borderSide:
BorderSide(color: _colors.enableBorderFormFieldColor, width: 1.0),
),
errorBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(_dimens.defaultRadius),
borderSide:
BorderSide(color: _colors.errorBorderFormFieldColor, width: 1.0),
),
focusedErrorBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(_dimens.defaultRadius),
borderSide:
BorderSide(color: _colors.errorBorderFormFieldColor, width: 1.0),
),
),
);
}
}
| 0 |
mirrored_repositories/barber-booking/lib/app | mirrored_repositories/barber-booking/lib/app/global_widgets/not_found_page.dart | import 'package:flutter/material.dart';
class NotFoundPage extends StatelessWidget {
const NotFoundPage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold();
}
}
| 0 |
mirrored_repositories/barber-booking/lib/app | mirrored_repositories/barber-booking/lib/app/global_widgets/global_error.dart | import 'package:barber_booking/app/core/utils/size_config_helper.dart';
import 'package:barber_booking/app/data/enums/text_color_option.dart';
import 'package:barber_booking/app/data/enums/text_size_option.dart';
import 'package:barber_booking/app/global_widgets/global_button.dart';
import 'package:barber_booking/app/global_widgets/optimized_text.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../exports.dart';
class GlobalErrorWidget extends StatelessWidget {
GlobalErrorWidget({Key? key, required this.onTap}) : super(key: key);
final VoidCallback onTap;
final AppColors _colors = Get.find();
final Strings _strings = Get.find();
final Dimens _dimens = Get.find();
@override
Widget build(BuildContext context) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
OptimizedText(
_strings.errorWidgetTitle,
sizeOption: TextSizeOptions.bigBody,
colorOption: TextColorOptions.light,
),
SizedBox(height: SizeConfig.heightMultiplier * 2),
OptimizedText(
_strings.errorWidgetDescription,
sizeOption: TextSizeOptions.caption,
colorOption: TextColorOptions.hint,
maxLine: 2,
),
SizedBox(height: SizeConfig.heightMultiplier * 2),
GlobalButton(
width: SizeConfig.widthMultiplier * 50,
child: OptimizedText(
_strings.errorWidgetButtonTitle,
sizeOption: TextSizeOptions.button,
fontWeight: FontWeight.bold,
),
color: _colors.pastelCyan,
onPressed: onTap,
radius: _dimens.defaultRadius,
)
],
);
}
}
| 0 |
mirrored_repositories/barber-booking/lib/app | mirrored_repositories/barber-booking/lib/app/global_widgets/global_indicator.dart | import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'dart:io' show Platform;
class GlobalIndicator extends StatelessWidget {
const GlobalIndicator({Key? key, this.size, this.color}) : super(key: key);
final double? size;
final Color? color;
@override
Widget build(BuildContext context) {
if (Platform.isIOS || Platform.isMacOS) {
return Center(
child: SizedBox(
width: size,
height: size,
child: CupertinoActivityIndicator(
color: color,
animating: true,
),
),
);
} else {
return Center(
child: SizedBox(
width: size,
height: size,
child: CircularProgressIndicator(
color: color,
strokeWidth: 1.7,
),
),
);
}
}
}
| 0 |
mirrored_repositories/barber-booking/lib/app | mirrored_repositories/barber-booking/lib/app/global_widgets/optimized_text.dart | import 'package:auto_size_text/auto_size_text.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../core/values/colors.dart';
import '../data/enums/text_color_option.dart';
import '../data/enums/text_size_option.dart';
class OptimizedText extends StatelessWidget {
OptimizedText(
this.txt, {
Key? key,
this.maxLine = 1,
this.textAlign = TextAlign.center,
this.sizeOption = TextSizeOptions.body,
this.colorOption = TextColorOptions.dark,
this.fontWeight = FontWeight.normal,
this.customColor,
}) : super(
key: key,
);
final String txt;
final int maxLine;
final TextAlign textAlign;
final TextSizeOptions sizeOption;
final TextColorOptions colorOption;
final FontWeight fontWeight;
final Color? customColor;
final AppColors _colors = Get.find();
double setTextSize() {
double? fontSize;
if (sizeOption == TextSizeOptions.body) {
fontSize = 19.0;
} else if (sizeOption == TextSizeOptions.underline) {
fontSize = 15.0;
} else if (sizeOption == TextSizeOptions.button) {
fontSize = 19.0;
} else if (sizeOption == TextSizeOptions.caption) {
fontSize = 14.0;
} else if (sizeOption == TextSizeOptions.title) {
fontSize = 30.0;
} else if (sizeOption == TextSizeOptions.bigBody) {
fontSize = 25;
} else if (sizeOption == TextSizeOptions.small) {
fontSize = 12.0;
}
return fontSize ?? 14;
}
@override
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: Text(
txt,
style: TextStyle(
fontSize: setTextSize(),
color: customColor ??
((colorOption == TextColorOptions.hint)
? _colors.hintTextColor.withOpacity(.6)
: (colorOption == TextColorOptions.light)
? _colors.lightTxtColor
: _colors.darkTxtColor),
fontWeight: fontWeight,
),
overflow: TextOverflow.ellipsis,
textAlign: textAlign,
maxLines: maxLine,
),
),
],
);
}
}
| 0 |
mirrored_repositories/barber-booking/lib/app | mirrored_repositories/barber-booking/lib/app/global_widgets/bottom_sheet_line.dart | import 'package:barber_booking/app/core/values/dimes.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class BottomSheetLine extends StatelessWidget {
BottomSheetLine({Key? key}) : super(key: key);
final Dimens _dimens = Get.find();
@override
Widget build(BuildContext context) {
return Container(
width: 60,
height: 8,
margin: EdgeInsets.only(
top: _dimens.defaultMargin,
),
decoration: BoxDecoration(
color: Colors.white.withOpacity(.2),
borderRadius: BorderRadius.circular(_dimens.defaultRadius),
),
);
}
}
| 0 |
mirrored_repositories/barber-booking/lib/app | mirrored_repositories/barber-booking/lib/app/global_widgets/parent_widget.dart | import 'package:flutter/material.dart';
class ParentWidget extends StatelessWidget {
const ParentWidget({Key? key, required this.child}) : super(key: key);
final Widget child;
@override
Widget build(BuildContext context) {
return LayoutBuilder(
builder: (context, constraints) => SingleChildScrollView(
child: ConstrainedBox(
constraints: BoxConstraints(minHeight: constraints.maxHeight),
child: child,
),
),
);
}
}
| 0 |
mirrored_repositories/barber-booking/lib/app | mirrored_repositories/barber-booking/lib/app/global_widgets/global_snackbar.dart | import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:ionicons/ionicons.dart';
import '../exports.dart';
void globalSnackbar({
required String content,
DismissDirection dismissDirection = DismissDirection.down,
SnackPosition snackPosition = SnackPosition.BOTTOM,
bool isPermanet = false,
VoidCallback? onTap,
}) {
final AppColors _colors = Get.find();
final Dimens _dimens = Get.find();
final Strings _strings = Get.find();
Get.snackbar(
_strings.noticeTitle,
content,
icon: Icon(Ionicons.notifications, color: _colors.frostedBlack),
mainButton: (onTap != null)
? TextButton(
onPressed: onTap,
child: Icon(
Ionicons.refresh_outline,
color: _colors.darkTxtColor,
))
: null,
snackPosition: snackPosition,
backgroundColor: _colors.pastelCyan,
borderRadius: _dimens.defaultRadius * .5,
margin: EdgeInsets.all(_dimens.defaultMargin),
colorText: _colors.frostedBlack,
duration: isPermanet ? null : const Duration(seconds: 4),
isDismissible: true,
dismissDirection: dismissDirection,
forwardAnimationCurve: Curves.easeOutBack,
);
}
| 0 |
mirrored_repositories/barber-booking | mirrored_repositories/barber-booking/test/widget_test.dart | // This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility that Flutter provides. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:barber_booking/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(const MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}
| 0 |
mirrored_repositories | mirrored_repositories/AcademicAndroid-IOS/main.dart | import 'package:first_flutter_project/RandomWords.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
// title: 'Generator Nazw',
// home: Scaffold(
// appBar: AppBar(
// title: Text('Generator Nazw'),
// ),
// body: Center(
// child: RandomWords(),
// ),
// ),
title: 'Startup Name Generator',
theme: ThemeData(
primaryColor: Colors.green
),
home: RandomWords(),
);
}
}
| 0 |
mirrored_repositories | mirrored_repositories/AcademicAndroid-IOS/RandomWords.dart | import 'package:english_words/english_words.dart';
import 'package:flutter/material.dart';
class RandomWords extends StatefulWidget {
@override
_RandomWordsState createState() => _RandomWordsState();
}
class _RandomWordsState extends State<RandomWords> {
final _suggestions = <WordPair>[];
final _saved = <WordPair>{};
final _biggerFont = TextStyle(fontSize: 18.0);
Widget _buildSuggestions() {
return ListView.builder(
padding: EdgeInsets.all(16.0),
itemBuilder: (context, i) {
if (i.isOdd) return Divider();
final index = i ~/ 2;
if (index >= _suggestions.length) {
_suggestions.addAll(generateWordPairs().take(10));
}
return _buildRow(_suggestions[index]);
}
);
}
Widget _buildRow(WordPair pair) {
final alreadySaved = _saved.contains(pair);
return ListTile(
title: Text(
pair.asPascalCase,
style: _biggerFont,
),
trailing: Icon(
alreadySaved ? Icons.accessible: Icons.accessible_forward_sharp,
color: alreadySaved ? Colors.deepOrange : null,
),
onTap: () {
setState(() {
if (alreadySaved) {
_saved.remove(pair);
} else {
_saved.add(pair);
}
});
},
);
}
void _pushSaved() {
Navigator.of(context).push(
MaterialPageRoute<void>(
builder: (BuildContext context) {
final tiles = _saved.map(
(WordPair pair) {
return ListTile(
title: Text(
pair.asPascalCase,
style: _biggerFont,
),
);
},
);
final divided = ListTile.divideTiles(
context: context,
tiles: tiles,
).toList();
return Scaffold(
appBar: AppBar(
title: Text('Saved Suggestions'),
backgroundColor: Colors.deepOrange,
),
body: ListView(children: divided),
);
},
),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Startup Name Generator'),
backgroundColor: Colors.deepOrange,
actions: [
IconButton(onPressed: _pushSaved, icon: Icon(Icons.accessible))
],
),
body: _buildSuggestions(),
);
}
} | 0 |
mirrored_repositories/gravestone | mirrored_repositories/gravestone/lib/bottom_navigation_widget.dart | import 'package:flutter/material.dart';
import 'pages/home_screen.dart';
import 'pages/email_screen.dart';
import 'pages/pages_screen.dart';
import 'pages/person_screen.dart';
class BottomNavigationWidget extends StatefulWidget {
@override
_BottomNavigationWidgetState createState() => _BottomNavigationWidgetState();
}
class _BottomNavigationWidgetState extends State<BottomNavigationWidget> {
final _bottomNavigationColor = Colors.blue;
int _currentIndex = 0;
List<Widget> list = List();
@override
void initState(){
list
..add(GraveListPage())
..add(EmailScreen())
..add(PagesScreen())
..add(PersonScreen());
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: list[_currentIndex],
bottomNavigationBar: BottomNavigationBar(items: [
BottomNavigationBarItem(
icon: Icon(
Icons.home,
color: _bottomNavigationColor,
),
title: Text(
'主页',
style: TextStyle(
color: _bottomNavigationColor
)
)
),
BottomNavigationBarItem(
icon: Icon(
Icons.email,
color: _bottomNavigationColor,
),
title: Text(
'消息',
style: TextStyle(
color: _bottomNavigationColor
)
)
),
BottomNavigationBarItem(
icon: Icon(
Icons.pages,
color: _bottomNavigationColor,
),
title: Text(
'收藏',
style: TextStyle(
color: _bottomNavigationColor
)
)
),
BottomNavigationBarItem(
icon: Icon(
Icons.person,
color: _bottomNavigationColor,
),
title: Text(
'我的',
style: TextStyle(
color: _bottomNavigationColor
)
)
),
],
currentIndex: _currentIndex,
onTap: (int index){
setState(() {
_currentIndex = index;
});
},
),
);
}
}
| 0 |
mirrored_repositories/gravestone | mirrored_repositories/gravestone/lib/login.dart | import 'package:flutter/material.dart';
class Login extends StatefulWidget {
@override
_LoginState createState() => _LoginState();
}
class _LoginState extends State<Login> {
var leftRightPadding = 30.0;
var topBottomPadding = 4.0;
var textTips = new TextStyle(fontSize: 16.0,color: Colors.black);
var hintTips = new TextStyle(fontSize: 15.0,color: Colors.black26);
static const LOGO = "images/grave.png";
FocusNode _focusNodeUserName = new FocusNode();
FocusNode _focusNodeUserPass = new FocusNode();
var _userNameController = new TextEditingController();
var _userPassController = new TextEditingController();
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text("登录",style: new TextStyle(color: Colors.white),),
leading: IconButton(
icon: Icon(Icons.arrow_back_ios),
onPressed: () {
print('Clicked Leading');
//TODO:close app
},
),
actions: <Widget>[
IconButton(
icon: Icon(Icons.star_border),
onPressed: (){
print('Clicked Star');
//TODO:follow a grave action
},
),
IconButton(
icon: Icon(Icons.share),
onPressed: (){
print('Clicked share');
//TODO:follow a grave action
},
),
Container(
child: new Card(
color: Colors.green,
elevation: 6.0,
child: new FlatButton(
onPressed: (){
print('clicked register');
//TODO:跳转到注册页面
},
child: new Padding(
padding: new EdgeInsets.all(10.0),
child: new Text(
'注册',
style: new TextStyle(color: Colors.white,fontSize: 16.0),
),
)
),
),
)
],
iconTheme: new IconThemeData(color: Colors.white),
),
body: new Column(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
new Padding(
padding: new EdgeInsets.fromLTRB(
leftRightPadding,10.0,leftRightPadding,10.0),
child: new Image.asset(LOGO),
),
new Padding(
padding: new EdgeInsets.fromLTRB(
leftRightPadding,10.0,leftRightPadding,topBottomPadding),
child: new TextField(
style: hintTips,
controller: _userNameController,
decoration: new InputDecoration(
border: const UnderlineInputBorder(),
filled: true,
icon: const Icon(Icons.person),
hintText: "请输入用户名",
labelText: "用户名",
),
obscureText: false,
focusNode: _focusNodeUserName,
onSubmitted: (String userName){
//TODO:Save userName to SQL
},
),
),
new Padding(
padding: new EdgeInsets.fromLTRB(
leftRightPadding, 10.0, leftRightPadding, topBottomPadding),
child: new TextField(
style: hintTips,
controller: _userPassController,
decoration: new InputDecoration(
border: const UnderlineInputBorder(),
filled: true,
icon: const Icon(Icons.vpn_key),
hintText: "请输入密码",
labelText: "密码",
),
obscureText: true,
focusNode: _focusNodeUserPass,
onSubmitted: (String userPass){
//TODO:Save userPass to SQL
},
),
),
new Container(
width: 360.0,
margin: new EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 0.0),
padding: new EdgeInsets.fromLTRB(
leftRightPadding, topBottomPadding, leftRightPadding, topBottomPadding),
child: new Card(
color: Colors.green,
elevation: 6.0,
child: new FlatButton(
onPressed: (){
print("the pass is"+_userPassController.text);
//TODO:验证和登录
},
child: new Padding(
padding: new EdgeInsets.all(10.0),
child: new Text(
'立即登录',
style: new TextStyle(color: Colors.white,fontSize: 16.0),
),
)
),
),
)
],
),
);
}
}
| 0 |
mirrored_repositories/gravestone | mirrored_repositories/gravestone/lib/splash_screen.dart | import 'package:flutter/material.dart';
import 'bottom_navigation_widget.dart';
class SplashScreen extends StatefulWidget {
@override
_SplashScreenState createState() => _SplashScreenState();
}
class _SplashScreenState extends State<SplashScreen> with SingleTickerProviderStateMixin{
AnimationController _controller;
Animation _animation;
@override
void initState() {
super.initState();
_controller = AnimationController(vsync: this,duration: Duration(milliseconds: 3000));
_animation = Tween(begin: 0.0,end: 1.0).animate(_controller);
_animation.addStatusListener((status) {
if(status == AnimationStatus.completed){
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(builder: (context) => BottomNavigationWidget()),
(route) => route == null
);
}
});
_controller.forward();//播放动画
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return FadeTransition(
opacity: _animation,
child: Image.asset(
"images/splash.jpg",
scale: 2.0,
fit: BoxFit.cover,
),
);
}
}
| 0 |
mirrored_repositories/gravestone | mirrored_repositories/gravestone/lib/main.dart | import 'package:flutter/material.dart';
import 'splash_screen.dart';
void main() =>runApp(MyApp());
class MyApp extends StatelessWidget{
@override
Widget build(BuildContext context){
return MaterialApp(
title:'Flutter bottomNavigationBar',
theme: ThemeData.light(),
home: SplashScreen(),
);
}
} | 0 |
mirrored_repositories/gravestone/lib | mirrored_repositories/gravestone/lib/pages/home_screen.dart | import 'package:flutter/material.dart';
import 'package:banner_view/banner_view.dart';
import 'package:flutter_refresh/flutter_refresh.dart';
import '../banner_component/banner_item.dart';
import '../banner_component/pair.dart';
class GraveListPage extends StatefulWidget {
@override
_GraveListPageState createState() => _GraveListPageState();
}
class _GraveListPageState extends State<GraveListPage>{
List<Pair<String, Color>> param = [
Pair.create('1', Colors.red[500]),
Pair.create('2', Colors.green[500]),
Pair.create('3', Colors.blue[500]),
Pair.create('4', Colors.yellow[500]),
Pair.create('5', Colors.purple[500]),
];
List<Map> listData = [
{
'title':'why',
'personImg':'https://www.baidu.com/img/superlogo_c4d7df0a003d3db9b65e9ef0fe6da1ec.png?where=super',
'info':'2019-02-09',
'commentCount':'0',
'imgUrl':'https://www.baidu.com/img/superlogo_c4d7df0a003d3db9b65e9ef0fe6da1ec.png?where=super',
},
];
@override
Widget build(BuildContext context) {
return new Refresh(
onFooterRefresh: onFooterRefresh,
onHeaderRefresh: onHeaderRefresh,
childBuilder: (BuildContext context,
{ScrollController controller, ScrollPhysics physics}){
return new ListView.builder(
itemCount: listData.length * 2 + 1,
controller: controller,
physics: physics,
itemBuilder: (context,i) => renderRow(i)
);
},
);
}
Future<Null> onFooterRefresh() {
return new Future.delayed(new Duration(seconds: 2), () {
setState(() {
//TODO:更新策略
// _mCurPage++;
// getNewsList(_mCurPage);
});
});
}
Future<Null> onHeaderRefresh() {
return new Future.delayed(new Duration(seconds: 2), () {
setState(() {
//TODO:更新策略
//_mCurPage = 1;
//getNewsList(_mCurPage);
});
});
}
/*
getNewsList(int curPage) {
String url = Api.NEWS_LIST_BASE_URL;
url += '?pageIndex=$curPage&pageSize=4';
Http.get(url).then((res) {
if (res != null) {
Map<String, dynamic> map = json.decode(res);
debugPrint("the res is" + map.toString());
if (map['code'] == 0) {
var msg = map['msg'];
listTotalSize = msg['news']['total'];
var _listData = msg['news']['data'];
var _slideData = msg['slide'];
setState(() {
if (curPage == 1) {
listData = _listData;
slideData = _slideData;
} else {
List tempList = new List();
tempList.addAll(listData);
tempList.addAll(_listData);
if (tempList.length >= listTotalSize) {
tempList.add('the end');
}
listData = tempList;
slideData = _slideData;
}
});
}
} else {
debugPrint("the res is null");
}
});
}
*/
Widget renderRow(i){
///i=0时渲染为轮播图
if(i == 0){
return new Container(
height: 180.0,
//TODO:插入轮播图
child: new BannerView(
BannerItemFactory.banners(param),
intervalDuration: Duration(seconds: 3),
),
);
}
///i > 0时
i -= 1;
///i为奇数时,渲染分割线
if(i.isOdd){
return new Divider(height: 1.0,);
}
///将i取整
i = i ~/ 2;
//TODO:得到列表数据
var itemData = listData[i];
///标题行
var titleRow = new Row(
children: <Widget>[
new Expanded(
child: new Text(itemData['title'],style: TextStyle(),),//TODO:分离标题
)
],
);
///墓碑信息行
var infoRow = new Row(
children: <Widget>[
new Container(
///头像
width: 20.0,
height: 20.0,
decoration: new BoxDecoration(
shape: BoxShape.circle,
color: Colors.white,
image: new DecorationImage(
image: new NetworkImage(itemData['personImg']),//TODO:分离头像链接
fit: BoxFit.cover,
),
border: new Border.all(
color: Colors.white,
width: 2.0,
)
),
),
///时间文本
new Padding(
padding: EdgeInsets.fromLTRB(4.0, 0.0, 0.0, 0.0),
child: new Text(
itemData['info'],//TODO:分离时间文本
style: new TextStyle(),//TODO:时间文本格式
),
),
///评论数(由一个评论图标和具体的评论数构成)
new Expanded(
flex: 1,
child: new Row(
///为了让评论数显示在最右侧,所以需要外面的Expanded和MainAxisAlignment
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
new Text(
itemData['commentCount'],//TODO:分离评论数
style: TextStyle(),//TODO:评论数文本格式
),
new Padding(
padding: new EdgeInsets.fromLTRB(4.0, 0.0, 0.0, 0.0),
child: new Image.asset(
'images/avatar_default.png',//TODO:评论图标
width: 16.0,
height: 16.0,
),
)
],
)
)
],
);
var thumbImgUrl = itemData['imgUrl'];//右侧图片
///默认的右侧图片
var thumbImg = new Container(
margin: EdgeInsets.all(10.0),
width: 60.0,
height: 60.0,
decoration: new BoxDecoration(
shape: BoxShape.circle,
color: Colors.black26,
image: new DecorationImage(
image: ExactAssetImage('images/avatar_default.png'),//TODO:设置默认图片
fit: BoxFit.cover,
),
border: new Border.all(
color: Colors.white,
width: 2.0
)
),
);
///如果有图片,就使用网络图片,而不是默认图片
if(thumbImgUrl != null && thumbImgUrl.length > 0){
thumbImg = new Container(
//margin: EdgeInsets.all(10.0),
//width: 60.0,
//height: 60.0,
decoration: new BoxDecoration(
color: Colors.black26,
image: new DecorationImage(
image: new NetworkImage(thumbImgUrl),
fit: BoxFit.cover
),
border: new Border.all(
color: Colors.black26,
width: 2.0,
)
),
);
}
///ListItem 的一行
var row = new Row(
children: <Widget>[
new Expanded(
flex: 1,
child: new Padding(
padding: EdgeInsets.all(10.0),
child: new Column(
children: <Widget>[
titleRow,
new Padding(
padding: EdgeInsets.fromLTRB(0.0, 8.0, 0.0, 0.0),
child: infoRow,
)
],
),
)
),
///右侧图片
new Padding(
padding: EdgeInsets.all(6.0),
child: new Container(
width: 100.0,
height: 80.0,
color: Colors.white,
child: new Center(
child: thumbImg,
),
),
)
],
);
///用InkWell包裹row,让row可以点击
return new InkWell(
child: row,
onTap: (){},//TODO:点击事件
);
}
}
| 0 |
mirrored_repositories/gravestone/lib | mirrored_repositories/gravestone/lib/pages/pages_screen.dart | import 'package:flutter/material.dart';
class PagesScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Pages'),
),
body: Center(
child: Text('Pages'),
),
);
}
} | 0 |
mirrored_repositories/gravestone/lib | mirrored_repositories/gravestone/lib/pages/email_screen.dart | import 'package:flutter/material.dart';
class EmailScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Email'),
),
body: Center(
child: Text('Email'),
),
);
}
} | 0 |
mirrored_repositories/gravestone/lib | mirrored_repositories/gravestone/lib/pages/person_screen.dart | import 'package:flutter/material.dart';
class PersonScreen extends StatelessWidget {
List<String> titles = [
'我的消息',
'阅读记录',
'我的墓碑',
'我的问答',
'我的活动',
'我的xx',
'我的xx',
'我的xx',
'我的xx',
'我的xx',
'我的xx',
'我的xx',
'我的xx',
'我的xx',
'我的xx',
'我的xx',
];
var userAvatar = null;
var userName = null;
//TODO:判断是否登录并从数据库获取用户头像和用户名
@override
Widget build(BuildContext context) {
return Container(
child: CustomScrollView(
reverse: false,
shrinkWrap: false,
slivers: <Widget>[
new SliverAppBar(
pinned: false,
backgroundColor: Colors.green,
expandedHeight: 200.0,
iconTheme: new IconThemeData(color: Colors.transparent),
flexibleSpace: new InkWell(
onTap: (){
userAvatar == null ? debugPrint('登录') : debugPrint('用户信息');
//TODO:判断是否登录
},
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
userAvatar == null
? new Image.asset(
'images/avatar_default.png',
width: 60.0,
height: 60.0,
)
: new Container(
width: 60.0,
height: 60.0,
decoration: new BoxDecoration(
shape: BoxShape.circle,
color: Colors.transparent,
image: new DecorationImage(
image: new NetworkImage(userAvatar),
//TODO:从数据库获取用户头像
fit: BoxFit.cover,
),
border: new Border.all(
color: Colors.white,
width: 2.0,
)
),
),
new Container(
margin: const EdgeInsets.fromLTRB(0.0, 10.0, 0.0, 0.0),
child: new Text(
userName == null ? '点击修改头像' : userName,
style: new TextStyle(
color: Colors.white,
fontSize: 16.0,
),
),
)
],
),
),
),
new SliverFixedExtentList(
delegate:
new SliverChildBuilderDelegate((BuildContext context,int index){
String title = titles[index];
return new Container(
alignment: Alignment.centerLeft,
child: new InkWell(
onTap: (){
print('this is the item of $title');
//TODO:各个组件对应的点击事件
},
child: new Column(
children: <Widget>[
new Padding(
padding: const EdgeInsets.all(10.0),
child: new Row(
children: <Widget>[
new Expanded(
child: new Text(
title,
style: TextStyle(),//TODO:设置文字样式
)
),
new Icon(
Icons.chevron_right,
),
],
),
),
new Divider(
height: 6.0,
)
],
),
),
);
},childCount: titles.length),
itemExtent: 50.0
),
],
)
);
}
} | 0 |
mirrored_repositories/gravestone/lib | mirrored_repositories/gravestone/lib/banner_component/pair.dart | class Pair<F, S>{
F first;
S second;
Pair(F first, S second) {
this.first = first;
this.second = second;
}
static Pair<F, S> create<F, S>(F first, S second) {
return new Pair(first, second);
}
} | 0 |
mirrored_repositories/gravestone/lib | mirrored_repositories/gravestone/lib/banner_component/banner_item.dart | import 'package:flutter/material.dart';
import 'pair.dart';
class BannerItemFactory {
static List<Widget> banners(List<Pair<String, Color>> param) {
TextStyle style = new TextStyle(
fontSize: 70.0,
color: Colors.white,
);
Widget _bannerText(Color color, String text) {
return new Container(
alignment: Alignment.center,
height: double.infinity,
color: color,
child: new Text(
text,
style: style,
),
);
}
Widget _bannerImage(Color color, String url) {
return new Container(
alignment: Alignment.center,
height: double.infinity,
color: color,
child: new Image.network(url, fit: BoxFit.cover, width: double.infinity, height: double.infinity,),
);
}
List<Widget> _renderBannerItem(List<Pair<String, Color>> param) {
return param.map((item) {
final text = item.first;
final color = item.second;
return text.startsWith('http://') || text.startsWith('https://') ?
_bannerImage(color, text) :
_bannerText(color, text);
}).toList();
}
return _renderBannerItem(param);
}
} | 0 |
mirrored_repositories/gravestone/lib | mirrored_repositories/gravestone/lib/http_component/http.dart | import 'package:http/http.dart' as http;
import 'dart:async';
class Http{
//get请求
static Future<String> get(String url,{Map<String,String>params})async{
if(params != null && params.isNotEmpty){
StringBuffer stringBuffer = new StringBuffer("?");
params.forEach((key,value){
stringBuffer.write("$key" + "=$value" + "&");
});
String paramStr = stringBuffer.toString();
paramStr = paramStr.substring(0, paramStr.length -1);
url += paramStr;
}
http.Response res = await http.get(url);
if(res.statusCode == 200){
return res.body;
}else{
return null;
}
}
//post请求
static Future<String> post(String url,{Map<String,String>params})async{
http.Response res = await http.post(url, body: params);
return res.body;
}
}
| 0 |
mirrored_repositories/gravestone | mirrored_repositories/gravestone/test/unit_test.dart | import 'package:flutter_test/flutter_test.dart';
void main() {
test('my first unit test', () {
var answer = 42;
expect(answer, 42);
});
}
| 0 |
mirrored_repositories/github_api | mirrored_repositories/github_api/lib/main.dart | import 'package:flutter/material.dart';
import 'package:github_api/screens/homepage.dart';
import 'package:github_api/screens/repospage.dart';
import 'package:github_api/screens/splashscreen.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: const HomePage(),
initialRoute: SplashScreen.id,
routes: {
HomePage.id: (context) => const HomePage(),
ReposPage.id: (context) => const ReposPage(),
SplashScreen.id: (context) => const SplashScreen(),
},
);
}
}
| 0 |
mirrored_repositories/github_api/lib | mirrored_repositories/github_api/lib/models/repo.dart | // import 'dart:convert';
// class Repos {
// Repos(
// {required this.id,
// required this.name,
// required this.svnUrl,
// required this.description});
// int id;
// String name;
// String svnUrl;
// String description;
// factory Repos.fromMap(Map<String, dynamic> json) => Repos(
// id: json["id"],
// name: json["name"],
// svnUrl: json["svn_url"],
// description: json["description"]);
// }
// To parse this JSON data, do
//
// final medias = mediasFromMap(jsonString);
// import 'dart:convert';
// class Repos {
// Repos({
// required this.data,
// });
// List<Repo> data;
// factory Repos.fromJson(String str) => Repos.fromMap(json.decode(str));
// String toJson() => json.encode(toMap());
// factory Repos.fromMap(Map<String, dynamic> json) => Repos(
// data: List<Repo>.from(json["data"].map((x) => Repo.fromMap(x))),
// );
// Map<String, dynamic> toMap() => {
// "data": List<dynamic>.from(data.map((x) => x.toMap())),
// };
// }
// class Repo {
// Repo({
// required this.id,
// required this.name,
// required this.svnUrl,
// required this.description,
// });
// String id;
// String name;
// String svnUrl;
// String description;
// factory Repo.fromJson(String str) => Repo.fromMap(json.decode(str));
// String toJson() => json.encode(toMap());
// factory Repo.fromMap(Map<String, dynamic> json) => Repo(
// id: json["id"] ?? "",
// name: json["name"] ?? "",
// svnUrl: json["svn_url"] ?? "",
// description: json["description"] ?? "",
// );
// Map<String, dynamic> toMap() => {
// "id": id,
// "name": name,
// "svn_url": svnUrl,
// "description": description,
// };
// }
import 'dart:convert';
List<Repo> repoFromMap(String str) =>
List<Repo>.from(json.decode(str).map((x) => Repo.fromMap(x)));
String repoToMap(List<Repo> data) =>
json.encode(List<dynamic>.from(data.map((x) => x.toMap())));
class Repo {
Repo({
required this.id,
required this.name,
this.description,
required this.svnUrl,
});
int id;
String name;
dynamic description;
String svnUrl;
factory Repo.fromMap(Map<String, dynamic> json) => Repo(
id: json["id"],
name: json["name"],
description: json["description"] ?? "No description available",
svnUrl: json["svn_url"],
);
Map<String, dynamic> toMap() => {
"id": id,
"name": name,
"description": description,
"svn_url": svnUrl,
};
}
| 0 |
mirrored_repositories/github_api/lib | mirrored_repositories/github_api/lib/screens/homepage.dart | import 'package:flutter_neumorphic/flutter_neumorphic.dart';
import 'package:get_storage/get_storage.dart';
import 'package:github_api/screens/repospage.dart';
class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key);
static String id = "HomePage";
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
final myController = TextEditingController();
@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
resizeToAvoidBottomInset: false,
backgroundColor: const Color(0xff0D1117),
appBar: AppBar(
foregroundColor: Colors.white,
backgroundColor: Colors.transparent,
elevation: 0,
title: const Text(
"GitGram",
),
centerTitle: true,
),
body: Padding(
padding: const EdgeInsets.symmetric(vertical: 40, horizontal: 10),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
SizedBox(
height: 100,
child: Image.asset("assets/Octocat.png"),
),
const SizedBox(
height: 20,
),
const Text(
"Enter the username",
style: TextStyle(
color: Colors.white,
fontSize: 18,
),
),
const SizedBox(
height: 30,
),
Padding(
padding: const EdgeInsets.all(15.0),
child: TextField(
autofocus: false,
style: const TextStyle(color: Colors.white),
controller: myController,
onSubmitted: (value) async {
final storage = GetStorage();
await Future.wait([
storage.write("username", myController.text),
]);
Navigator.pushNamed(
context,
ReposPage.id,
);
myController.clear();
},
decoration: InputDecoration(
labelText: "Username",
labelStyle: const TextStyle(color: Colors.white),
floatingLabelBehavior: FloatingLabelBehavior.auto,
prefixIcon: const Icon(
Icons.person,
color: Colors.green,
size: 30,
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(30),
borderSide: const BorderSide(
color: Colors.green,
width: 2.0,
),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(15),
borderSide: const BorderSide(
color: Colors.green,
width: 1.0,
),
),
),
),
),
const SizedBox(
height: 30,
),
Neumorphic(
style: NeumorphicStyle(
shape: NeumorphicShape.concave,
boxShape: NeumorphicBoxShape.roundRect(
BorderRadius.circular(20)),
depth: 8,
lightSource: LightSource.topLeft,
shadowLightColor: Colors.green,
color: Colors.green),
child: TextButton(
child: const Padding(
padding: EdgeInsets.symmetric(
horizontal: 40,
vertical: 15,
),
child: Text(
'Fetch data',
style: TextStyle(color: Colors.white),
),
),
onPressed: () async {
final storage = GetStorage();
await Future.wait([
storage.write("username", myController.text),
]);
Navigator.pushNamed(
context,
ReposPage.id,
);
myController.clear();
},
)),
],
),
),
),
);
}
}
| 0 |
mirrored_repositories/github_api/lib | mirrored_repositories/github_api/lib/screens/splashscreen.dart | import 'dart:async';
import 'package:flutter/material.dart';
import 'package:github_api/screens/homepage.dart';
import 'package:rive/rive.dart';
class SplashScreen extends StatelessWidget {
const SplashScreen({Key? key}) : super(key: key);
static String id = "SplashScreen";
@override
Widget build(BuildContext context) {
Timer(const Duration(seconds: 6), () {
Navigator.pushReplacement(
context, MaterialPageRoute(builder: (_) => const HomePage()));
});
return const Scaffold(
backgroundColor: Color(0xff0D1117),
body: Center(
child: RiveAnimation.asset("assets/github-logo.riv"),
widthFactor: 1.5,
),
);
}
}
| 0 |
mirrored_repositories/github_api/lib | mirrored_repositories/github_api/lib/screens/repospage.dart | import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:get_storage/get_storage.dart';
import 'package:timeline_tile/timeline_tile.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:github_api/models/repo.dart';
class ReposPage extends StatefulWidget {
const ReposPage({Key? key}) : super(key: key);
static String id = "ReposPage";
@override
State<ReposPage> createState() => _ReposPageState();
}
class _ReposPageState extends State<ReposPage> {
@override
void initState() {
final storage = GetStorage();
final username = storage.read("username");
getData(username);
}
bool loading = true;
bool error = false;
List<Repo> repo = [];
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color(0xff0D1117),
appBar: AppBar(
foregroundColor: Colors.white,
backgroundColor: Colors.transparent,
elevation: 0,
title: const Text(
"GitGram",
),
centerTitle: true,
),
body: Column(
children: [
Expanded(
child: loading
? const Center(
child: CircularProgressIndicator(),
)
: error
? const Center(
child: Text('An error has occurred!'),
)
: ListView.builder(
itemCount: repo.length,
itemBuilder: (context, index) => TimelineTile(
isFirst: index == 0 ? true : false,
isLast: index == repo.length - 1 ? true : false,
indicatorStyle:
const IndicatorStyle(color: Colors.greenAccent),
afterLineStyle: const LineStyle(
color: Color.fromARGB(255, 56, 158, 109),
),
beforeLineStyle: const LineStyle(
color: Color.fromARGB(255, 56, 158, 109),
),
endChild: Stack(
children: [
Column(
children: [
SizedBox(
width: double.infinity,
child: Card(
elevation: 8,
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(32)),
child: Padding(
padding: const EdgeInsets.all(20.0),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.center,
children: [
const SizedBox(
height: 10,
),
Text(
repo[index].name.toUpperCase(),
maxLines: 1,
softWrap: false,
style: const TextStyle(
fontSize: 20,
color: Color(0xFF414C6B),
fontWeight: FontWeight.w600,
),
textAlign: TextAlign.left,
),
const SizedBox(
height: 20,
),
Text(
"repo ID ${repo[index].id}",
style: const TextStyle(
fontSize: 12,
color: Color(0xFF414C6B),
fontWeight: FontWeight.w500,
),
textAlign: TextAlign.left,
),
const SizedBox(
height: 20,
),
Text(
repo[index].description,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
fontSize: 15,
color: Color(0xFF414C6B),
fontWeight: FontWeight.w500,
),
textAlign: TextAlign.center,
),
const SizedBox(
height: 20,
),
InkWell(
onTap: () => _launchURL(
repo[index].svnUrl),
child: Text(
repo[index].svnUrl,
style: const TextStyle(
fontSize: 15,
color: Color(0xFF414C6B),
fontWeight: FontWeight.w500,
),
textAlign: TextAlign.center,
),
),
],
),
),
),
),
const SizedBox(
height: 20,
),
],
),
],
),
),
),
),
],
),
);
}
Future<void> getData(username) async {
try {
final dio = Dio();
var response =
await dio.get("https://api.github.com/users/" + username + "/repos");
if (response.statusCode.toString().startsWith('2')) {
setState(() {
loading = false;
repo = (response.data as List)
.map((data) => Repo.fromMap(data))
.toList();
});
}
} catch (e) {
setState(() {
error = true;
});
} finally {
setState(() {
loading = false;
});
}
}
_launchURL(url) async {
Uri newurl = Uri.parse(url);
if (await canLaunchUrl(newurl)) {
await launchUrl(newurl);
} else {
throw 'Could not launch $url';
}
}
}
| 0 |
mirrored_repositories/github_api | mirrored_repositories/github_api/test/widget_test.dart | // This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility that Flutter provides. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:github_api/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(const MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}
| 0 |
mirrored_repositories/flutter_example | mirrored_repositories/flutter_example/lib/main.dart | import 'package:flutter/material.dart';
import 'package:english_words/english_words.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: "Welcome flutter",
theme: ThemeData(
primarySwatch: Colors.blue,
primaryColor: Colors.white,
),
home: RandomWords());
}
}
class RandomWords extends StatefulWidget {
@override
RandomWordState createState() => new RandomWordState();
}
class RandomWordState extends State<RandomWords> with TickerProviderStateMixin {
final _suggestions = <WordPair>[];
final _saved = Set<WordPair>();
final _biggerFont = const TextStyle(fontSize: 18.0);
AnimationController controller;
CurvedAnimation curve;
@override
void initState() {
controller = AnimationController(duration: const Duration(milliseconds: 1500), vsync: this);
curve = CurvedAnimation(parent: controller, curve: Curves.easeIn);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Startup Name Generator'),
actions: <Widget>[
IconButton(icon: const Icon(Icons.list), onPressed: _goToFavList),
],
),
body: _buildListSuggestion(),
);
}
// Generate Suggestion list lazily with infinity elements
Widget _buildListSuggestion() {
controller.forward();
return ListView.builder(
padding: const EdgeInsets.all(16.0),
itemBuilder: (context, i) {
if (i.isOdd) return Divider();
final index = i ~/ 2;
if (index >= _suggestions.length) {
_suggestions.addAll(generateWordPairs().take(10));
}
return _buildRow(_suggestions[index]);
});
}
Widget _buildRow(WordPair pair) {
final alreadySaved = _saved.contains(pair);
return ListTile(
title: Text(
pair.asPascalCase,
style: _biggerFont,
),
trailing: Container(
child: FadeTransition(
opacity: curve,
child: Icon(alreadySaved ? Icons.favorite : Icons.favorite_border,
color: alreadySaved ? Colors.red : null))),
onTap: () {
setState(() {
if (alreadySaved) {
_saved.remove(pair);
} else {
_saved.add(pair);
}
});
});
}
void _goToFavList() {
Navigator.of(context).push(MaterialPageRoute(builder: (BuildContext context) {
final Iterable<ListTile> tiles = _saved.map((WordPair pair) {
return ListTile(
title: Text(
pair.asPascalCase,
style: _biggerFont,
),
onTap: _showDetailView,
);
});
final List<Widget> divided = ListTile.divideTiles(
context: context,
tiles: tiles,
).toList();
return Scaffold(
appBar: AppBar(
title: const Text('Favorites list'),
),
body: ListView(
children: divided,
),
);
}));
}
void _showDetailView() {
Navigator.of(context).push(MaterialPageRoute(builder: (BuildContext context) {
// Title section
Widget titleSection = Container(
padding: const EdgeInsets.all(32.0),
child: Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
padding: const EdgeInsets.only(bottom: 8.0),
child: Text(
'Oeschinen Lake Campground',
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
),
Text(
'Kandersteg, Switzerland',
style: TextStyle(
color: Colors.grey[500],
),
),
],
),
),
Icon(
Icons.star,
color: Colors.red[500],
),
Text('4.7'),
],
),
);
// end section
// Button section
Column buildButtonColumn(IconData icon, String label) {
Color color = Theme
.of(context)
.primaryColor;
return Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(icon, color: color),
Container(
margin: const EdgeInsets.only(top: 8.0),
child: Text(
label,
style: TextStyle(
fontSize: 12.0,
fontWeight: FontWeight.w400,
color: color,
),
),
),
],
);
}
// end section
Widget buttonSection = Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
buildButtonColumn(Icons.call, 'CALL'),
buildButtonColumn(Icons.near_me, 'ROUTE'),
buildButtonColumn(Icons.share, 'SHARE'),
],
),
);
Widget textSection = Container(
padding: const EdgeInsets.all(22.0),
child: Text(
'''
Lake Oeschinen lies at the foot of the Blüemlisalp in the Bernese Alps.\n
Situated 1,578 meters above sea level, it is one of the larger Alpine Lakes...
''',
softWrap: true,
),
);
return Scaffold(
appBar: AppBar(
title: const Text('Favorites list'),
),
body: ListView(
children: [
Image.asset(
'images/castle.png',
width: 600.0,
height: 240.0,
fit: BoxFit.cover,
),
titleSection,
buttonSection,
textSection,
],
),
);
}));
}
} | 0 |
mirrored_repositories/flutter_example | mirrored_repositories/flutter_example/test/widget_test.dart | // This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility that Flutter provides. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:startup_namer/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}
| 0 |
mirrored_repositories/Clima-Weather-App | mirrored_repositories/Clima-Weather-App/lib/main.dart | import 'package:flutter/material.dart';
import 'package:clima/screens/loading_screen.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData.dark(),
home: LoadingScreen(),
);
}
}
| 0 |
mirrored_repositories/Clima-Weather-App/lib | mirrored_repositories/Clima-Weather-App/lib/utilities/constants.dart | import 'package:flutter/material.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
const kTempTextStyle = TextStyle(
fontFamily: 'Spartan MB',
fontSize: 100.0,
);
const kMessageTextStyle = TextStyle(
fontFamily: 'Spartan MB',
fontSize: 60.0,
);
const kButtonTextStyle = TextStyle(
fontSize: 30.0,
fontFamily: 'Spartan MB',
color: Colors.white,
);
const kConditionTextStyle = TextStyle(
fontSize: 80.0,
);
const spinkit = SpinKitRotatingCircle(
color: Colors.white,
size: 50.0,
);
const kTextFieldInputDecoration = InputDecoration(
filled: true,
icon: Icon(Icons.location_city),
hintText: 'enter city name',
hintStyle: TextStyle(color: Colors.white70),
);
| 0 |
mirrored_repositories/Clima-Weather-App/lib | mirrored_repositories/Clima-Weather-App/lib/services/networking.dart | import 'package:http/http.dart' as http;
import 'dart:convert';
import 'package:clima/screens/loading_screen.dart';
class NetworkHelper {
NetworkHelper(this.url);
final String url;
Future getData() async {
var URL = Uri.parse(url);
http.Response response = await http.get(URL);
print(response.statusCode);
if (response.statusCode == 200) {
String data = response.body;
// print(data);
return jsonDecode(data);
} else {
print(response.statusCode);
}
}
}
| 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.