repo_id
stringlengths 21
168
| file_path
stringlengths 36
210
| content
stringlengths 1
9.98M
| __index_level_0__
int64 0
0
|
|---|---|---|---|
mirrored_repositories/flutter_grocery_app/lib/app/modules/calendar
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/calendar/views/calendar_view.dart
|
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../../components/no_data.dart';
import '../controllers/calendar_controller.dart';
class CalendarView extends GetView<CalendarController> {
const CalendarView({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Calendar', style: context.theme.textTheme.headline3),
centerTitle: true,
),
body: const NoData(text: 'This is Calendar Screen'),
);
}
}
| 0
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/calendar
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/calendar/controllers/calendar_controller.dart
|
import 'package:get/get.dart';
class CalendarController extends GetxController {}
| 0
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/calendar
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/calendar/bindings/calendar_binding.dart
|
import 'package:get/get.dart';
import '../controllers/calendar_controller.dart';
class CalendarBinding extends Bindings {
@override
void dependencies() {
Get.lazyPut<CalendarController>(
() => CalendarController(),
);
}
}
| 0
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/category
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/category/views/category_view.dart
|
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../../components/no_data.dart';
import '../controllers/category_controller.dart';
class CategoryView extends GetView<CategoryController> {
const CategoryView({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Category', style: context.theme.textTheme.headline3),
centerTitle: true,
),
body: const NoData(text: 'This is Category Screen'),
);
}
}
| 0
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/category
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/category/controllers/category_controller.dart
|
import 'package:get/get.dart';
class CategoryController extends GetxController {}
| 0
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/category
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/category/bindings/category_binding.dart
|
import 'package:get/get.dart';
import '../controllers/category_controller.dart';
class CategoryBinding extends Bindings {
@override
void dependencies() {
Get.lazyPut<CategoryController>(
() => CategoryController(),
);
}
}
| 0
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/profile
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/profile/views/profile_view.dart
|
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../../components/no_data.dart';
import '../controllers/profile_controller.dart';
class ProfileView extends GetView<ProfileController> {
const ProfileView({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Profile', style: context.theme.textTheme.headline3),
centerTitle: true,
),
body: const NoData(text: 'This is Profile Screen'),
);
}
}
| 0
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/profile
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/profile/controllers/profile_controller.dart
|
import 'package:get/get.dart';
class ProfileController extends GetxController {}
| 0
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/profile
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/profile/bindings/profile_binding.dart
|
import 'package:get/get.dart';
import '../controllers/profile_controller.dart';
class ProfileBinding extends Bindings {
@override
void dependencies() {
Get.lazyPut<ProfileController>(
() => ProfileController(),
);
}
}
| 0
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/product_details
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/product_details/views/product_details_view.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_animate/flutter_animate.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:get/get.dart';
import '../../../../utils/constants.dart';
import '../../../../utils/dummy_helper.dart';
import '../../../components/custom_button.dart';
import '../../../components/custom_card.dart';
import '../../../components/custom_icon_button.dart';
import '../../../components/product_count_item.dart';
import '../controllers/product_details_controller.dart';
class ProductDetailsView extends GetView<ProductDetailsController> {
const ProductDetailsView({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
final theme = context.theme;
return Scaffold(
body: SafeArea(
child: ListView(
children: [
SizedBox(
height: 330.h,
child: Stack(
children: [
Positioned.fill(
child: SvgPicture.asset(
Constants.container,
fit: BoxFit.fill,
color: theme.cardColor,
),
),
Positioned(
top: 24.h,
left: 24.w,
right: 24.w,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
CustomIconButton(
onPressed: () => Get.back(),
icon: SvgPicture.asset(
Constants.backArrowIcon,
fit: BoxFit.none,
color: theme.appBarTheme.iconTheme?.color,
),
),
CustomIconButton(
onPressed: () {},
icon: SvgPicture.asset(
Constants.searchIcon,
fit: BoxFit.none,
color: theme.appBarTheme.iconTheme?.color,
),
),
],
),
),
Positioned(
top: 80.h,
left: 0,
right: 0,
child: Image.asset(
controller.product.image,
width: 250.w,
height: 225.h,
).animate().fade().scale(
duration: 800.ms,
curve: Curves.fastOutSlowIn,
),
),
],
),
),
30.verticalSpace,
Padding(
padding: EdgeInsets.symmetric(horizontal: 24.w),
child: Row(
children: [
Text(
controller.product.name,
style: theme.textTheme.headline2,
).animate().fade().slideX(
duration: 300.ms,
begin: -1,
curve: Curves.easeInSine,
),
const Spacer(),
ProductCountItem(product: controller.product).animate().fade(
duration: 200.ms
),
],
),
),
8.verticalSpace,
Padding(
padding: EdgeInsets.symmetric(horizontal: 24.w),
child: Text(
'1kg, ${controller.product.price}\$',
style: theme.textTheme.headline3?.copyWith(
color: theme.accentColor,
),
).animate().fade().slideX(
duration: 300.ms,
begin: -1,
curve: Curves.easeInSine,
),
),
8.verticalSpace,
Padding(
padding: EdgeInsets.symmetric(horizontal: 24.w),
child: Text(
controller.product.description,
style: theme.textTheme.bodyText1,
).animate().fade().slideX(
duration: 300.ms,
begin: -1,
curve: Curves.easeInSine,
),
),
20.verticalSpace,
Padding(
padding: EdgeInsets.symmetric(horizontal: 24.w),
child: GridView(
shrinkWrap: true,
primary: false,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
crossAxisSpacing: 16.w,
mainAxisSpacing: 16.h,
mainAxisExtent: 80.h,
),
children: DummyHelper.cards.map((card) => CustomCard(
title: card['title']!,
subtitle: card['subtitle']!,
icon: card['icon']!,
)).toList().animate().fade().slideY(
duration: 300.ms,
begin: 1,
curve: Curves.easeInSine,
),
),
),
30.verticalSpace,
Padding(
padding: EdgeInsets.symmetric(horizontal: 24.w),
child: CustomButton(
text: 'Add to cart',
onPressed: () => controller.onAddToCartPressed(),
fontSize: 16.sp,
radius: 50.r,
verticalPadding: 16.h,
hasShadow: false,
).animate().fade().slideY(
duration: 300.ms,
begin: 1,
curve: Curves.easeInSine,
),
),
30.verticalSpace,
],
),
),
);
}
}
| 0
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/product_details
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/product_details/controllers/product_details_controller.dart
|
import 'package:get/get.dart';
import '../../../data/models/product_model.dart';
import '../../base/controllers/base_controller.dart';
class ProductDetailsController extends GetxController {
// get product details from arguments
ProductModel product = Get.arguments;
/// when the user press on add to cart button
onAddToCartPressed() {
if (product.quantity == 0) {
Get.find<BaseController>().onIncreasePressed(product.id);
}
Get.back();
}
}
| 0
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/product_details
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/product_details/bindings/product_details_binding.dart
|
import 'package:get/get.dart';
import '../controllers/product_details_controller.dart';
class ProductDetailsBinding extends Bindings {
@override
void dependencies() {
Get.lazyPut<ProductDetailsController>(
() => ProductDetailsController(),
);
}
}
| 0
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/home
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/home/views/home_view.dart
|
import 'package:flutter/material.dart';
import 'package:carousel_slider/carousel_slider.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:get/get.dart';
import '../../../../utils/constants.dart';
import '../../../components/category_item.dart';
import '../../../components/custom_form_field.dart';
import '../../../components/custom_icon_button.dart';
import '../../../components/dark_transition.dart';
import '../../../components/product_item.dart';
import '../controllers/home_controller.dart';
class HomeView extends GetView<HomeController> {
const HomeView({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
final theme = context.theme;
return DarkTransition(
offset: Offset(context.width, -1),
isDark: !controller.isLightTheme,
builder: (context, _) => Scaffold(
body: Stack(
children: [
Positioned(
top: -100.h,
child: SvgPicture.asset(
Constants.container,
fit: BoxFit.fill,
color: theme.canvasColor,
),
),
ListView(
children: [
Column(
children: [
ListTile(
contentPadding: EdgeInsets.symmetric(horizontal: 24.w),
title: Text(
'Good morning',
style: theme.textTheme.bodyText2?.copyWith(
fontSize: 12.sp
),
),
subtitle: Text(
'Amelia Barlow',
style: theme.textTheme.headline5?.copyWith(
fontWeight: FontWeight.normal,
),
),
leading: CircleAvatar(
radius: 22.r,
backgroundColor: theme.primaryColorDark,
child: ClipOval(
child: Align(
alignment: Alignment.bottomCenter,
child: Image.asset(Constants.avatar),
),
),
),
trailing: CustomIconButton(
onPressed: () => controller.onChangeThemePressed(),
backgroundColor: theme.primaryColorDark,
icon: GetBuilder<HomeController>(
id: 'Theme',
builder: (_) => Icon(
controller.isLightTheme
? Icons.dark_mode_outlined
: Icons.light_mode_outlined,
color: theme.appBarTheme.iconTheme?.color,
size: 20,
),
),
),
),
10.verticalSpace,
Padding(
padding: EdgeInsets.symmetric(horizontal: 24.w),
child: CustomFormField(
backgroundColor: theme.primaryColorDark,
textSize: 14.sp,
hint: 'Search category',
hintFontSize: 14.sp,
hintColor: theme.hintColor,
maxLines: 1,
borderRound: 60.r,
contentPadding: EdgeInsets.symmetric(
vertical: 10.h,
horizontal: 10.w
),
focusedBorderColor: Colors.transparent,
isSearchField: true,
keyboardType: TextInputType.text,
textInputAction: TextInputAction.search,
prefixIcon: SvgPicture.asset(
Constants.searchIcon,
fit: BoxFit.none
),
),
),
20.verticalSpace,
SizedBox(
width: double.infinity,
height: 158.h,
child: CarouselSlider.builder(
options: CarouselOptions(
initialPage: 1,
viewportFraction: 0.9,
enableInfiniteScroll: true,
autoPlay: true,
autoPlayInterval: const Duration(seconds: 3),
),
itemCount: controller.cards.length,
itemBuilder: (context, itemIndex, pageViewIndex) {
return Image.asset(controller.cards[itemIndex]);
},
),
),
],
),
Padding(
padding: EdgeInsets.symmetric(horizontal: 24.w),
child: Column(
children: [
20.verticalSpace,
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'Categories 😋',
style: theme.textTheme.headline4,
),
Text(
'See all',
style: theme.textTheme.headline6?.copyWith(
color: theme.primaryColor,
fontWeight: FontWeight.normal,
),
),
],
),
16.verticalSpace,
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: controller.categories.map((category) {
return CategoryItem(category: category);
}).toList(),
),
20.verticalSpace,
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'Best selling 🔥',
style: theme.textTheme.headline4,
),
Text(
'See all',
style: theme.textTheme.headline6?.copyWith(
color: theme.primaryColor,
fontWeight: FontWeight.normal,
),
),
],
),
16.verticalSpace,
GridView.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
crossAxisSpacing: 16.w,
mainAxisSpacing: 16.h,
mainAxisExtent: 214.h,
),
shrinkWrap: true,
primary: false,
itemCount: 2,
itemBuilder: (context, index) => ProductItem(
product: controller.products[index],
),
),
20.verticalSpace,
],
),
),
],
),
],
),
),
);
}
}
| 0
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/home
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/home/controllers/home_controller.dart
|
import 'package:get/get.dart';
import '../../../../config/theme/my_theme.dart';
import '../../../../utils/constants.dart';
import '../../../../utils/dummy_helper.dart';
import '../../../data/local/my_shared_pref.dart';
import '../../../data/models/category_model.dart';
import '../../../data/models/product_model.dart';
class HomeController extends GetxController {
// to hold categories & products
List<CategoryModel> categories = [];
List<ProductModel> products = [];
// for app theme
var isLightTheme = MySharedPref.getThemeIsLight();
// for home screen cards
var cards = [Constants.card1, Constants.card2, Constants.card3];
@override
void onInit() {
getCategories();
getProducts();
super.onInit();
}
/// get categories from dummy helper
getCategories() {
categories = DummyHelper.categories;
}
/// get products from dummy helper
getProducts() {
products = DummyHelper.products;
}
/// when the user press on change theme icon
onChangeThemePressed() {
MyTheme.changeTheme();
isLightTheme = MySharedPref.getThemeIsLight();
update(['Theme']);
}
}
| 0
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/home
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/home/bindings/home_binding.dart
|
import 'package:get/get.dart';
import '../controllers/home_controller.dart';
class HomeBinding extends Bindings {
@override
void dependencies() {
Get.lazyPut<HomeController>(
() => HomeController(),
);
}
}
| 0
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/splash
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/splash/views/splash_view.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_animate/flutter_animate.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import '../../../../utils/constants.dart';
import '../controllers/splash_controller.dart';
class SplashView extends GetView<SplashController> {
const SplashView({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
Get.put(SplashController());
var theme = context.theme;
return Scaffold(
backgroundColor: theme.primaryColorLight,
body: Center(
child: CircleAvatar(
radius: 55.r,
backgroundColor: theme.primaryColorDark,
child: Image.asset(Constants.logo, width: 67.w, height: 55.h),
).animate().fade().slideY(
duration: 500.ms,
begin: 1, curve: Curves.easeInSine
),
),
);
}
}
| 0
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/splash
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/splash/controllers/splash_controller.dart
|
import 'package:get/get.dart';
import '../../../routes/app_pages.dart';
class SplashController extends GetxController {
@override
void onInit() async {
await Future.delayed(const Duration(seconds: 2));
Get.offNamed(Routes.WELCOME);
super.onInit();
}
}
| 0
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/splash
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/splash/bindings/splash_binding.dart
|
import 'package:get/get.dart';
import '../controllers/splash_controller.dart';
class SplashBinding extends Bindings {
@override
void dependencies() {
Get.lazyPut<SplashController>(
() => SplashController(),
);
}
}
| 0
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/base
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/base/views/base_view.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:badges/badges.dart';
import 'package:get/get.dart';
import '../../../../utils/constants.dart';
import '../../../routes/app_pages.dart';
import '../../calendar/views/calendar_view.dart';
import '../../category/views/category_view.dart';
import '../../profile/views/profile_view.dart';
import '../controllers/base_controller.dart';
import '../../home/views/home_view.dart';
class BaseView extends GetView<BaseController> {
const BaseView({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
var theme = context.theme;
return GetBuilder<BaseController>(
builder: (_) => Scaffold(
resizeToAvoidBottomInset: false,
body: SafeArea(
bottom: false,
child: IndexedStack(
index: controller.currentIndex,
children: const [
HomeView(),
CategoryView(),
Center(),
CalendarView(),
ProfileView()
],
),
),
bottomNavigationBar: BottomNavigationBar(
currentIndex: controller.currentIndex,
type: BottomNavigationBarType.fixed,
elevation: 0.0,
backgroundColor: Colors.transparent,
showSelectedLabels: false,
showUnselectedLabels: false,
selectedFontSize: 0.0,
items: [
_mBottomNavItem(
label: 'Home',
icon: Constants.homeIcon,
),
_mBottomNavItem(
label: 'category',
icon: Constants.categoryIcon,
),
const BottomNavigationBarItem(
label: '',
icon: Center(),
),
_mBottomNavItem(
label: 'Calendar',
icon: Constants.calendarIcon,
),
_mBottomNavItem(
label: 'Profile',
icon: Constants.userIcon,
),
],
onTap: controller.changeScreen,
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
floatingActionButton: FloatingActionButton(
elevation: 0.0,
backgroundColor: Colors.transparent,
onPressed:() => Get.toNamed(Routes.CART),
child: GetBuilder<BaseController>(
id: 'CartBadge',
builder: (_) => Badge(
position: BadgePosition.bottomEnd(bottom: -16, end: 13),
badgeContent: Text(
controller.cartItemsCount.toString(),
style: theme.textTheme.bodyText2?.copyWith(
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
badgeStyle: BadgeStyle(
elevation: 2,
badgeColor: theme.accentColor,
borderSide: const BorderSide(color: Colors.white, width: 1),
),
child: CircleAvatar(
radius: 22.r,
backgroundColor: theme.primaryColor,
child: SvgPicture.asset(
Constants.cartIcon, fit: BoxFit.none,
),
),
),
),
),
),
);
}
_mBottomNavItem({required String label, required String icon}) {
return BottomNavigationBarItem(
label: label,
icon: SvgPicture.asset(icon, color: Get.theme.iconTheme.color),
activeIcon: SvgPicture.asset(icon, color: Get.theme.appBarTheme.iconTheme?.color),
);
}
}
| 0
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/base
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/base/controllers/base_controller.dart
|
import 'package:get/get.dart';
import '../../../../utils/dummy_helper.dart';
import '../../cart/controllers/cart_controller.dart';
class BaseController extends GetxController {
// current screen index
int currentIndex = 0;
// to count the number of products in the cart
int cartItemsCount = 0;
@override
void onInit() {
getCartItemsCount();
super.onInit();
}
/// change the selected screen index
changeScreen(int selectedIndex) {
currentIndex = selectedIndex;
update();
}
/// calculate the number of products in the cart
getCartItemsCount() {
var products = DummyHelper.products;
cartItemsCount = products.fold<int>(0, (p, c) => p + c.quantity);
update(['CartBadge']);
}
/// when the user press on add + icon
onIncreasePressed(int productId) {
DummyHelper.products.firstWhere((p) => p.id == productId).quantity++;
getCartItemsCount();
update(['ProductQuantity']);
}
/// when the user press on remove - icon
onDecreasePressed(int productId) {
var product = DummyHelper.products.firstWhere((p) => p.id == productId);
if (product.quantity > 0) {
product.quantity--;
getCartItemsCount();
if (Get.isRegistered<CartController>()) {
Get.find<CartController>().getCartProducts();
}
update(['ProductQuantity']);
}
}
}
| 0
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/base
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/base/bindings/base_binding.dart
|
import 'package:get/get.dart';
import '../../calendar/controllers/calendar_controller.dart';
import '../../category/controllers/category_controller.dart';
import '../../home/controllers/home_controller.dart';
import '../../profile/controllers/profile_controller.dart';
import '../controllers/base_controller.dart';
class BaseBinding extends Bindings {
@override
void dependencies() {
Get.lazyPut<BaseController>(() => BaseController());
Get.lazyPut<HomeController>(() => HomeController());
Get.lazyPut<CategoryController>(() => CategoryController());
Get.lazyPut<CalendarController>(() => CalendarController());
Get.lazyPut<ProfileController>(() => ProfileController());
}
}
| 0
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/products
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/products/views/products_view.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:get/get.dart';
import '../../../../utils/constants.dart';
import '../../../components/custom_icon_button.dart';
import '../../../components/product_item.dart';
import '../controllers/products_controller.dart';
class ProductsView extends GetView<ProductsController> {
const ProductsView({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
final theme = context.theme;
return Scaffold(
appBar: AppBar(
automaticallyImplyLeading: false,
title: Padding(
padding: EdgeInsets.symmetric(horizontal: 8.w),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
CustomIconButton(
onPressed: () => Get.back(),
backgroundColor: theme.scaffoldBackgroundColor,
borderColor: theme.dividerColor,
icon: SvgPicture.asset(
Constants.backArrowIcon,
fit: BoxFit.none,
color: theme.appBarTheme.iconTheme?.color,
),
),
Text(
'Vegetables 🌽',
style: theme.textTheme.headline3,
),
CustomIconButton(
onPressed: () {},
backgroundColor: theme.scaffoldBackgroundColor,
borderColor: theme.dividerColor,
icon: SvgPicture.asset(
Constants.searchIcon,
fit: BoxFit.none,
color: theme.appBarTheme.iconTheme?.color,
),
),
],
),
),
),
body: Padding(
padding: EdgeInsets.fromLTRB(24.w, 24.h, 24.w, 0),
child: GridView.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
crossAxisSpacing: 16.w,
mainAxisSpacing: 16.h,
mainAxisExtent: 214.h,
),
shrinkWrap: true,
primary: false,
itemCount: controller.products.length,
itemBuilder: (context, index) => ProductItem(
product: controller.products[index],
),
),
),
);
}
}
| 0
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/products
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/products/controllers/products_controller.dart
|
import 'package:get/get.dart';
import '../../../../utils/dummy_helper.dart';
import '../../../data/models/product_model.dart';
class ProductsController extends GetxController {
// to hold the products
List<ProductModel> products = [];
@override
void onInit() {
getProducts();
super.onInit();
}
/// get products from dummy helper
getProducts() {
products.addAll(DummyHelper.products);
products.removeWhere((p) => p.id == 2);
}
}
| 0
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/products
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/products/bindings/products_binding.dart
|
import 'package:get/get.dart';
import '../controllers/products_controller.dart';
class ProductsBinding extends Bindings {
@override
void dependencies() {
Get.lazyPut<ProductsController>(
() => ProductsController(),
);
}
}
| 0
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/welcome
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/welcome/views/welcome_view.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_animate/flutter_animate.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import '../../../../utils/constants.dart';
import '../../../components/custom_button.dart';
import '../../../data/local/my_shared_pref.dart';
import '../../../routes/app_pages.dart';
import '../controllers/welcome_controller.dart';
class WelcomeView extends GetView<WelcomeController> {
const WelcomeView({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
final isLightTheme = MySharedPref.getThemeIsLight();
final theme = context.theme;
return Scaffold(
body: Stack(
children: [
Positioned.fill(
child: Image.asset(
isLightTheme ? Constants.background : Constants.backgroundDark,
fit: BoxFit.fill,
),
),
Padding(
padding: EdgeInsets.symmetric(horizontal: 30.w),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
95.verticalSpace,
CircleAvatar(
radius: 33.r,
backgroundColor: theme.primaryColorDark,
child: Image.asset(
Constants.logo,
width: 40.33.w, height: 33.40.h,
),
).animate().fade().slideY(
duration: 300.ms,
begin: -1,
curve: Curves.easeInSine,
),
30.verticalSpace,
Text(
'Get your groceries delivered to your home',
style: theme.textTheme.headline1,
textAlign: TextAlign.center,
).animate().fade().slideY(
duration: 300.ms,
begin: -1,
curve: Curves.easeInSine,
),
24.verticalSpace,
Text(
'The best delivery app in town for delivering your daily fresh groceries',
style: theme.textTheme.bodyText1,
textAlign: TextAlign.center,
).animate().fade().slideY(
duration: 300.ms,
begin: 1,
curve: Curves.easeInSine,
),
40.verticalSpace,
Padding(
padding: EdgeInsets.symmetric(horizontal: 70.w),
child: CustomButton(
text: 'Shop now',
onPressed: () => Get.offNamed(Routes.BASE),
fontSize: 16.sp,
radius: 50.r,
verticalPadding: 16.h,
hasShadow: false,
).animate().fade().slideY(
duration: 300.ms,
begin: 1,
curve: Curves.easeInSine,
),
),
],
),
),
],
),
);
}
}
| 0
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/welcome
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/welcome/controllers/welcome_controller.dart
|
import 'package:get/get.dart';
class WelcomeController extends GetxController {}
| 0
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/welcome
|
mirrored_repositories/flutter_grocery_app/lib/app/modules/welcome/bindings/welcome_binding.dart
|
import 'package:get/get.dart';
import '../controllers/welcome_controller.dart';
class WelcomeBinding extends Bindings {
@override
void dependencies() {
Get.lazyPut<WelcomeController>(
() => WelcomeController(),
);
}
}
| 0
|
mirrored_repositories/flutter_grocery_app/lib/app/data
|
mirrored_repositories/flutter_grocery_app/lib/app/data/models/product_model.dart
|
class ProductModel {
int id;
String image;
String name;
String description;
int quantity;
double price;
ProductModel({
required this.id,
required this.image,
required this.name,
required this.quantity,
required this.price,
required this.description
});
}
| 0
|
mirrored_repositories/flutter_grocery_app/lib/app/data
|
mirrored_repositories/flutter_grocery_app/lib/app/data/models/category_model.dart
|
class CategoryModel {
int id;
String title;
String image;
CategoryModel({
required this.id,
required this.title,
required this.image,
});
}
| 0
|
mirrored_repositories/flutter_grocery_app/lib/app/data
|
mirrored_repositories/flutter_grocery_app/lib/app/data/local/my_shared_pref.dart
|
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../../../config/translations/localization_service.dart';
class MySharedPref {
// prevent making instance
MySharedPref._();
// get storage
static late SharedPreferences _sharedPreferences;
// STORING KEYS
static const String _fcmTokenKey = 'fcm_token';
static const String _currentLocalKey = 'current_local';
static const String _lightThemeKey = 'is_theme_light';
/// init get storage services
static Future<void> init() async {
_sharedPreferences = await SharedPreferences.getInstance();
}
static setStorage(SharedPreferences sharedPreferences) {
_sharedPreferences = sharedPreferences;
}
/// set theme current type as light theme
static Future<void> setThemeIsLight(bool lightTheme) =>
_sharedPreferences.setBool(_lightThemeKey, lightTheme);
/// get if the current theme type is light
static bool getThemeIsLight() =>
_sharedPreferences.getBool(_lightThemeKey) ?? true; // todo set the default theme (true for light, false for dark)
/// save current locale
static Future<void> setCurrentLanguage(String languageCode) =>
_sharedPreferences.setString(_currentLocalKey, languageCode);
/// get current locale
static Locale getCurrentLocal(){
String? langCode = _sharedPreferences.getString(_currentLocalKey);
// default language is english
if(langCode == null){
return LocalizationService.defaultLanguage;
}
return LocalizationService.supportedLanguages[langCode]!;
}
/// save generated fcm token
static Future<void> setFcmToken(String token) =>
_sharedPreferences.setString(_fcmTokenKey, token);
/// get generated fcm token
static String? getFcmToken() =>
_sharedPreferences.getString(_fcmTokenKey);
/// clear all data from shared pref
static Future<void> clear() async => await _sharedPreferences.clear();
}
| 0
|
mirrored_repositories/flutter_grocery_app/lib/config
|
mirrored_repositories/flutter_grocery_app/lib/config/translations/localization_service.dart
|
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../app/data/local/my_shared_pref.dart';
import 'ar_AR/ar_ar_translation.dart';
import 'en_US/en_us_translation.dart';
class LocalizationService extends Translations {
// prevent creating instance
LocalizationService._();
static LocalizationService? _instance;
static LocalizationService getInstance() {
_instance ??= LocalizationService._();
return _instance!;
}
// default language
// todo change the default language
static Locale defaultLanguage = supportedLanguages['en']!;
// supported languages
static Map<String,Locale> supportedLanguages = {
'en' : const Locale('en', 'US'),
'ar' : const Locale('ar', 'AR'),
};
// supported languages fonts family (must be in assets & pubspec yaml) or you can use google fonts
static Map<String,TextStyle> supportedLanguagesFontsFamilies = {
// todo add your English font families (add to assets/fonts, pubspec and name it here) default is poppins for english and cairo for arabic
'en' : const TextStyle(fontFamily: 'Poppins'),
'ar': const TextStyle(fontFamily: 'Cairo'),
};
@override
Map<String, Map<String, String>> get keys => {
'en_US': enUs,
'ar_AR': arAR,
};
/// check if the language is supported
static isLanguageSupported(String languageCode) =>
supportedLanguages.keys.contains(languageCode);
/// update app language by code language for example (en,ar..etc)
static updateLanguage(String languageCode) async {
// check if the language is supported
if(!isLanguageSupported(languageCode)) return;
// update current language in shared pref
await MySharedPref.setCurrentLanguage(languageCode);
if(!Get.testMode) {
Get.updateLocale(supportedLanguages[languageCode]!);
}
}
/// check if the language is english
static bool isItEnglish() =>
MySharedPref.getCurrentLocal().languageCode.toLowerCase().contains('en');
/// get current locale
static Locale getCurrentLocal () => MySharedPref.getCurrentLocal();
}
| 0
|
mirrored_repositories/flutter_grocery_app/lib/config
|
mirrored_repositories/flutter_grocery_app/lib/config/translations/strings_enum.dart
|
class Strings {
static const String hello = 'hello';
static const String loading = 'loading';
static const String changeTheme = 'change_theme';
static const String changeLanguage = 'change_language';
static const String noInternetConnection = 'no internet connection';
static const String serverNotResponding = 'server not responding';
static const String someThingWentWorng = 'something went wrong';
static const String apiNotFound = 'api not found';
static const String serverError = 'Server error';
static const String urlNotFound = 'Url not found';
}
| 0
|
mirrored_repositories/flutter_grocery_app/lib/config/translations
|
mirrored_repositories/flutter_grocery_app/lib/config/translations/en_US/en_us_translation.dart
|
import '../strings_enum.dart';
const Map<String, String> enUs = {
Strings.hello : 'Hello!',
Strings.loading : 'Loading',
Strings.changeTheme : 'Change theme',
Strings.changeLanguage : 'Change language',
Strings.noInternetConnection : 'No internet connection!',
Strings.serverNotResponding : 'Server is not responding!',
Strings.someThingWentWorng : 'Something went wrong',
Strings.apiNotFound : 'Route not found!',
Strings.serverError : 'Server error',
Strings.urlNotFound : 'Url not found',
};
| 0
|
mirrored_repositories/flutter_grocery_app/lib/config/translations
|
mirrored_repositories/flutter_grocery_app/lib/config/translations/ar_AR/ar_ar_translation.dart
|
import '../strings_enum.dart';
final Map<String, String> arAR =
{
Strings.hello : 'مرحباً!',
Strings.loading : 'جاري التحميل',
Strings.changeTheme : 'تغيير الثيم',
Strings.changeLanguage : 'تغيير اللغة',
Strings.noInternetConnection : 'لا يوجد إتصال بالإنترنت',
Strings.serverNotResponding : 'لا يوجد إستجابة من السيرفر!',
Strings.someThingWentWorng : 'حدث خطأ غير متوقع!',
Strings.apiNotFound : 'الرابط الذي تحاول الوصول اليه غير موجود!',
Strings.serverError : 'مشكلة من السيرفر',
Strings.urlNotFound : 'مشكلة في الرابط',
};
| 0
|
mirrored_repositories/flutter_grocery_app/lib/config
|
mirrored_repositories/flutter_grocery_app/lib/config/theme/my_theme.dart
|
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../app/data/local/my_shared_pref.dart';
import 'dark_theme_colors.dart';
import 'light_theme_colors.dart';
import 'my_styles.dart';
class MyTheme {
static getThemeData({required bool isLight}){
return ThemeData(
useMaterial3: true,
// main color (app bar,tabs..etc)
primaryColor: isLight ? LightThemeColors.primaryColor : DarkThemeColors.primaryColor,
primaryColorLight: isLight ? LightThemeColors.primaryColorLight : DarkThemeColors.primaryColorLight,
primaryColorDark: isLight ? LightThemeColors.primaryColorDark : DarkThemeColors.primaryColorDark,
// secondary color (for checkbox,float button, radio..etc)
accentColor: isLight ? LightThemeColors.accentColor : DarkThemeColors.accentColor,
// color contrast (if the theme is dark text should be white for example)
brightness: isLight ? Brightness.light : Brightness.dark,
// canvas Color
canvasColor: isLight ? LightThemeColors.canvasColor : DarkThemeColors.canvasColor,
// card widget background color
cardColor: isLight ? LightThemeColors.cardColor : DarkThemeColors.cardColor,
// hint text color
hintColor: isLight ? LightThemeColors.hintTextColor : DarkThemeColors.hintTextColor,
// divider color
dividerColor: isLight ? LightThemeColors.dividerColor : DarkThemeColors.dividerColor,
// app background color
backgroundColor: isLight ? LightThemeColors.backgroundColor : DarkThemeColors.backgroundColor,
scaffoldBackgroundColor: isLight ? LightThemeColors.scaffoldBackgroundColor : DarkThemeColors.scaffoldBackgroundColor,
// progress bar theme
progressIndicatorTheme: ProgressIndicatorThemeData(
color: isLight ? LightThemeColors.primaryColor : DarkThemeColors.primaryColor,
),
// appBar theme
appBarTheme: MyStyles.getAppBarTheme(isLightTheme: isLight),
// elevated button theme
elevatedButtonTheme: MyStyles.getElevatedButtonTheme(isLightTheme: isLight),
// text theme
textTheme: MyStyles.getTextTheme(isLightTheme: isLight),
// chip theme
chipTheme: MyStyles.getChipTheme(isLightTheme: isLight),
// icon theme
iconTheme: MyStyles.getIconTheme(isLightTheme: isLight),
);
}
/// update app theme and save theme type to shared pref
/// (so when the app is killed and up again theme will remain the same)
static changeTheme() {
// *) check if the current theme is light (default is light)
bool isLightTheme = MySharedPref.getThemeIsLight();
// *) store the new theme mode on get storage
MySharedPref.setThemeIsLight(!isLightTheme);
// *) let GetX change theme
Get.changeThemeMode(!isLightTheme ? ThemeMode.light : ThemeMode.dark);
}
/// check if the theme is light or dark
bool get getThemeIsLight => MySharedPref.getThemeIsLight();
}
| 0
|
mirrored_repositories/flutter_grocery_app/lib/config
|
mirrored_repositories/flutter_grocery_app/lib/config/theme/dark_theme_colors.dart
|
import 'package:flutter/material.dart';
class DarkThemeColors
{
//dark swatch
static const Color primaryColor = Color(0xFF40DF9F);
static const Color primaryColorLight = Color(0xFF0D1F29);
static const Color primaryColorDark = Color(0xFF1A3848);
static const Color accentColor = Color(0xFFFF324B);
static const Color canvasColor = Color(0xFF172C38);
//static const Color accentColor = Color(0xFFD9EDE1);
//Appbar
static const Color appbarColor = Colors.transparent;
//SCAFFOLD
static const Color scaffoldBackgroundColor = Color(0xFF0D1F29);
static const Color backgroundColor = Color(0xFF172C38);
static const Color dividerColor = Color(0xFF203744);
static const Color cardColor = Color(0xFF1A3848);
//ICONS
static const Color appBarIconsColor = Colors.white;
static const Color iconColor = Color(0xFF617986);
//static const Color iconColor = Color(0xFF96A7AF);
//BUTTON
static const Color buttonColor = primaryColor;
static const Color buttonTextColor = Colors.black;
static const Color buttonDisabledColor = Colors.grey;
static const Color buttonDisabledTextColor = Colors.black;
//TEXT
static const Color bodyTextColor = Color(0xFF617986);
static const Color headlinesTextColor = Colors.white;
static const Color captionTextColor = Colors.black;
static const Color hintTextColor = Color(0xFF617986);
//chip
static const Color chipBackground = primaryColor;
static const Color chipTextColor = Colors.black87;
// progress bar indicator
static const Color progressIndicatorColor = primaryColor;
}
| 0
|
mirrored_repositories/flutter_grocery_app/lib/config
|
mirrored_repositories/flutter_grocery_app/lib/config/theme/my_fonts.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import '../../app/data/local/my_shared_pref.dart';
import '../translations/localization_service.dart';
// todo configure text family and size
class MyFonts
{
// return the right font depending on app language
static TextStyle get getAppFontType => LocalizationService.supportedLanguagesFontsFamilies[MySharedPref.getCurrentLocal().languageCode]!;
// headlines text font
static TextStyle get headlineTextStyle => getAppFontType;
// body text font
static TextStyle get bodyTextStyle => getAppFontType;
// button text font
static TextStyle get buttonTextStyle => getAppFontType;
// app bar text font
static TextStyle get appBarTextStyle => getAppFontType;
// chips text font
static TextStyle get chipTextStyle => getAppFontType;
// appbar font size
static double get appBarTittleSize => 18.sp;
// body font size
static double get body1TextSize => 16.sp;
static double get body2TextSize => 14.sp;
// headlines font size
static double get headline1TextSize => 28.sp;
static double get headline2TextSize => 24.sp;
static double get headline3TextSize => 20.sp;
static double get headline4TextSize => 18.sp;
static double get headline5TextSize => 16.sp;
static double get headline6TextSize => 14.sp;
//button font size
static double get buttonTextSize => 16.sp;
//caption font size
static double get captionTextSize => 12.sp;
//chip font size
static double get chipTextSize => 10.sp;
}
| 0
|
mirrored_repositories/flutter_grocery_app/lib/config
|
mirrored_repositories/flutter_grocery_app/lib/config/theme/light_theme_colors.dart
|
import 'package:flutter/material.dart';
class LightThemeColors
{
//dark swatch
static const Color primaryColor = Color(0xFF23AA49);
static const Color primaryColorLight = Color(0xFF23AA49);
static const Color primaryColorDark = Colors.white;
static const Color accentColor = Color(0xFFFF324B);
static const Color canvasColor = Color(0xFFF3F5F7);
//static const Color accentColor = Color(0xFFD9EDE1);
//APPBAR
static const Color appBarColor = Colors.transparent;
//SCAFFOLD
static const Color scaffoldBackgroundColor = Colors.white;
static const Color backgroundColor = Colors.white;
static const Color dividerColor = Color(0xFFF1F1F5);
static const Color cardColor = Color(0xFFF3F5F7);
//ICONS
static const Color appBarIconsColor = Color(0xFF06161C);
static const Color iconColor = Color(0xFFDBDBDB);
//static const Color iconColor = Color(0xFF899A96);
//BUTTON
static const Color buttonColor = primaryColor;
static const Color buttonTextColor = Colors.white;
static const Color buttonDisabledColor = Colors.grey;
static const Color buttonDisabledTextColor = Colors.black;
//TEXT
static const Color bodyTextColor = Color(0xFF979899);
static const Color headlinesTextColor = Color(0xFF06161C);
static const Color captionTextColor = Colors.grey;
static const Color hintTextColor = Color(0xFF979899);
//chip
static const Color chipBackground = primaryColor;
static const Color chipTextColor = Colors.white;
// progress bar indicator
static const Color progressIndicatorColor = primaryColor;
}
| 0
|
mirrored_repositories/flutter_grocery_app/lib/config
|
mirrored_repositories/flutter_grocery_app/lib/config/theme/my_styles.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'dark_theme_colors.dart';
import 'my_fonts.dart';
import 'light_theme_colors.dart';
class MyStyles {
///icons theme
static IconThemeData getIconTheme({required bool isLightTheme}) =>
IconThemeData(
color: isLightTheme
? LightThemeColors.iconColor
: DarkThemeColors.iconColor,
);
///app bar theme
static AppBarTheme getAppBarTheme({required bool isLightTheme}) =>
AppBarTheme(
elevation: 0,
scrolledUnderElevation: 0,
titleTextStyle:
getTextTheme(isLightTheme: isLightTheme).bodyText1!.copyWith(
color: Colors.white,
fontSize: MyFonts.appBarTittleSize,
),
iconTheme: IconThemeData(
color: isLightTheme
? LightThemeColors.appBarIconsColor
: DarkThemeColors.appBarIconsColor),
backgroundColor: isLightTheme
? LightThemeColors.appBarColor
: DarkThemeColors.appbarColor,
);
///text theme
static TextTheme getTextTheme({required bool isLightTheme}) => TextTheme(
button: MyFonts.buttonTextStyle
.copyWith(fontSize: MyFonts.buttonTextSize),
bodyText1: (MyFonts.bodyTextStyle).copyWith(
fontWeight: FontWeight.bold,
fontSize: MyFonts.body1TextSize,
color: isLightTheme
? LightThemeColors.bodyTextColor
: DarkThemeColors.bodyTextColor),
bodyText2: (MyFonts.bodyTextStyle).copyWith(
fontSize: MyFonts.body2TextSize,
color: isLightTheme
? LightThemeColors.bodyTextColor
: DarkThemeColors.bodyTextColor),
headline1: (MyFonts.headlineTextStyle).copyWith(
fontSize: MyFonts.headline1TextSize,
fontWeight: FontWeight.bold,
color: isLightTheme
? LightThemeColors.headlinesTextColor
: DarkThemeColors.headlinesTextColor),
headline2: (MyFonts.headlineTextStyle).copyWith(
fontSize: MyFonts.headline2TextSize,
fontWeight: FontWeight.bold,
color: isLightTheme
? LightThemeColors.headlinesTextColor
: DarkThemeColors.headlinesTextColor),
headline3: (MyFonts.headlineTextStyle).copyWith(
fontSize: MyFonts.headline3TextSize,
fontWeight: FontWeight.bold,
color: isLightTheme
? LightThemeColors.headlinesTextColor
: DarkThemeColors.headlinesTextColor),
headline4: (MyFonts.headlineTextStyle).copyWith(
fontSize: MyFonts.headline4TextSize,
fontWeight: FontWeight.bold,
color: isLightTheme
? LightThemeColors.headlinesTextColor
: DarkThemeColors.headlinesTextColor),
headline5: (MyFonts.headlineTextStyle).copyWith(
fontSize: MyFonts.headline5TextSize,
fontWeight: FontWeight.bold,
color: isLightTheme
? LightThemeColors.headlinesTextColor
: DarkThemeColors.headlinesTextColor),
headline6: (MyFonts.headlineTextStyle).copyWith(
fontSize: MyFonts.headline6TextSize,
fontWeight: FontWeight.bold,
color: isLightTheme
? LightThemeColors.headlinesTextColor
: DarkThemeColors.headlinesTextColor),
caption: TextStyle(
color: isLightTheme
? LightThemeColors.captionTextColor
: DarkThemeColors.captionTextColor,
fontSize: MyFonts.captionTextSize),
);
static ChipThemeData getChipTheme({required bool isLightTheme}) {
return ChipThemeData(
backgroundColor: isLightTheme
? LightThemeColors.chipBackground
: DarkThemeColors.chipBackground,
brightness: Brightness.light,
labelStyle: getChipTextStyle(isLightTheme: isLightTheme),
secondaryLabelStyle: getChipTextStyle(isLightTheme: isLightTheme),
selectedColor: Colors.black,
disabledColor: Colors.green,
padding: const EdgeInsets.all(5),
secondarySelectedColor: Colors.purple,
);
}
///Chips text style
static TextStyle getChipTextStyle({required bool isLightTheme}) {
return MyFonts.chipTextStyle.copyWith(
fontSize: MyFonts.chipTextSize,
color: isLightTheme
? LightThemeColors.chipTextColor
: DarkThemeColors.chipTextColor,
);
}
// elevated button text style
static MaterialStateProperty<TextStyle?>? getElevatedButtonTextStyle(
bool isLightTheme,
{bool isBold = true,
double? fontSize}) {
return MaterialStateProperty.resolveWith<TextStyle>(
(Set<MaterialState> states) {
if (states.contains(MaterialState.pressed)) {
return MyFonts.buttonTextStyle.copyWith(
fontWeight: isBold ? FontWeight.bold : FontWeight.normal,
fontSize: fontSize ?? MyFonts.buttonTextSize,
color: isLightTheme
? LightThemeColors.buttonTextColor
: DarkThemeColors.buttonTextColor);
} else if (states.contains(MaterialState.disabled)) {
return MyFonts.buttonTextStyle.copyWith(
fontSize: fontSize ?? MyFonts.buttonTextSize,
fontWeight: isBold ? FontWeight.bold : FontWeight.normal,
color: isLightTheme
? LightThemeColors.buttonDisabledTextColor
: DarkThemeColors.buttonDisabledTextColor);
}
return MyFonts.buttonTextStyle.copyWith(
fontSize: fontSize ?? MyFonts.buttonTextSize,
fontWeight: isBold ? FontWeight.bold : FontWeight.normal,
color: isLightTheme
? LightThemeColors.buttonTextColor
: DarkThemeColors
.buttonTextColor); // Use the component's default.
},
);
}
//elevated button theme data
static ElevatedButtonThemeData getElevatedButtonTheme(
{required bool isLightTheme}) =>
ElevatedButtonThemeData(
style: ButtonStyle(
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(6.r),
//side: BorderSide(color: Colors.teal, width: 2.0),
),
),
elevation: MaterialStateProperty.all(0),
padding:
MaterialStateProperty.all<EdgeInsetsGeometry>(EdgeInsets.symmetric(vertical: 8.h)),
textStyle: getElevatedButtonTextStyle(isLightTheme),
backgroundColor: MaterialStateProperty.resolveWith<Color>(
(Set<MaterialState> states) {
if (states.contains(MaterialState.pressed)) {
return isLightTheme
? LightThemeColors.buttonColor.withOpacity(0.5)
: DarkThemeColors.buttonColor.withOpacity(0.5);
} else if (states.contains(MaterialState.disabled)) {
return isLightTheme
? LightThemeColors.buttonDisabledColor
: DarkThemeColors.buttonDisabledColor;
}
return isLightTheme
? LightThemeColors.buttonColor
: DarkThemeColors.buttonColor; // Use the component's default.
},
),
),
);
}
| 0
|
mirrored_repositories/flutter_grocery_app/lib
|
mirrored_repositories/flutter_grocery_app/lib/utils/constants.dart
|
class Constants {
// assets images
static const logo = 'assets/images/app_icon.png';
static const homeIcon = 'assets/vectors/home.svg';
static const categoryIcon = 'assets/vectors/category.svg';
static const cartIcon = 'assets/vectors/cart.svg';
static const calendarIcon = 'assets/vectors/calendar.svg';
static const userIcon = 'assets/vectors/user.svg';
static const backArrowIcon = 'assets/vectors/back_arrow.svg';
static const addIcon = 'assets/vectors/add.svg';
static const removeIcon = 'assets/vectors/remove.svg';
static const searchIcon = 'assets/vectors/search.svg';
static const themeIcon = 'assets/vectors/theme.svg';
static const basketIcon = 'assets/vectors/basket.svg';
static const cornIcon = 'assets/vectors/corn.svg';
static const fireIcon = 'assets/vectors/fire.svg';
static const emojiIcon = 'assets/vectors/emoji.svg';
static const container = 'assets/vectors/container.svg';
static const apple = 'assets/vectors/apple.svg';
static const broccoli = 'assets/vectors/broccoli.svg';
static const cheese = 'assets/vectors/cheese.svg';
static const meat = 'assets/vectors/meat.svg';
static const background = 'assets/images/background.png';
static const backgroundDark = 'assets/images/background_dark.png';
static const avatar = 'assets/images/avatar.png';
static const calendar = 'assets/images/calendar.png';
static const lotus = 'assets/images/lotus.png';
static const matches = 'assets/images/matches.png';
static const favourites = 'assets/images/favourites.png';
static const lambMeat = 'assets/images/lamb_meat.png';
static const bellPepper = 'assets/images/bell_pepper.png';
static const cabbage = 'assets/images/cabbage.png';
static const carrot = 'assets/images/carrot.png';
static const cauliflower = 'assets/images/cauliflower.png';
static const ginger = 'assets/images/ginger.png';
static const pumpkin = 'assets/images/pumpkin.png';
static const spinach = 'assets/images/spinach.png';
static const tomatoes = 'assets/images/tomatoes.png';
static const card1 = 'assets/images/card1.png';
static const card2 = 'assets/images/card2.png';
static const card3 = 'assets/images/card3.png';
}
| 0
|
mirrored_repositories/flutter_grocery_app/lib
|
mirrored_repositories/flutter_grocery_app/lib/utils/dummy_helper.dart
|
import '../app/data/models/category_model.dart';
import '../app/data/models/product_model.dart';
import 'constants.dart';
class DummyHelper {
const DummyHelper._();
static const _description = 'Ginger is a flowering plant whose rhizome, ginger root or ginger, is widely used as a spice and a folk medicine.';
static List<Map<String, String>> cards = [
{'icon': Constants.lotus, 'title': '100%', 'subtitle': 'Organic'},
{'icon': Constants.calendar, 'title': '1 Year', 'subtitle': 'Expiration'},
{'icon': Constants.favourites, 'title': '4.8 (256)', 'subtitle': 'Reviews'},
{'icon': Constants.matches, 'title': '80 kcal', 'subtitle': '100 Gram'},
];
static List<CategoryModel> categories = [
CategoryModel(id: 1, title: 'Fruits', image: Constants.apple),
CategoryModel(id: 2, title: 'Vegetables', image: Constants.broccoli),
CategoryModel(id: 3, title: 'Cheeses', image: Constants.cheese),
CategoryModel(id: 4, title: 'Meat', image: Constants.meat),
];
static List<ProductModel> products = [
ProductModel(
id: 1,
image: Constants.bellPepper,
name: 'Bell Pepper Red',
quantity: 0,
price: 5.99,
description: _description,
),
ProductModel(
id: 2,
image: Constants.lambMeat,
name: 'Lamb Meat',
quantity: 0,
price: 44.99,
description: _description,
),
ProductModel(
id: 3,
image: Constants.ginger,
name: 'Arabic Ginger',
quantity: 0,
price: 4.99,
description: _description,
),
ProductModel(
id: 4,
image: Constants.cabbage,
name: 'Fresh Lettuce',
quantity: 0,
price: 3.99,
description: _description,
),
ProductModel(
id: 5,
image: Constants.pumpkin,
name: 'Butternut Squash',
quantity: 0,
price: 8.99,
description: _description,
),
ProductModel(
id: 6,
image: Constants.carrot,
name: 'Organic Carrots',
quantity: 0,
price: 5.99,
description: _description,
),
ProductModel(
id: 7,
image: Constants.cauliflower,
name: 'Fresh Broccoli',
quantity: 0,
price: 3.99,
description: _description,
),
ProductModel(
id: 8,
image: Constants.tomatoes,
name: 'Cherry Tomato',
quantity: 0,
price: 5.99,
description: _description,
),
ProductModel(
id: 9,
image: Constants.spinach,
name: 'Fresh Spinach',
quantity: 0,
price: 2.99,
description: _description,
),
];
}
| 0
|
mirrored_repositories/Ansitu
|
mirrored_repositories/Ansitu/lib/main.dart
|
import 'package:flutter/material.dart';
import 'pages/home_page.dart';
import 'package:google_fonts/google_fonts.dart';
import 'models/functions.dart';
Future<void> main() async {
await getSurahList();
await getReaderList();
// await loadAppData();
runApp(MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Ansitu',
themeMode: ThemeMode.system,
theme: ThemeData(
useMaterial3: true,
fontFamily: GoogleFonts.balooBhaijaan2().fontFamily,
// primaryColor: Color(0xff602FB4),
backgroundColor: const Color(0xffFFFBFC),
colorSchemeSeed: const Color(0xff602FB4),
),
darkTheme: ThemeData(
useMaterial3: true,
brightness: Brightness.dark,
fontFamily: GoogleFonts.balooBhaijaan2().fontFamily,
// primaryColor: Color(0xff602FB4),
// backgroundColor: Color(0xffFFFBFC),
colorSchemeSeed: const Color(0xff602FB4),
primaryColorDark: const Color(0xff602FB4),
),
home: HomePage(),
// home: ReaderPage(reader: AppData.readerList.where((element) => '86' == element.id).first,),
);
}
}
| 0
|
mirrored_repositories/Ansitu/lib
|
mirrored_repositories/Ansitu/lib/pages/home_page.dart
|
import 'package:avatar_glow/avatar_glow.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '/models/app_data.dart';
import '/models/reader.dart';
import '/pages/reader_page.dart';
import 'package:flutter_vibrate/flutter_vibrate.dart';
import 'package:tflite_audio/tflite_audio.dart';
import 'readers_page.dart';
class HomePage extends StatefulWidget {
HomePage({Key? key}) : super(key: key);
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
late AnimationController beforeDetectController;
late AnimationController afterDetectController;
late Animation<double> beforeDetectAnimation;
late Animation<double> afterDetectAnimation;
late AnimationController buttonController;
late Animation<double> buttonAnimation;
late Stream<Map<dynamic, dynamic>> recognitionStream;
Reader? reader;
String result = '';
int inferenceTime = 0;
bool isKnown = true;
bool isGlowing = false;
void startRecognition() {
recognitionStream = TfliteAudio.startAudioRecognition(
sampleRate: 44100,
bufferSize: 22016,
//NOTE: This will set 70% as minimum confidence
detectionThreshold: 0.7,
//TODO: Check This later
averageWindowDuration: 1500,
// suppressionTime: 10,
// averageWindowDuration: 10,
);
}
void setUpAnimation() {
beforeDetectController = AnimationController(
vsync: this,
duration: Duration(milliseconds: 200),
);
afterDetectController = AnimationController(
vsync: this,
duration: Duration(milliseconds: 200),
);
beforeDetectAnimation = Tween(begin: 1.0, end: 0.0).animate(CurvedAnimation(
parent: beforeDetectController,
curve: Curves.easeInOut,
));
afterDetectAnimation = Tween(begin: 0.0, end: 1.0).animate(CurvedAnimation(
parent: afterDetectController,
curve: Curves.easeInOut,
));
beforeDetectAnimation = Tween(begin: 0.0, end: 1.0).animate(CurvedAnimation(
parent: beforeDetectController,
curve: Curves.easeInOut,
));
beforeDetectController.forward();
buttonController = AnimationController(
vsync: this,
duration: Duration(milliseconds: 1000),
);
buttonAnimation = Tween(begin: 3.0, end: 4.0).animate(
CurvedAnimation(
parent: buttonController,
curve: Curves.easeInOut,
),
);
buttonController.forward();
buttonAnimation.addStatusListener((status) {
if (status == AnimationStatus.completed) {
buttonController.reverse();
} else if (status == AnimationStatus.dismissed) {
buttonController.forward();
}
});
}
void loadModel() {
TfliteAudio.loadModel(
model: 'assets/model.tflite',
label: 'assets/labels.txt',
inputType: 'rawAudio',
numThreads: 10,
);
}
void restart() async {
await TfliteAudio.stopAudioRecognition();
print('looooool');
startRecognition();
}
@override
void initState() {
super.initState();
loadModel();
setUpAnimation();
}
@override
void dispose() {
super.dispose();
beforeDetectController.dispose();
afterDetectController.dispose();
buttonController.dispose();
TfliteAudio.stopAudioRecognition();
}
@override
Widget build(BuildContext context) {
ThemeData theme = Theme.of(context);
Color primary = theme.brightness == Brightness.light
? theme.primaryColor
: theme.primaryColorDark;
return Scaffold(
floatingActionButton: Directionality(
textDirection: TextDirection.rtl,
child: FloatingActionButton.extended(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ReadersPage(),
),
);
},
label: Text('جميع القراء'),
icon: Icon(Icons.record_voice_over_rounded),
// child: Icon(Icons.record_voice_over_rounded),
),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Spacer(
flex: 1,
),
FadeTransition(
opacity: beforeDetectAnimation,
child: Text(
'Tap to start',
style: TextStyle(
fontSize: 30,
fontWeight: FontWeight.bold,
),
),
),
AvatarGlow(
endRadius: 200,
repeat: true,
animate: isGlowing,
glowColor: primary,
child: GestureDetector(
onTap: () {
if (!isGlowing) {
Vibrate.feedback(FeedbackType.medium);
beforeDetectController.reverse();
afterDetectController.forward();
startRecognition();
recognitionStream.listen((event) {
switch (event['recognitionResult']) {
case 'nasser_alqatami':
reader = AppData.readerList
.where((reader) => 'ناصر القطامي' == reader.name)
.first;
reader!.instagram =
'https://www.instagram.com/alqtaminasser/';
reader!.twitter =
'https://twitter.com/nasseralqtami?lang=ar';
reader!.youtube =
'https://www.youtube.com/channel/UC-AuvzIPDgBmvoDMlLhBuFQ';
Vibrate.feedback(FeedbackType.success);
result = 'ناصر القطامي';
inferenceTime = event["inferenceTime"];
print(result);
isKnown = true;
break;
case 'al_shatri':
reader = AppData.readerList
.where((reader) =>
'شيخ أبو بكر الشاطري' == reader.name)
.first;
reader!.instagram =
'https://www.instagram.com/sheikhalshateri/';
reader!.twitter =
'https://twitter.com/sheikhalshateri?lang=ar';
reader!.youtube =
'https://www.youtube.com/user/noblequran2';
Vibrate.feedback(FeedbackType.success);
result = 'شاطري';
inferenceTime = event["inferenceTime"];
print(result);
isKnown = true;
break;
case 'abdulaziz_alzahrani':
reader = AppData.readerList
.where((reader) =>
'عبدالعزيز الزهراني' == reader.name)
.first;
//TODO change links
reader!.instagram =
'https://www.instagram.com/alzhranitv/';
reader!.twitter =
'https://twitter.com/alzhranitv';
reader!.youtube =
'https://www.youtube.com/channel/UCYh95QxdA8GHTJowBuXcLNQ';
Vibrate.feedback(FeedbackType.success);
result = 'عبدالعزيز الزهراني';
inferenceTime = event["inferenceTime"];
print(result);
isKnown = true;
break;
case 'al_sudais':
reader = AppData.readerList
.where(
(reader) => 'عبدالرحمن السديس' == reader.name)
.first;
//TODO change links
reader!.instagram =
'https://www.instagram.com/_asudais/';
reader!.twitter =
'https://twitter.com/alsudayscom?lang=ar';
reader!.youtube =
'https://www.youtube.com/channel/UCT-w0BCxz1gIfVx2VgcDlYw';
Vibrate.feedback(FeedbackType.success);
result = 'عبدالرحمن السديس';
inferenceTime = event["inferenceTime"];
print(result);
isKnown = true;
break;
case 'saud_alshuraim':
reader = AppData.readerList
.where((reader) => 'سعود الشريم' == reader.name)
.first;
//TODO change links
reader!.instagram =
'https://www.instagram.com/saud_shuraim/';
reader!.twitter =
'https://twitter.com/salshuraym?ref_src=twsrc%5Egoogle%7Ctwcamp%5Eserp%7Ctwgr%5Eauthor';
reader!.youtube =
'https://www.youtube.com/channel/UCGUK0a-a20ef34PI4X60SRQ';
Vibrate.feedback(FeedbackType.success);
result = 'سعود الشريم';
inferenceTime = event["inferenceTime"];
print(result);
isKnown = true;
break;
default:
Vibrate.feedback(FeedbackType.error);
isKnown = false;
print(event['recognitionResult']);
break;
}
}).onDone(
() {
if (isKnown)
Navigator.push(
context,
CupertinoPageRoute(
builder: (context) => ReaderPage(reader: reader!),
),
);
beforeDetectController.forward();
afterDetectController.reverse();
setState(() {
isGlowing = !isGlowing;
});
},
);
} else {
TfliteAudio.stopAudioRecognition();
beforeDetectController.forward();
afterDetectController.reverse();
}
setState(() {
isGlowing = !isGlowing;
});
},
child: ScaleTransition(
scale: Tween(begin: 1.0, end: isGlowing ? 1.2 : 1.0).animate(
CurvedAnimation(
parent: buttonController,
curve: Curves.ease,
),
),
child: Material(
shape: CircleBorder(),
child: CircleAvatar(
backgroundColor: primary,
child: Icon(
Icons.search_rounded,
size: 90,
color: Colors.white,
),
radius: 90.0,
),
),
),
),
),
Visibility(
child: Text(
'Please try again',
style: TextStyle(
fontSize: 30,
fontWeight: FontWeight.bold,
color: theme.errorColor,
),
),
visible: !isGlowing & !isKnown,
),
FadeTransition(
opacity: afterDetectAnimation,
child: Text(
'Detecting...',
style: TextStyle(
fontSize: 30,
fontWeight: FontWeight.bold,
),
),
),
Spacer(
flex: 2,
),
],
),
),
);
}
}
| 0
|
mirrored_repositories/Ansitu/lib
|
mirrored_repositories/Ansitu/lib/pages/detection_page.dart
|
import 'package:flutter/material.dart';
import 'package:tflite_audio/tflite_audio.dart';
class DetectionPage extends StatefulWidget {
const DetectionPage({Key? key}) : super(key: key);
@override
State<DetectionPage> createState() => _DetectionPageState();
}
class _DetectionPageState extends State<DetectionPage> {
late Stream<Map<dynamic, dynamic>> recognitionStream;
String result = '';
int inferenceTime = 0;
bool isKnown = true;
@override
void initState() {
super.initState();
TfliteAudio.loadModel(
//TODO: Change this to your own model // done
model: 'assets/soundclassifier_with_metadata.tflite',
label: 'assets/labels.txt',
inputType: 'rawAudio',
);
}
void startRecognition() {
recognitionStream = TfliteAudio.startAudioRecognition(
sampleRate: 44100,
bufferSize: 22016,
//NOTE: This will set 70% as minimum confidence
detectionThreshold: 0.7,
averageWindowDuration: 10,
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(result),
ElevatedButton(
child: Text('Start'),
style: ElevatedButton.styleFrom(shape: StadiumBorder()),
onPressed: () {
startRecognition();
recognitionStream.listen((event) {
switch (event['recognitionResult']) {
case 'Nasser':
result = 'ناصر القطامي';
inferenceTime = event["inferenceTime"];
print(result);
isKnown = true;
break;
case 'Shatery':
result = 'شاطري';
inferenceTime = event["inferenceTime"];
print(result);
isKnown = true;
break;
default:
isKnown = false;
break;
}
}).onDone(
() {
setState(() {});
if (!isKnown) startRecognition();
},
);
},
),
// ElevatedButton(
// onPressed: () {
// // TfliteAudio.stopAudioRecognition();
// },
// child: Text('End'),
// style: ElevatedButton.styleFrom(
// shape: StadiumBorder(), primary: Colors.red),
// )
],
),
),
);
}
}
| 0
|
mirrored_repositories/Ansitu/lib
|
mirrored_repositories/Ansitu/lib/pages/reader_page.dart
|
import 'package:assets_audio_player/assets_audio_player.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import '/models/app_data.dart';
import '/models/surah.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:url_launcher/url_launcher.dart';
import '../models/reader.dart';
import 'readers_page.dart';
class ReaderPage extends StatefulWidget {
ReaderPage({Key? key, required this.reader}) : super(key: key);
final Reader reader;
@override
State<ReaderPage> createState() => _ReaderPageState();
}
class _ReaderPageState extends State<ReaderPage>
with SingleTickerProviderStateMixin {
late AnimationController iconController;
@override
void initState() {
iconController =
AnimationController(vsync: this, duration: Duration(milliseconds: 200));
AppData.assetsAudioPlayer.showNotification = true;
super.initState();
}
@override
void dispose() {
// assetsAudioPlayer.stop();
iconController.dispose();
super.dispose();
}
bool _play = false;
String _currentPosition = '';
TextEditingController searchController = TextEditingController();
List<Surah> listToShow = [];
@override
Widget build(BuildContext context) {
String url =
'${widget.reader.server}/${widget.reader.suras[0].id.padLeft(3, '0')}.mp3';
ThemeData theme = Theme.of(context);
Color primary = theme.brightness == Brightness.light
? theme.primaryColor
: theme.primaryColorDark;
bool isFav = AppData.favoriteReaders.contains(widget.reader);
if (searchController.text == '') listToShow = widget.reader.suras;
return Scaffold(
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
floatingActionButton: FloatingActionButton(
onPressed: () {
// print(_play);
// print(AppData.assetsAudioPlayer.isPlaying.value);
setState(() {
_play = !_play;
if (!AppData.assetsAudioPlayer.isPlaying.value) {
AppData.assetsAudioPlayer.play();
iconController.forward();
} else {
AppData.assetsAudioPlayer.pause();
iconController.reverse();
}
});
},
child: AnimatedBuilder(
animation:
CurvedAnimation(parent: iconController, curve: Curves.easeInOut),
builder: (context, child) {
return AnimatedIcon(
icon: AnimatedIcons.play_pause,
progress: CurvedAnimation(
parent: iconController, curve: Curves.easeInOut),
);
},
child: Icon(
_play ? Icons.pause : Icons.play_arrow,
),
),
),
body: SafeArea(
top: false,
child: Center(
child: Scrollbar(
child: Directionality(
textDirection: TextDirection.rtl,
child: CustomScrollView(
slivers: [
SliverAppBar(
// backgroundColor: primary,
expandedHeight: 100,
pinned: true,
leading: SizedBox(),
actions: [
if (widget.reader.instagram != '')
IconButton(
splashRadius: 20,
onPressed: () {
launch(widget.reader.instagram!);
},
icon: Icon(FontAwesomeIcons.instagram),
),
if (widget.reader.twitter != '')
IconButton(
splashRadius: 20,
onPressed: () {
launch(widget.reader.twitter!);
},
icon: Icon(FontAwesomeIcons.twitter),
),
if (widget.reader.youtube != '')
IconButton(
splashRadius: 20,
onPressed: () {
launch(widget.reader.youtube!);
},
icon: Icon(FontAwesomeIcons.youtube),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: IconButton(
onPressed: () {
Navigator.pop(context);
},
icon: Icon(Icons.arrow_back_ios_new),
),
),
],
flexibleSpace: FlexibleSpaceBar(
title: OverflowBox(
alignment: AlignmentDirectional.bottomStart,
maxWidth: MediaQuery.of(context).size.width,
child: Row(
children: [
IconButton(
onPressed: () async {
if (isFav) {
AppData.favoriteReaders.remove(widget.reader);
// await saveAppData();
} else {
AppData.favoriteReaders.add(widget.reader);
// await saveAppData();
}
setState(() {});
},
icon: Icon(
isFav
? Icons.favorite_rounded
: Icons.favorite_border_rounded,
color: Colors.redAccent,
),
padding: EdgeInsets.all(0),
splashRadius: 16,
),
FittedBox(
fit: BoxFit.scaleDown,
child: Text(
widget.reader.name,
overflow: TextOverflow.fade,
style: TextStyle(fontSize: 25),
),
),
],
),
),
centerTitle: false,
titlePadding:
EdgeInsets.symmetric(horizontal: 0, vertical: 0),
),
),
SliverPersistentHeader(
pinned: true,
delegate: PersistentHeader(
widget: Directionality(
textDirection: TextDirection.ltr,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Row(
children: [
Expanded(
child: Hero(
tag: 'Search',
child: Material(
child: SizedBox(
height: 44,
child: TextField(
controller: searchController,
onChanged: (value) {
listToShow = widget.reader.suras
.where((surah) => surah.name
.contains(
searchController.text))
.toList();
setState(() {});
print(listToShow);
},
decoration: InputDecoration(
hintText: "Search",
contentPadding:
EdgeInsets.symmetric(vertical: 4),
prefixIcon: Icon(Icons.search),
border: OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(15.0),
),
),
),
),
),
),
),
),
],
),
),
),
),
),
SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
Surah surah = listToShow[index];
return ListTile(
title: Text(surah.name,
style: theme.textTheme.headline6),
onTap: () async {
AppData.assetsAudioPlayer.stop();
print(_play);
HapticFeedback.mediumImpact();
try {
await AppData.assetsAudioPlayer.open(
Audio.network(
'${widget.reader.server}/${surah.id.padLeft(3, '0')}.mp3',
metas: Metas(
title: surah.name,
artist: widget.reader.name,
),
),
showNotification: true,
playInBackground: PlayInBackground.enabled,
);
iconController.forward();
setState(() {
_play = true;
});
} catch (t) {
//mp3 unreachable
print('error');
}
// print(
// await reader.getAudio(int.parse(surah.id)));
},
);
},
childCount: listToShow.length,
),
),
],
),
),
),
),
),
);
}
}
| 0
|
mirrored_repositories/Ansitu/lib
|
mirrored_repositories/Ansitu/lib/pages/readers_page.dart
|
import 'package:flutter/material.dart';
import '/models/app_data.dart';
import '/models/reader.dart';
import '/pages/reader_page.dart';
class ReadersPage extends StatefulWidget {
const ReadersPage({Key? key}) : super(key: key);
@override
State<ReadersPage> createState() => _ReadersPageState();
}
class _ReadersPageState extends State<ReadersPage> {
bool toggelFav = false;
TextEditingController searchController = TextEditingController();
List<Reader> listToShow = AppData.readerList;
@override
Widget build(BuildContext context) {
ThemeData theme = Theme.of(context);
Color primary = theme.brightness == Brightness.light
? theme.primaryColor
: theme.primaryColorDark;
return Scaffold(
body: Center(
child: Scrollbar(
child: Directionality(
textDirection: TextDirection.rtl,
child: CustomScrollView(
slivers: [
SliverAppBar(
expandedHeight: 100,
// backgroundColor: primary,
pinned: true,
leading: SizedBox(),
actions: [
Padding(
padding: const EdgeInsets.all(8.0),
child: IconButton(
onPressed: () {
Navigator.pop(context);
},
icon: Icon(Icons.arrow_back_ios_new)),
),
],
flexibleSpace: FlexibleSpaceBar(
title: Text(
"القراء",
style: TextStyle(fontSize: 30),
),
centerTitle: false,
titlePadding:
EdgeInsets.symmetric(horizontal: 16, vertical: 0),
),
),
SliverPersistentHeader(
pinned: true,
delegate: PersistentHeader(
widget: Directionality(
textDirection: TextDirection.ltr,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Row(
children: [
// Icon(
// toggelFav
// ? Icons.favorite_rounded
// : Icons.favorite_border_rounded,
// size: Theme.of(context)
// .textTheme
// .headline6!
// .fontSize,
// color: Colors.redAccent,
// ),
// Switch(
// value: toggelFav,
// onChanged: (value) {
// setState(() {
// toggelFav = value;
// });
// },
// ),
Expanded(
child: Hero(
tag: 'Search',
child: Material(
child: SizedBox(
height: 44,
child: TextField(
controller: searchController,
onChanged: (value) {
if (toggelFav) {
listToShow = AppData.favoriteReaders
.where((reader) => reader.name
.contains(searchController.text))
.toList();
setState(() {});
} else {
listToShow = AppData.readerList
.where((reader) => reader.name
.contains(searchController.text))
.toList();
}
setState(() {});
},
decoration: InputDecoration(
hintText: "Search",
contentPadding:
EdgeInsets.symmetric(vertical: 4),
prefixIcon: Icon(Icons.search),
border: OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(15.0),
),
),
),
),
),
),
),
),
SizedBox(width: 8),
DropdownButton(
hint: toggelFav ? Text("Favorite") : Text("All"),
underline: SizedBox(),
items: [
DropdownMenuItem(
value: false,
child: Text('All'),
),
DropdownMenuItem(
value: true,
child: Text('Favorite'),
),
],
onChanged: (value) {
setState(() {
toggelFav = value.toString() == 'true';
listToShow = toggelFav ? AppData.favoriteReaders : AppData.readerList;
});
},
),
],
),
),
),
),
),
if(listToShow.isEmpty) SliverToBoxAdapter(
child: Center(
child: Text("No Reciters", style: TextStyle(fontSize: 20),),
),
),
if(listToShow.isNotEmpty) SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
var reader = listToShow[index];
return ListTile(
title: Text(
reader.name,
style: Theme.of(context).textTheme.headline6,
),
subtitle: Text(reader.rewaya),
trailing: Icon(Icons.arrow_back_ios_new_rounded),
leading: Icon(Icons.record_voice_over),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ReaderPage(reader: reader),
),
);
},
);
},
childCount: listToShow.length,
),
),
],
),
),
),
),
);
}
}
class PersistentHeader extends SliverPersistentHeaderDelegate {
final Widget widget;
PersistentHeader({required this.widget});
@override
Widget build(
BuildContext context, double shrinkOffset, bool overlapsContent) {
return Container(
width: double.infinity,
// height: 56.0,
color: Theme.of(context).backgroundColor,
child: Center(child: widget),
);
}
@override
double get maxExtent => 56.0;
@override
double get minExtent => 56.0;
@override
bool shouldRebuild(SliverPersistentHeaderDelegate oldDelegate) {
return true;
}
}
| 0
|
mirrored_repositories/Ansitu/lib
|
mirrored_repositories/Ansitu/lib/models/functions.dart
|
import 'dart:convert';
import 'package:dio/dio.dart';
import '/models/app_data.dart';
import '/models/reader.dart';
import '/models/surah.dart';
Future<void> getSurahList() async {
Response surahJson;
var res;
try {
surahJson =
// await Dio().get('https://www.mp3quran.net/api/arabic__sura.json');
await Dio().get('https://mp3quran.net/api/_arabic_sura.json');
res = await json.decode(surahJson.data);
} catch (e) {
print(e);
}
AppData.suraList = List.generate(
(res['Suras_Name'] as List).length,
(index) => Surah.fromMap(
(res['Suras_Name'] as List)[index] as Map<String, dynamic>),
);
}
Future<void> getReaderList() async {
Response readersJson =
await Dio().get('https://www.mp3quran.net/api/_arabic.json');
// try {
// // readersJson = await Dio().get('https://www.mp3quran.net/api/_arabic.json');
// } catch (e) {
// print(e);
// }
// print(readersJson.data);
// print((jsonDecode(readersJson.data)['reciters'] as List));
var data = jsonDecode(readersJson.data)['reciters'] as List;
// print(data.length);
AppData.readerList = List.generate(
data.length,
(index) => Reader.fromMap(data[index] as Map<String, dynamic>),
);
}
// Future<void> loadAppData() async {
// final prefs = await SharedPreferences.getInstance();
// List<String>? res = await prefs.getStringList('AppData');
// if (res != null) {
// for (var reader in res) {
// AppData.favoriteReaders.add(Reader.fromJson(reader));
// }
// }
// }
// Future<void> saveAppData() async {
// final prefs = await SharedPreferences.getInstance();
// await prefs.setStringList(
// 'AppData',
// List<String>.generate(AppData.favoriteReaders.length,
// (index) => AppData.favoriteReaders[index].toJson()));
// }
| 0
|
mirrored_repositories/Ansitu/lib
|
mirrored_repositories/Ansitu/lib/models/surah.dart
|
import 'dart:convert';
class Surah {
final String id;
final String name;
Surah({
required this.id,
required this.name,
});
Surah copyWith({
String? id,
String? name,
}) {
return Surah(
id: id ?? this.id,
name: name ?? this.name,
);
}
Map<String, dynamic> toMap() {
return {
'id': id,
'name': name,
};
}
factory Surah.fromMap(Map<String, dynamic> map) {
return Surah(
id: map['id'] ?? '',
name: map['name'].replaceAll('\n', '').replaceAll('\r', '') ?? '',
);
}
String toJson() => json.encode(toMap());
factory Surah.fromJson(String source) => Surah.fromMap(json.decode(source));
@override
String toString() => 'Surah(id: $id, name: $name)';
@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
return other is Surah && other.id == id && other.name == name;
}
@override
int get hashCode => id.hashCode ^ name.hashCode;
}
| 0
|
mirrored_repositories/Ansitu/lib
|
mirrored_repositories/Ansitu/lib/models/reader.dart
|
import 'package:dio/dio.dart';
import '/models/app_data.dart';
import 'dart:convert';
import 'surah.dart';
import 'package:collection/collection.dart';
class Reader {
final String id;
final String name;
final String server;
final String rewaya;
final String count;
final String letter;
final List<Surah> suras;
String? instagram;
String? twitter;
String? youtube;
Reader({
required this.id,
required this.name,
required this.server,
required this.rewaya,
required this.count,
required this.letter,
required this.suras,
this.instagram = '',
this.twitter = '',
this.youtube = '',
});
Reader copyWith({
String? id,
String? name,
String? server,
String? rewaya,
String? count,
String? letter,
List<Surah>? suras,
}) {
return Reader(
id: id ?? this.id,
name: name ?? this.name,
server: server ?? this.server,
rewaya: rewaya ?? this.rewaya,
count: count ?? this.count,
letter: letter ?? this.letter,
suras: suras ?? this.suras,
);
}
Map<String, dynamic> toMap() {
return {
'id': id,
'name': name,
'server': server,
'rewaya': rewaya,
'count': count,
'letter': letter,
'suras': suras.map((x) => x.toMap()).toList(),
};
}
factory Reader.fromMap(Map<String, dynamic> map) {
String suras = map['suras'];
List<Surah> finalSuras = [];
suras.split(',').forEach((id) {
finalSuras.add(AppData.suraList.where((surah) => surah.id == id).first);
});
return Reader(
id: map['id'] ?? '',
name: map['name'] ?? '',
server: map['Server'] ?? '',
rewaya: map['rewaya'] ?? '',
count: map['count'] ?? '',
letter: map['letter'] ?? '',
suras: finalSuras,
);
}
String toJson() => json.encode(toMap());
factory Reader.fromJson(String source) => Reader.fromMap(json.decode(source));
@override
String toString() {
return 'Reader(id: $id, name: $name, server: $server, rewaya: $rewaya, count: $count, letter: $letter, suras: $suras)';
}
@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
final listEquals = const DeepCollectionEquality().equals;
return other is Reader &&
other.id == id &&
other.name == name &&
other.server == server &&
other.rewaya == rewaya &&
other.count == count &&
other.letter == letter &&
listEquals(other.suras, suras);
}
@override
int get hashCode {
return id.hashCode ^
name.hashCode ^
server.hashCode ^
rewaya.hashCode ^
count.hashCode ^
letter.hashCode ^
suras.hashCode;
}
Future<String> getAudio(int surahId) async {
print('$server/${surahId.toString().padLeft(3, '0')}.mp3');
var audio =
await Dio().get('$server/${surahId.toString().padLeft(3, '0')}.mp3');
// print(audio.data);
return audio.data;
}
}
| 0
|
mirrored_repositories/Ansitu/lib
|
mirrored_repositories/Ansitu/lib/models/app_data.dart
|
import 'package:assets_audio_player/assets_audio_player.dart';
import 'reader.dart';
import 'surah.dart';
class AppData {
static List<Surah> suraList = [];
static List<Reader> readerList = [];
static List<Reader> favoriteReaders = [];
static final assetsAudioPlayer = AssetsAudioPlayer();
String toJSON() {
Map<String, List> json = {
'favoriteReaders': favoriteReaders,
};
return json.toString();
}
}
| 0
|
mirrored_repositories/Ansitu
|
mirrored_repositories/Ansitu/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:ansitu/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}
| 0
|
mirrored_repositories/Flutter-Splash-Project
|
mirrored_repositories/Flutter-Splash-Project/lib/widget.dart
|
import 'package:flutter/material.dart';
Widget appbar(BuildContext context)
{
return RichText(
text: TextSpan(
text: null,
style: TextStyle(fontSize: 22.0,fontWeight: FontWeight.w900),
children: <TextSpan>[
TextSpan(text: 'Quiz',style:TextStyle(color:Colors.blue)),
TextSpan(text: 'Application',style:TextStyle(color:Colors.black87)),
]
),
);
}
| 0
|
mirrored_repositories/Flutter-Splash-Project
|
mirrored_repositories/Flutter-Splash-Project/lib/splash.dart
|
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_app/home.dart';
import 'package:flutter_app/widget.dart';
class splashscreen extends StatefulWidget {
@override
_splashscreenState createState() => _splashscreenState();
}
class _splashscreenState extends State<splashscreen> {
@override
void initSate()
{
super.initState();
Timer(Duration(seconds: 3),(){
Navigator.of(context).pushReplacement(MaterialPageRoute(builder: (context)=>Homepage()));
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: appbar(context),
),
);
}
}
| 0
|
mirrored_repositories/Flutter-Splash-Project
|
mirrored_repositories/Flutter-Splash-Project/lib/main.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_app/home.dart';
import 'package:flutter_app/splash.dart';
import 'package:flutter_app/widget.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Calculator(),
debugShowCheckedModeBanner: false,
);
}
}
// class HomeWidget extends StatefulWidget {
// @override
// _HomeWidgetState createState() => _HomeWidgetState();
// }
//
// class _HomeWidgetState extends State<HomeWidget> {
// int _index=0;
// @override
// Widget build(BuildContext context) {
// return Scaffold(
// appBar: AppBar(title: appbar(context),
// backgroundColor: Colors.white,
// elevation: 0.1,),
// body: Column(children: <Widget>[
// Spacer(),
// Padding(
// padding: EdgeInsets.only(top:10.0,left: 18.0,bottom: MediaQuery.of(context).padding.bottom),
// child: Row(
// children: <Widget>[
// GestureDetector(
// onTap: (){
// setState(() {
// _index=0;
// });
// },
// child: Container(
// decoration: BoxDecoration(color: _index==0?Colors.red:Colors.transparent,borderRadius: BorderRadius.circular(25.0)),
// child: Padding(
// padding: const EdgeInsets.symmetric(horizontal: 15.0,vertical:12.0),
// child: Row(children: <Widget>[
// Icon(Icons.home,color: _index==0?Colors.white:Colors.black,),
// Text(_index==0?"Home":"",style:TextStyle(color: _index==0?Colors.white:Colors.black))
// ],),
// ),
// ),
// ),
// GestureDetector(
// onTap: (){
// setState(() {
// _index=1;
// });
// },
// child: Container(
// decoration: BoxDecoration(color: _index==1?Colors.red:Colors.transparent,borderRadius: BorderRadius.circular(25.0)),
// child: Padding(
// padding: const EdgeInsets.symmetric(horizontal: 15.0,vertical:12.0),
// child: Row(children: <Widget>[
// Icon(Icons.home,color: _index==1?Colors.white:Colors.black,),
// Text(_index==1?"Home":"",style: TextStyle(color: _index==1?Colors.white:Colors.black),)
// ],),
// ),
// ),
// ),
// GestureDetector(
// onTap: (){
// setState(() {
// _index=2;
// });
// },
// child: Container(
// decoration: BoxDecoration(color:_index==2?Colors.red:Colors.transparent,borderRadius: BorderRadius.circular(25.0)),
// child: Padding(
// padding: const EdgeInsets.symmetric(horizontal: 15.0,vertical:12.0),
// child: Row(children: <Widget>[
// Icon(Icons.home,color: _index==2?Colors.white:Colors.black,),
// Text(_index==2?"Home":"")
// ],),
// ),
// ),
// ),
// ],
// ),
// )
// ],),
// );
// }
// }
class Calculator extends StatefulWidget {
@override
_CalculatorState createState() => _CalculatorState();
}
class _CalculatorState extends State<Calculator> {
Widget CustomButton(String btnval)
{
Expanded(
child: OutlineButton(
onPressed: (){},
padding: EdgeInsets.all(25.0),
child: Text(btnval),
),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Row(
children:<Widget>[CustomButton("9"),
CustomButton("8")
],
)
],
),
),
);
}
}
| 0
|
mirrored_repositories/Flutter-Splash-Project
|
mirrored_repositories/Flutter-Splash-Project/lib/home.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_app/widget.dart';
class Homepage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Center(child: Text('Quiz Application Splash Screen'),);
}
}
| 0
|
mirrored_repositories/Flutter-Splash-Project
|
mirrored_repositories/Flutter-Splash-Project/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:flutter_app/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/shoes_shopping
|
mirrored_repositories/shoes_shopping/lib/detail_page.dart
|
import 'package:flutter/material.dart';
import 'package:shoe_shop/entrance_fader.dart';
class DetailPage extends StatefulWidget {
final String tag;
final String imageUrl;
final bool isFavoutrite;
final String cost;
DetailPage({this.tag, this.imageUrl, this.isFavoutrite, this.cost});
@override
_DetailPageState createState() => _DetailPageState();
}
class _DetailPageState extends State<DetailPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: SingleChildScrollView(
child: Hero(
tag: widget.tag,
child: Container(
height: MediaQuery.of(context).size.height,
width: double.infinity,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(widget.imageUrl), fit: BoxFit.cover),
boxShadow: [
BoxShadow(
color: Colors.grey[400],
blurRadius: 10,
offset: Offset(0, 10),
)
],
),
child: EntranceFader(
duration: Duration(milliseconds: 800),
child: Stack(
children: <Widget>[
Padding(
padding: EdgeInsets.symmetric(
horizontal: 15.0,
vertical: 45.0,
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
GestureDetector(
onTap: () {
Navigator.pop(context);
},
child: Container(
width: 35.0,
height: 35.0,
child: Icon(
Icons.arrow_back_ios,
color: Colors.white,
),
),
),
Container(
width: 35.0,
height: 35.0,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.white,
),
child: Icon(
Icons.favorite_border,
color: Colors.redAccent,
size: 20.0,
),
),
],
),
),
Positioned(
bottom: 0,
left: 0,
width: MediaQuery.of(context).size.width,
height: 500.0,
child: Container(
padding: EdgeInsets.all(20.0),
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.bottomRight,
colors: [
Colors.black.withOpacity(0.9),
Colors.black.withOpacity(.0),
],
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Text(
"Sneakers",
style: TextStyle(
color: Colors.white,
fontSize: 50.0,
fontWeight: FontWeight.bold,
),
),
SizedBox(
height: 30.0,
),
Row(
children: <Widget>[
Container(
width: 40,
height: 40,
margin: EdgeInsets.only(right: 20.0),
child: Center(
child: Text(
"40",
style: TextStyle(
color: Colors.white,
fontSize: 20.0,
fontWeight: FontWeight.bold),
),
),
),
Container(
width: 40,
height: 40,
margin: EdgeInsets.only(right: 20.0),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10),
),
child: Center(
child: Text(
"42",
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.bold),
),
),
),
Container(
width: 40,
height: 40,
margin: EdgeInsets.only(right: 20.0),
child: Center(
child: Text(
"44",
style: TextStyle(
color: Colors.white,
fontSize: 20.0,
fontWeight: FontWeight.bold),
),
),
),
Container(
width: 40,
height: 40,
margin: EdgeInsets.only(right: 20.0),
child: Center(
child: Text(
"46",
style: TextStyle(
color: Colors.white,
fontSize: 20.0,
fontWeight: FontWeight.bold),
),
),
),
],
),
SizedBox(height: 50.0),
Container(
height: 50.0,
width: double.infinity,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(15.0),
),
child: Center(
child: Text(
"Buy Now",
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.bold,
),
),
),
),
SizedBox(height: 20.0),
],
),
),
),
],
),
),
),
),
),
);
}
}
| 0
|
mirrored_repositories/shoes_shopping
|
mirrored_repositories/shoes_shopping/lib/tabs.dart
|
import 'package:flutter/material.dart';
class Tabs extends StatelessWidget {
final String name;
final bool isSelected;
Tabs(this.name, this.isSelected);
@override
Widget build(BuildContext context) {
return AspectRatio(
aspectRatio: 2.2 / 1,
child: Container(
margin: EdgeInsets.only(right: 8.0),
decoration: isSelected
? BoxDecoration(
color: Colors.grey[200],
borderRadius: BorderRadius.circular(30.0))
: null,
child: Center(
child: Text(
name,
style: isSelected
? TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.bold,
)
: TextStyle(
fontSize: 18.0,
),
)),
),
);
}
}
| 0
|
mirrored_repositories/shoes_shopping
|
mirrored_repositories/shoes_shopping/lib/entrance_fader.dart
|
import 'package:flutter/material.dart';
class EntranceFader extends StatefulWidget {
/// Child to be animated on entrance
final Widget child;
/// Delay after which the animation will start
final Duration delay;
/// Duration of entrance animation
final Duration duration;
/// Starting point from which the widget will fade to its default position
final Offset offset;
const EntranceFader({
Key key,
this.child,
this.delay = const Duration(milliseconds: 0),
this.duration = const Duration(milliseconds: 400),
this.offset = const Offset(0.0, 32.0),
}) : super(key: key);
@override
EntranceFaderState createState() {
return new EntranceFaderState();
}
}
class EntranceFaderState extends State<EntranceFader>
with SingleTickerProviderStateMixin {
AnimationController _controller;
Animation _dxAnimation;
Animation _dyAnimation;
@override
void initState() {
super.initState();
_controller = AnimationController(vsync: this, duration: widget.duration);
_dxAnimation =
Tween(begin: widget.offset.dx, end: 0.0).animate(_controller);
_dyAnimation =
Tween(begin: widget.offset.dy, end: 0.0).animate(_controller);
Future.delayed(widget.delay, () {
if (this.mounted) {
_controller.forward();
}
});
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: _controller,
builder: (context, child) => Opacity(
opacity: _controller.value,
child: Transform.translate(
offset: Offset(_dxAnimation.value, _dyAnimation.value),
child: widget.child,
),
),
);
}
}
| 0
|
mirrored_repositories/shoes_shopping
|
mirrored_repositories/shoes_shopping/lib/main.dart
|
import 'package:flutter/material.dart';
import 'package:shoe_shop/cards.dart';
import 'package:shoe_shop/tabs.dart';
import 'package:flutter/services.dart';
void main() => runApp(
MaterialApp(
debugShowCheckedModeBanner: false,
home: HomePage(),
),
);
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
@override
Widget build(BuildContext context) {
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
]);
SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
statusBarIconBrightness: Brightness.dark,
),
);
return Scaffold(
appBar: AppBar(
elevation: 0,
backgroundColor: Colors.transparent,
leading: null,
title: Text(
"Nike Shoes",
style: TextStyle(color: Colors.black, fontSize: 25.0),
),
actions: <Widget>[
IconButton(
icon: Icon(
Icons.notifications_none,
color: Colors.black,
),
onPressed: null),
IconButton(
icon: Icon(
Icons.add_shopping_cart,
color: Colors.black,
),
onPressed: null),
],
),
body: SingleChildScrollView(
child: Padding(
padding: EdgeInsets.all(20.0),
child: Column(
children: <Widget>[
Container(
height: 48.0,
child: ListView(
scrollDirection: Axis.horizontal,
children: <Widget>[
Tabs("All", true),
Tabs("Sneakers", false),
Tabs("Football", false),
Tabs("Soccer", false),
Tabs("Basketball", false),
Tabs("Tennis", false),
],
),
),
SizedBox(
height: 20.0,
),
Cards("red", "assets/images/red.jpg", false, "99"),
Cards("black", "assets/images/yellow.jpg", true, "89"),
Cards("blue", "assets/images/blue.jpg", false, "79"),
],
),
),
),
);
}
}
| 0
|
mirrored_repositories/shoes_shopping
|
mirrored_repositories/shoes_shopping/lib/cards.dart
|
import 'package:flutter/material.dart';
import 'package:shoe_shop/detail_page.dart';
class Cards extends StatefulWidget {
final String tag;
final String imageUrl;
final bool isFavoutrite;
final String cost;
Cards(
this.tag,
this.imageUrl,
this.isFavoutrite,
this.cost,
);
@override
_CardsState createState() => _CardsState();
}
class _CardsState extends State<Cards> {
@override
Widget build(BuildContext context) {
return Hero(
tag: widget.tag,
child: GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => DetailPage(
tag: widget.tag,
imageUrl: widget.imageUrl,
isFavoutrite: widget.isFavoutrite,
cost: widget.cost,
),
),
);
},
child: Container(
height: 250.0,
margin: EdgeInsets.only(bottom: 24.0),
padding: EdgeInsets.all(20.0),
width: double.infinity,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20.0),
image: DecorationImage(
image: AssetImage(widget.imageUrl), fit: BoxFit.cover),
boxShadow: [
BoxShadow(
color: Colors.grey[400],
blurRadius: 10,
offset: Offset(0, 10),
)
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
"Sneakers",
style: TextStyle(
color: Colors.white,
fontSize: 24.0,
fontWeight: FontWeight.bold,
),
),
SizedBox(
height: 10.0,
),
Text(
"NIKE",
style: TextStyle(
color: Colors.white,
fontSize: 16.0,
fontWeight: FontWeight.normal,
),
),
],
),
),
Container(
width: 40.0,
height: 40.0,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.white,
),
child: widget.isFavoutrite
? Icon(
Icons.favorite,
color: Colors.redAccent,
size: 25.0,
)
: Icon(
Icons.favorite_border,
color: Colors.redAccent,
size: 25.0,
),
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Text(
"\$ " + widget.cost,
style: TextStyle(
color: Colors.white,
fontSize: 36.0,
fontWeight: FontWeight.bold,
),
),
],
),
],
),
),
),
);
}
}
| 0
|
mirrored_repositories/shoes_shopping
|
mirrored_repositories/shoes_shopping/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:shoe_shop/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/netflix
|
mirrored_repositories/netflix/lib/main.dart
|
import 'package:flutter/material.dart';
import 'package:netflix/view/root_app/view/root_app_view.dart';
import 'core/init/theme/app_theme.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(
theme: AppTheme.instance.theme,
debugShowCheckedModeBanner: false,
home: const SafeArea(child: RootView()),
);
}
}
| 0
|
mirrored_repositories/netflix/lib/view/coming_soon
|
mirrored_repositories/netflix/lib/view/coming_soon/view/coming_soon_view.dart
|
// ignore_for_file: sized_box_for_whitespace
import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:netflix/core/base/view/base_view.dart';
import '../../../product/api/api_init.dart';
import '../../../product/widgets/coming_soon_widget.dart';
import '../../../product/widgets/helper.dart';
class ComingSoonView extends StatelessWidget {
const ComingSoonView({super.key});
@override
Widget build(BuildContext context) {
const String imageUrl = 'https://image.tmdb.org/t/p/w500';
var size = MediaQuery.of(context).size;
return Scaffold(
appBar: Helper.comingSoonAppBar,
backgroundColor: Colors.black,
body: BaseView<Api>(
viewModel: Api(),
onModelReady: (model) => model.init(),
onPageBuilder: (context, model) => Observer(
builder: (context) => model.loading
? const Center(child: CircularProgressIndicator())
: Container(
padding: const EdgeInsets.only(top: 20),
height: size.height,
child: ListView.builder(
itemBuilder: ((context, index) {
return ComingSoonWidget(
comingSoon: model.topratedmovies ?? [],
index: index,
);
}),
itemCount: model.topratedmovies?.length ?? 0,
),
),
),
),
);
}
}
| 0
|
mirrored_repositories/netflix/lib/view/video_details
|
mirrored_repositories/netflix/lib/view/video_details/view/video_details_movie.dart
|
// ignore_for_file: sized_box_for_whitespace, avoid_unnecessary_containers
import 'package:flutter/material.dart';
import 'package:netflix/core/extension/context_extension.dart';
import '../../../product/widgets/helper.dart';
class VideoDetailsMovieView extends StatelessWidget {
final String? image;
final String? title;
final String? detail;
final String? thdb;
const VideoDetailsMovieView(
{super.key,
required this.image,
required this.title,
required this.detail,
required this.thdb});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: Helper.detailsAppBar,
backgroundColor: Colors.black,
body: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
height: context.height * 0.3,
decoration: BoxDecoration(
image: DecorationImage(
image: NetworkImage(image ?? ""), fit: BoxFit.cover)),
),
SizedBox(
height: context.height * 0.03,
),
Padding(
padding: const EdgeInsets.only(
left: 15,
),
child: Text(
title ?? "",
style: const TextStyle(
height: 1.5,
fontSize: 25,
fontWeight: FontWeight.bold,
color: Colors.white),
),
),
SizedBox(
height: context.height * 0.02,
),
Padding(
padding: const EdgeInsets.only(
left: 15,
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Text(
"THDB $thdb",
style:
const TextStyle(color: Colors.grey, fontSize: 16),
),
SizedBox(
width: context.width * 0.04,
),
Container(
padding: const EdgeInsets.all(3.5),
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(3),
color: Colors.grey,
),
child: const Text(
"18+",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
),
SizedBox(
width: context.width * 0.04,
),
Container(
padding: const EdgeInsets.all(3.5),
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(3),
color: Colors.black,
border: Border.all(
color: Colors.grey,
),
),
child: const Text(
"HD",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
),
],
),
IconButton(
onPressed: () => null,
icon: const Icon(
Icons.add,
color: Colors.white,
),
)
],
),
),
SizedBox(
height: context.height * 0.01,
),
Padding(
padding: const EdgeInsets.only(left: 15),
child: Text(detail ?? "")),
SizedBox(
height: context.height * 0.01,
),
],
),
),
);
}
}
| 0
|
mirrored_repositories/netflix/lib/view/root_app
|
mirrored_repositories/netflix/lib/view/root_app/view/root_app_view.dart
|
import 'package:flutter/material.dart';
import '../../../product/uitlity/root_app_icons.dart';
import '../../../product/widgets/helper.dart';
class RootView extends StatefulWidget {
const RootView({super.key});
@override
State<RootView> createState() => _RootViewState();
}
class _RootViewState extends State<RootView> {
int selectedIndex = 0;
void onChange(int value) {
setState(() {
selectedIndex = value;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: screens[selectedIndex],
backgroundColor: Colors.black,
bottomNavigationBar: BottomNavigationBar(
type: BottomNavigationBarType.fixed,
currentIndex: selectedIndex,
backgroundColor: Colors.black,
unselectedLabelStyle: const TextStyle(color: Colors.white),
unselectedIconTheme: const IconThemeData(
color: Colors.white,
),
unselectedItemColor: Colors.white,
selectedItemColor: const Color(0xffcc2b5e),
selectedIconTheme: const IconThemeData(
color: Color(0xffcc2b5e),
),
selectedLabelStyle: const TextStyle(color: Color(0xffcc2b5e)),
items: <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(
items[0]["icon"],
),
label: items[0]["text"],
),
BottomNavigationBarItem(
icon: Icon(
items[1]["icon"],
),
label: items[1]["text"],
),
BottomNavigationBarItem(
icon: Icon(
items[2]["icon"],
),
label: items[2]["text"],
),
BottomNavigationBarItem(
icon: Icon(
items[3]["icon"],
),
label: items[3]["text"],
)
],
onTap: (value) {
onChange(value);
},
),
);
}
}
| 0
|
mirrored_repositories/netflix/lib/view/home_films
|
mirrored_repositories/netflix/lib/view/home_films/view/home_tv_view.dart
|
// ignore_for_file: sized_box_for_whitespace
import 'package:flutter/material.dart';
import 'package:netflix/core/extension/context_extension.dart';
import '../../video_details/view/video_details_movie.dart';
class HomeTvView extends StatelessWidget {
final String label;
final List filmList;
const HomeTvView({super.key, required this.label, required this.filmList});
@override
Widget build(BuildContext context) {
const String imageUrl = 'https://image.tmdb.org/t/p/w500';
return Container(
width: context.width,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(left: 15, bottom: 10),
child: Text(
label,
style: const TextStyle(
color: Colors.white,
fontSize: 17,
fontWeight: FontWeight.w600,
),
),
),
Padding(
padding: const EdgeInsets.only(left: 15),
child: Container(
height: context.height * 0.3,
width: MediaQuery.of(context).size.width,
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemBuilder: ((context, index) {
return InkWell(
onTap: () {
Navigator.push(context,
MaterialPageRoute(builder: ((context) {
return VideoDetailsMovieView(
image: imageUrl + filmList[index]["backdrop_path"],
title: filmList[index]["original_name"],
detail: filmList[index]["overview"],
thdb: filmList[index]["vote_average"].toString(),
);
})));
},
child: Padding(
padding: const EdgeInsets.only(right: 10),
child: Container(
height: context.height * 0.3,
width: context.height * 0.3,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
image: DecorationImage(
image: NetworkImage(
imageUrl + filmList[index]["backdrop_path"],
),
fit: BoxFit.fitHeight,
),
),
),
),
);
}),
itemCount: filmList.length,
),
),
),
SizedBox(
height: context.height * 0.1,
)
],
),
);
}
}
| 0
|
mirrored_repositories/netflix/lib/view/home_films
|
mirrored_repositories/netflix/lib/view/home_films/view/home_films_view.dart
|
// ignore_for_file: sized_box_for_whitespace
import 'package:flutter/material.dart';
import 'package:netflix/core/extension/context_extension.dart';
import '../../video_details/view/video_details_movie.dart';
class HomeFilmsView extends StatelessWidget {
final String label;
final List filmList;
const HomeFilmsView({super.key, required this.label, required this.filmList});
@override
Widget build(BuildContext context) {
const String imageUrl = 'https://image.tmdb.org/t/p/w500';
return Container(
width: context.width,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(left: 15, bottom: 10),
child: Text(
label,
style: const TextStyle(
color: Colors.white,
fontSize: 17,
fontWeight: FontWeight.w600,
),
),
),
Padding(
padding: const EdgeInsets.only(left: 15),
child: Container(
height: context.height * 0.3,
width: MediaQuery.of(context).size.width,
child: ListView.builder(
shrinkWrap: true,
scrollDirection: Axis.horizontal,
itemBuilder: ((context, index) {
return InkWell(
onTap: () {
Navigator.push(context,
MaterialPageRoute(builder: ((context) {
return VideoDetailsMovieView(
image: imageUrl + filmList[index]["backdrop_path"],
title: filmList[index]["title"],
detail: filmList[index]["overview"],
thdb: filmList[index]["vote_average"].toString(),
);
})));
},
child: Padding(
padding: const EdgeInsets.only(right: 10),
child: Container(
height: context.height * 0.3,
width: context.height * 0.3,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
image: DecorationImage(
alignment: Alignment.center,
image: NetworkImage(
imageUrl + filmList[index]["backdrop_path"],
),
fit: BoxFit.fitHeight,
),
),
),
),
);
}),
itemCount: filmList.length,
),
),
),
SizedBox(
height: context.height * 0.1,
)
],
),
);
}
}
| 0
|
mirrored_repositories/netflix/lib/view/download
|
mirrored_repositories/netflix/lib/view/download/view/download_view.dart
|
// ignore_for_file: sized_box_for_whitespace
import 'package:flutter/material.dart';
import 'package:netflix/core/extension/context_extension.dart';
import 'package:netflix/view/root_app/view/root_app_view.dart';
import '../../../product/widgets/helper.dart';
class DownloadView extends StatelessWidget {
const DownloadView({super.key});
@override
Widget build(BuildContext context) {
var size = MediaQuery.of(context).size;
return Scaffold(
backgroundColor: Colors.black,
appBar: Helper.downloadAppBar,
body: Container(
height: size.height,
width: size.width,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SizedBox(
height: context.height * 0.01,
),
Container(
height: context.height * 0.1,
width: size.width,
decoration: const BoxDecoration(
color: Color.fromARGB(163, 66, 64, 64),
),
child: Helper.downloadBar,
),
SizedBox(
height: size.height * 0.1,
),
Container(
padding: const EdgeInsets.all(35),
decoration: const BoxDecoration(
color: Color.fromARGB(163, 66, 64, 64),
shape: BoxShape.circle),
child: const Icon(
Icons.download,
size: 90,
color: Color.fromARGB(161, 153, 148, 148),
),
),
SizedBox(
height: context.height * 0.03,
),
const Text(
"Never be without Netflix",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 20),
),
SizedBox(
height: context.height * 0.03,
),
const Padding(
padding: EdgeInsets.only(right: 40, left: 40),
child: Text(
"Download shows and movies so you'll never be without something to watch even when you're offline",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w400,
fontSize: 18,
),
textAlign: TextAlign.center,
),
),
SizedBox(
height: context.height * 0.02,
),
GestureDetector(
onTap: (() {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: ((context) {
return const RootView();
}),
),
);
}),
child: Container(
padding: const EdgeInsets.all(15),
alignment: Alignment.center,
width: size.width * 0.8,
color: Colors.white,
child: const Text(
"See What You Can Download",
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.black,
fontSize: 18),
),
),
),
const Spacer()
],
),
),
);
}
}
| 0
|
mirrored_repositories/netflix/lib/view/home_play
|
mirrored_repositories/netflix/lib/view/home_play/view/home_play_view.dart
|
import 'package:flutter/material.dart';
import 'package:netflix/core/base/view/base_view.dart';
import 'package:netflix/core/extension/context_extension.dart';
import 'package:netflix/view/video_details/view/video_details_movie.dart';
import '../../../product/api/api_init.dart';
class HomePlayView extends StatelessWidget {
const HomePlayView({super.key});
@override
Widget build(BuildContext context) {
const String imageUrl = 'https://image.tmdb.org/t/p/w500';
return BaseView<Api>(
onModelReady: (model) {
model.init();
},
viewModel: Api(),
onPageBuilder: (context, model) => Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Column(
children: [
const Icon(
Icons.add,
color: Colors.white,
),
SizedBox(
height: context.height * 0.01,
),
const Text(
"My List",
style: TextStyle(
color: Colors.white,
fontSize: 17,
fontWeight: FontWeight.w600),
),
],
),
GestureDetector(
onTap: (() {
Navigator.push(
context,
MaterialPageRoute(
builder: ((context) {
return VideoDetailsMovieView(
image: imageUrl +
model.trendingmovies?.first["backdrop_path"],
title: model.trendingmovies?.first["title"],
detail: model.trendingmovies?.first["overview"],
thdb: model.trendingmovies?.first["vote_average"]
.toString(),
);
}),
),
);
}),
child: Container(
padding:
const EdgeInsets.only(top: 5, bottom: 5, left: 5, right: 10),
decoration: BoxDecoration(
color: Colors.white, borderRadius: BorderRadius.circular(5)),
child: Row(
children: const [
Icon(
Icons.play_arrow,
color: Colors.black,
size: 27,
),
SizedBox(
width: 5,
),
Text(
"Play",
style: TextStyle(
color: Colors.black,
fontSize: 16,
fontWeight: FontWeight.w600),
),
],
),
),
),
Column(
children: const [
Icon(
Icons.info_outline,
color: Colors.white,
),
SizedBox(
height: 5,
),
Text(
"My List",
style: TextStyle(
color: Colors.white,
fontSize: 17,
fontWeight: FontWeight.w600),
),
],
),
],
),
);
}
}
| 0
|
mirrored_repositories/netflix/lib/view/home
|
mirrored_repositories/netflix/lib/view/home/view/home_view.dart
|
import 'package:flutter/material.dart';
import 'package:netflix/core/base/view/base_view.dart';
import 'package:netflix/core/extension/context_extension.dart';
import 'package:netflix/view/home_play/view/home_play_view.dart';
import '../../../product/api/api_init.dart';
import '../../../product/widgets/home_category.dart';
import '../../../product/widgets/home_label.dart';
import '../../../product/widgets/homepage_appbar.dart';
import '../../home_films/view/home_films_view.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import '../../home_films/view/home_tv_view.dart';
class HomeView extends StatelessWidget {
const HomeView({super.key});
@override
Widget build(BuildContext context) {
const String imageUrl = 'https://image.tmdb.org/t/p/w500';
return BaseView<Api>(
viewModel: Api(),
onModelReady: (model) {
model.setContext(context);
model.init();
},
onPageBuilder: (context, model) => Observer(builder: (_) {
return model.loading
? const Center(child: CircularProgressIndicator())
: Scaffold(
backgroundColor: Colors.black,
body: SingleChildScrollView(
child: Column(
children: [
Container(
height: context.height * 0.65,
decoration: BoxDecoration(
image: DecorationImage(
image: NetworkImage(imageUrl +
model.trendingmovies
?.first['poster_path']),
fit: BoxFit.cover),
),
child: Stack(
children: [
Container(
height: context.height * 0.65,
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
Colors.black.withOpacity(0.5),
Colors.black.withOpacity(0.1),
],
begin: Alignment.bottomCenter,
end: Alignment.topCenter),
),
),
Column(
children: [
const HomePageAppBar(),
const HomeCategory(),
HomeLabel(
title: model.trendingmovies
?.first['title'] ??
"",
),
const HomePlayView(),
],
)
],
),
),
SizedBox(
height: context.height * 0.05,
),
HomeFilmsView(
label: "Popular Now",
filmList: model.topratedmovies ?? [],
),
HomeFilmsView(
label: "Trending Now",
filmList: model.trendingmovies ?? [],
),
HomeTvView(
label: "Netflix Originals",
filmList: model.tvEpisodes ?? [],
),
],
),
),
);
}));
}
}
| 0
|
mirrored_repositories/netflix/lib/view/search
|
mirrored_repositories/netflix/lib/view/search/view/search_view.dart
|
// ignore_for_file: sized_box_for_whitespace
import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:netflix/core/base/view/base_view.dart';
import 'package:netflix/core/extension/context_extension.dart';
import 'package:netflix/product/api/api_init.dart';
import 'package:netflix/view/video_details/view/video_details_movie.dart';
import '../../../product/widgets/searchbar.dart';
import '../../../product/widgets/searched_item.dart';
class SearchView extends StatelessWidget {
const SearchView({super.key});
@override
Widget build(BuildContext context) {
const String imageUrl = 'https://image.tmdb.org/t/p/w500';
return SafeArea(
child: Scaffold(
backgroundColor: Colors.black,
body: BaseView<Api>(
viewModel: Api(),
onModelReady: (model) => model.init(),
onPageBuilder: (context, model) => Observer(
builder: (context) => Container(
height: context.height,
width: context.width,
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: context.height * 0.04,
),
Padding(
padding: const EdgeInsets.only(left: 20),
child: SearchBar(
onChanged: (query) =>
model.filterTopRatedMovies(query),
),
),
const Padding(
padding: EdgeInsets.only(left: 20, top: 20, bottom: 30),
child: Text(
"Top Searches",
style: TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.bold),
),
),
SizedBox(
width: context.width,
height: context.height * 0.9,
child: ListView.builder(
shrinkWrap: true,
itemCount: model.topratedmoviesSearch?.length ?? 0,
itemBuilder: (context, index) => GestureDetector(
onTap: (() {
Navigator.push(
context,
MaterialPageRoute(
builder: ((context) {
return VideoDetailsMovieView(
image: (imageUrl +
model.topratedmoviesSearch?[index]
["poster_path"]),
title: model.topratedmoviesSearch?[index]
['original_title'] ??
"",
detail: model.topratedmoviesSearch?[index]
['overview'] ??
"",
thdb: model.topratedmoviesSearch?[index]
['vote_average']
.toString() ??
"",
);
}),
),
);
}),
child: SearchedItems(
searched: model.topratedmoviesSearch,
index: index,
),
),
),
),
SizedBox(
height: context.height * 0.1,
)
],
),
),
),
),
)),
);
}
}
| 0
|
mirrored_repositories/netflix/lib/core
|
mirrored_repositories/netflix/lib/core/constants/color_constants.dart
|
import 'package:flutter/material.dart';
@immutable
class ColorConstants {
const ColorConstants._();
static const Color red = Color.fromRGBO(229, 9, 20, 1);
static const Color white = Color.fromRGBO(255, 255, 255, 1);
static const Color black = Color.fromRGBO(20, 20, 20, 1);
}
| 0
|
mirrored_repositories/netflix/lib/core/constants
|
mirrored_repositories/netflix/lib/core/constants/app/app_constants.dart
|
// ignore_for_file: constant_identifier_names
class ApplicationConstants {
static const COMPANY_NAME = 'sahinsoftware';
static const APPLICATION_NAME = 'benimokulum';
static const APPLICATION_VERSION = '1.0.0';
// production'da olmadığımız sürece çalışmasını istemediğimiz fonksiyonlar için kullanacağız
static const TEST_MODE = false;
//paths
static const LANG_ASSET_PATH = 'assets/translations';
static const IMAGES_ASSET_PATH = 'assets/images';
static const FONTS_OPENSANS_ASSET_PATH = 'assets/fonts/OpenSans';
static const DATABASE_NAME_LESSON = "lesson";
static const DATABASE_NAME_LECTURER = "lecturer";
static const DATABASE_NAME_HOMEWORK = "homework";
static const DATABASE_NAME_SUBJECT = "subject";
static const DATABASE_NAME_TASK = "task";
static const DATABASE_NAME_PROFILE = "profile";
static const String FONT_FAMILY = 'Poppins'; //OpenSans
}
| 0
|
mirrored_repositories/netflix/lib/core/constants
|
mirrored_repositories/netflix/lib/core/constants/app/app_duration.dart
|
class DurationManager {
DurationManager._init();
static DurationManager? _instance;
static DurationManager get instance {
_instance ??= DurationManager._init();
return _instance!;
}
Duration get lowDuration => const Duration(milliseconds: 500);
Duration get normalDuration => const Duration(seconds: 1);
}
| 0
|
mirrored_repositories/netflix/lib/core/constants
|
mirrored_repositories/netflix/lib/core/constants/enums/image_enums.dart
|
enum ImageTypes { ASSET, FILE }
enum ListTileTypes{IMAGE,NAME}
| 0
|
mirrored_repositories/netflix/lib/core/constants
|
mirrored_repositories/netflix/lib/core/constants/enums/preferences_keys.dart
|
enum PreferencesKeys { TOKEN, IS_FIRST_APP }
| 0
|
mirrored_repositories/netflix/lib/core/constants
|
mirrored_repositories/netflix/lib/core/constants/enums/theme_enums.dart
|
enum AppThemes { LIGHT, DARK }
| 0
|
mirrored_repositories/netflix/lib/core/constants
|
mirrored_repositories/netflix/lib/core/constants/api/api_constants.dart
|
class ApiConstants {
static const String apikey = '';
static const String readaccesstoken =
'';
}
| 0
|
mirrored_repositories/netflix/lib/core/constants
|
mirrored_repositories/netflix/lib/core/constants/navigation/navigation_constants.dart
|
// ignore_for_file: constant_identifier_names
class NavigationConstants {
static const TEST_VIEW = '/test';
static const DEFAULT = '/';
static const ADD_TASK = '/addTask';
static const ADD_SUBJECT = '/addSubject';
static const ADD_LECTURER = '/addLecturer';
static const LECTURERS = '/Lecturers';
static const SUBJECTS = '/Subjects';
static const EDIT_PROFILE = '/EditProfile';
}
| 0
|
mirrored_repositories/netflix/lib/core/constants
|
mirrored_repositories/netflix/lib/core/constants/image/image_constants.dart
|
class ImageConstants {
ImageConstants._init();
static ImageConstants? _instace;
static ImageConstants get instance => _instace ??= ImageConstants._init();
// String get logo => toPng('veli');
// String get hotDog => toPng('hotdogs');
// String get projeIcon => toPng('cirlce_hwa');
String get notFound => toSVG('not_found');
//String get user => toPng('user');
String get men => toPng('men');
String get woman => toPng('woman');
String get face => toPng('face');
String get empty => toPng('empty');
String get files => toPng('files');
String toPng(String name) => 'assets/images/$name.png';
String toSVG(String name) => 'assets/images/$name.svg';
}
| 0
|
mirrored_repositories/netflix/lib/core/init
|
mirrored_repositories/netflix/lib/core/init/cache/shared_preferences.dart
|
import 'package:shared_preferences/shared_preferences.dart';
import '../../constants/enums/preferences_keys.dart';
class LocaleManager {
LocaleManager._init() {
SharedPreferences.getInstance().then((value) {
_preferences = value;
});
}
static final LocaleManager _instance = LocaleManager._init();
SharedPreferences? _preferences;
static LocaleManager get instance => _instance;
static Future prefrencesInit() async {
instance._preferences ??= await SharedPreferences.getInstance();
}
Future<void> clearAll() async {
await _preferences!.clear();
}
Future<void> clearAllSaveFirst() async {
if (_preferences != null) {
await _preferences!.clear();
await setBoolValue(PreferencesKeys.IS_FIRST_APP, true);
}
}
Future<void> setStringValue(PreferencesKeys key, String value) async {
await _preferences!.setString(key.toString(), value);
}
Future<void> setBoolValue(PreferencesKeys key, bool value) async {
await _preferences!.setBool(key.toString(), value);
}
String getStringValue(PreferencesKeys key) => _preferences?.getString(key.toString()) ?? '';
bool getBoolValue(PreferencesKeys key) => _preferences!.getBool(key.toString()) ?? false;
}
| 0
|
mirrored_repositories/netflix/lib/core/init
|
mirrored_repositories/netflix/lib/core/init/language/language_keys.g.dart
|
// DO NOT EDIT. This is code generated via package:easy_localization/generate.dart
abstract class LocaleKeys {
static const page_not_found = 'page_not_found';
static const page_go_back = 'page_go_back';
static const bottom_main = 'bottom_main';
static const bottom_homework = 'bottom_homework';
static const bottom_add = 'bottom_add';
static const bottom_calendar = 'bottom_calendar';
static const bottom_profile = 'bottom_profile';
static const home_status = 'home_status';
static const home_homework = 'home_homework';
static const home_today = 'home_today';
static const home_chart_1 = 'home_chart_1';
static const home_chart_2 = 'home_chart_2';
static const home_chart_3 = 'home_chart_3';
static const home_chart_4 = 'home_chart_4';
static const profile_click_and_share = 'profile_click_and_share';
static const profile_share = 'profile_share';
static const profile_share_insgiht = 'profile_share_insgiht';
static const add_timeline_lesson = 'add_timeline_lesson';
static const add_timeline_write_lesson = 'add_timeline_write_lesson';
static const add_timeline_day = 'add_timeline_day';
static const add_timeline_time = 'add_timeline_time';
static const add_timeline_start_end = 'add_timeline_start_end';
static const add_timeline_location = 'add_timeline_location';
static const add_timeline_write_location = 'add_timeline_write_location';
static const add_task_add_task = 'add_task_add_task';
static const add_task_title = 'add_task_title';
static const add_task_write_subject_title = 'add_task_write_subject_title';
static const add_task_description = 'add_task_description';
static const add_task_write_some_description = 'add_task_write_some_description';
static const add_task_date_time = 'add_task_date_time';
static const add_task_pick_date = 'add_task_pick_date';
static const add_task_set_time = 'add_task_set_time';
static const add_task_subject = 'add_task_subject';
static const add_task_write_subject = 'add_task_write_subject';
static const add_subject_add_subject = 'add_subject_add_subject';
static const add_subject_lectures = 'add_subject_lectures';
static const add_subject_title = 'add_subject_title';
static const add_subject_write_subject_title = 'add_subject_write_subject_title';
static const add_subject_description = 'add_subject_description';
static const add_subject_write_some_description = 'add_subject_write_some_description';
static const add_subject_pick_a_color = 'add_subject_pick_a_color';
static const add_lecturer_add_lecturer = 'add_lecturer_add_lecturer';
static const add_lecturer_name = 'add_lecturer_name';
static const add_lecturer_write_lecturer_name = 'add_lecturer_write_lecturer_name';
static const add_lecturer_email = 'add_lecturer_email';
static const add_lecturer_write_email_address = 'add_lecturer_write_email_address';
static const add_lecturer_description = 'add_lecturer_description';
static const add_lecturer_write_some_description = 'add_lecturer_write_some_description';
static const monday = 'monday';
static const tuesday = 'tuesday';
static const wednesday = 'wednesday';
static const thursday = 'thursday';
static const friday = 'friday';
static const saturday = 'saturday';
static const sunday = 'sunday';
static const ok = 'ok';
static const cancel = 'cancel';
static const save = 'save';
static const list_is_empty = 'list_is_empty';
}
| 0
|
mirrored_repositories/netflix/lib/core/init
|
mirrored_repositories/netflix/lib/core/init/language/language_manager.dart
|
import 'package:flutter/material.dart';
class LanguageManager {
LanguageManager._init();
static LanguageManager? _instance;
static LanguageManager get instance {
_instance ??= LanguageManager._init();
return _instance!;
}
final enLocale = const Locale('en', 'US');
final trLocale = const Locale('tr', 'TR');
List<Locale> get supportedLocales => [enLocale, trLocale];
}
| 0
|
mirrored_repositories/netflix/lib/core/init
|
mirrored_repositories/netflix/lib/core/init/theme/app_theme.dart
|
import 'package:flutter/material.dart';
import 'theme_data.dart';
class AppTheme {
AppTheme._init();
static AppTheme? _instance;
static AppTheme get instance {
_instance ??= AppTheme._init();
return _instance!;
}
ThemeData theme = appTheme;
}
| 0
|
mirrored_repositories/netflix/lib/core/init
|
mirrored_repositories/netflix/lib/core/init/theme/theme_data.dart
|
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:netflix/core/constants/color_constants.dart';
import '../../constants/app/app_constants.dart';
ThemeData get appTheme => ThemeData(
useMaterial3: true,
textTheme:
GoogleFonts.latoTextTheme().apply(bodyColor: ColorConstants.white),
scaffoldBackgroundColor: ColorConstants.black,
iconTheme: iconThemeData,
appBarTheme: appBarTheme,
elevatedButtonTheme: elevatedButtonThemeData,
inputDecorationTheme: inputDecorationTheme,
navigationBarTheme: navigationBarThemeData);
ElevatedButtonThemeData get elevatedButtonThemeData {
return const ElevatedButtonThemeData(
style: ButtonStyle(
elevation: MaterialStatePropertyAll(0),
fixedSize: MaterialStatePropertyAll(Size(500, 55)),
textStyle: MaterialStatePropertyAll(TextStyle(
color: ColorConstants.white,
fontSize: 12,
fontWeight: FontWeight.normal,
wordSpacing: 0.4)),
backgroundColor: MaterialStatePropertyAll(ColorConstants.red),
foregroundColor: MaterialStatePropertyAll(ColorConstants.white)));
}
InputDecorationTheme get inputDecorationTheme {
const outlineInputBorder =
OutlineInputBorder(borderSide: BorderSide(color: ColorConstants.white));
return const InputDecorationTheme(
fillColor: ColorConstants.black,
iconColor: ColorConstants.white,
focusColor: ColorConstants.black,
hoverColor: ColorConstants.black,
prefixIconColor: ColorConstants.white,
suffixIconColor: ColorConstants.white,
enabledBorder: outlineInputBorder,
border: outlineInputBorder,
focusedBorder: outlineInputBorder,
disabledBorder: outlineInputBorder,
hintStyle: TextStyle(
color: ColorConstants.white,
fontSize: 12,
fontWeight: FontWeight.normal,
wordSpacing: 0.4),
labelStyle: TextStyle(
color: ColorConstants.white,
fontSize: 12,
fontWeight: FontWeight.normal,
wordSpacing: 0.4));
}
IconThemeData get iconThemeData {
return const IconThemeData(size: 24, color: ColorConstants.white);
}
AppBarTheme get appBarTheme {
return const AppBarTheme(
/*
systemOverlayStyle: const SystemUiOverlayStyle(
statusBarColor: Color.fromRGBO(245, 245, 245, 1),
statusBarIconBrightness: Brightness.dark,
statusBarBrightness: Brightness.light,
/* systemNavigationBarColor: Color(0xFFF8FDFF),
systemNavigationBarIconBrightness: Brightness.dark,
systemNavigationBarDividerColor: Color(0xFFF8FDFF),
systemNavigationBarContrastEnforced: true,
systemStatusBarContrastEnforced: true*/
),*/
iconTheme: IconThemeData(color: ColorConstants.white, size: 24),
actionsIconTheme: IconThemeData(color: ColorConstants.white, size: 30),
foregroundColor: ColorConstants.red,
toolbarHeight: 64,
scrolledUnderElevation: 2,
elevation: 0,
centerTitle: true,
backgroundColor: ColorConstants.black,
//color: const Color.fromRGBO(245, 245, 245, 1),
//surfaceTintColor: const Color.fromRGBO(245, 245, 245, 1),
//foregroundColor:const Color.fromRGBO(245, 245, 245, 1),
);
}
NavigationBarThemeData get navigationBarThemeData {
return NavigationBarThemeData(
height: 80,
indicatorColor: ColorConstants.black,
labelTextStyle: MaterialStateProperty.all(const TextStyle(
fontFamily: ApplicationConstants.FONT_FAMILY,
fontSize: 12,
fontWeight: FontWeight.w500,
color: ColorConstants.white,
)),
elevation: 2,
iconTheme: MaterialStateProperty.all(const IconThemeData(size: 24)),
);
}
| 0
|
mirrored_repositories/netflix/lib/core/init
|
mirrored_repositories/netflix/lib/core/init/navigation/INavigationService.dart
|
abstract class INavigationService {
Future<void> navigateToPage({String? path, Object? data});
Future<void> navigateToPageClear({String? path, Object? data});
}
| 0
|
mirrored_repositories/netflix/lib/core/init
|
mirrored_repositories/netflix/lib/core/init/navigation/navigation_service.dart
|
// ignore_for_file: prefer_function_declarations_over_variables
import 'package:flutter/material.dart';
import 'package:netflix/core/init/navigation/INavigationService.dart';
class NavigationService implements INavigationService {
NavigationService._init();
static final NavigationService _instance = NavigationService._init();
static NavigationService get instance => _instance;
GlobalKey<NavigatorState> navigatorKey = GlobalKey();
final removeAllOldRoutes = (Route<dynamic> route) => false;
@override
Future<void> navigateToPage({String? path, Object? data}) async {
await navigatorKey.currentState!.pushNamed(path!, arguments: data);
}
@override
Future<void> navigateToPageClear({String? path, Object? data}) async {
await navigatorKey.currentState!.pushNamedAndRemoveUntil(path!, removeAllOldRoutes, arguments: data);
}
}
| 0
|
mirrored_repositories/netflix/lib/core/init
|
mirrored_repositories/netflix/lib/core/init/navigation/navigation_route.dart
|
import 'package:flutter/material.dart';
import '../../constants/navigation/navigation_constants.dart';
class NavigationRoute {
NavigationRoute._init();
static final NavigationRoute _instance = NavigationRoute._init();
static NavigationRoute get instance => _instance;
Route<dynamic> generateRoute(RouteSettings args) {
switch (args.name) {
/*
case NavigationConstants.ADD_TASK:
return normalNavigate(const AddTaskView(), NavigationConstants.ADD_TASK);
case NavigationConstants.ADD_SUBJECT:
return normalNavigate(AddSubjectView(), NavigationConstants.ADD_SUBJECT);
case NavigationConstants.ADD_LECTURER:
return normalNavigate(AddLecturerView(), NavigationConstants.ADD_LECTURER);
case NavigationConstants.LECTURERS:
return normalNavigate(const LecturersView(), NavigationConstants.LECTURERS);
case NavigationConstants.SUBJECTS:
return normalNavigate(const SubjectView(), NavigationConstants.SUBJECTS);
case NavigationConstants.EDIT_PROFILE:
return normalNavigate(const EditProfileView(), NavigationConstants.EDIT_PROFILE);
*/
// case NavigationConstants.SETTINGS_WEB_VIEW:
// if (args.arguments is SettingsDynamicModel) {
// return normalNavigate(
// SettingsDynamicView(model: args.arguments as SettingsDynamicModel),
// NavigationConstants.SETTINGS_WEB_VIEW,
// );
// }
// throw NavigateException<SettingsDynamicModel>(args.arguments);
default:
return MaterialPageRoute(builder: (context) => Placeholder());
}
}
MaterialPageRoute normalNavigate(Widget widget, String pageName) {
return MaterialPageRoute(
builder: (context) => widget,
//analytciste görülecek olan sayfa ismi için pageName veriyoruz
settings: RouteSettings(name: pageName),
);
}
}
| 0
|
mirrored_repositories/netflix/lib/core
|
mirrored_repositories/netflix/lib/core/extension/context_extension.dart
|
import 'dart:math';
import 'package:flutter/material.dart';
import '../init/theme/app_theme.dart';
extension ContextExtension on BuildContext {
MediaQueryData get mediaQuery => MediaQuery.of(this);
}
extension MediaQueryExtension on BuildContext {
double get height => mediaQuery.size.height;
double get width => mediaQuery.size.width;
double get lowValue => height * 0.01;
double get normalValue => height * 0.02;
double get mediumValue => height * 0.04;
double get highValue => height * 0.1;
}
extension ThemeExtension on BuildContext {
ThemeData get theme => AppTheme.instance.theme;
ColorScheme get colors => theme.colorScheme;
TextTheme get textTheme => theme.textTheme.copyWith(
bodySmall: const TextStyle(
fontSize: 12, fontWeight: FontWeight.normal, wordSpacing: 0.4),
bodyMedium: const TextStyle(
fontSize: 14, fontWeight: FontWeight.normal, wordSpacing: 0.25),
bodyLarge: const TextStyle(
fontSize: 16, fontWeight: FontWeight.normal, wordSpacing: 0.5),
labelSmall: const TextStyle(
fontSize: 11, fontWeight: FontWeight.w200, wordSpacing: 0.5),
labelMedium: const TextStyle(
fontSize: 12, fontWeight: FontWeight.w200, wordSpacing: 0.5),
labelLarge: const TextStyle(
fontSize: 14, fontWeight: FontWeight.normal, wordSpacing: 0),
titleSmall: const TextStyle(
fontSize: 14, fontWeight: FontWeight.w200, wordSpacing: 0.1),
titleMedium: const TextStyle(
fontSize: 16, fontWeight: FontWeight.w200, wordSpacing: 0.15),
titleLarge: const TextStyle(
fontSize: 22, fontWeight: FontWeight.w200, wordSpacing: 0),
headlineSmall: const TextStyle(
fontSize: 24, fontWeight: FontWeight.normal, wordSpacing: 0),
headlineMedium: const TextStyle(
fontSize: 28, fontWeight: FontWeight.normal, wordSpacing: 0.5),
headlineLarge: const TextStyle(
fontSize: 32, fontWeight: FontWeight.normal, wordSpacing: 0),
);
}
extension PaddingExtensionAll on BuildContext {
EdgeInsets get paddingLow => EdgeInsets.all(lowValue);
EdgeInsets get paddingNormal => EdgeInsets.all(normalValue);
EdgeInsets get paddingMedium => EdgeInsets.all(mediumValue);
EdgeInsets get paddingHigh => EdgeInsets.all(highValue);
}
extension PaddingExtensionSymetric on BuildContext {
EdgeInsets get paddingLowVertical => EdgeInsets.symmetric(vertical: lowValue);
EdgeInsets get paddingNormalVertical =>
EdgeInsets.symmetric(vertical: normalValue);
EdgeInsets get paddingMediumVertical =>
EdgeInsets.symmetric(vertical: mediumValue);
EdgeInsets get paddingHighVertical =>
EdgeInsets.symmetric(vertical: highValue);
EdgeInsets get paddingLowHorizontal =>
EdgeInsets.symmetric(horizontal: lowValue);
EdgeInsets get paddingNormalHorizontal =>
EdgeInsets.symmetric(horizontal: normalValue);
EdgeInsets get paddingMediumHorizontal =>
EdgeInsets.symmetric(horizontal: mediumValue);
EdgeInsets get paddingHighHorizontal =>
EdgeInsets.symmetric(horizontal: highValue);
}
extension PageExtension on BuildContext {
Color get randomColor => Colors.primaries[Random().nextInt(17)];
}
extension DurationExtension on BuildContext {
Duration get lowDuration => const Duration(milliseconds: 500);
Duration get normalDuration => const Duration(seconds: 1);
}
| 0
|
mirrored_repositories/netflix/lib/core
|
mirrored_repositories/netflix/lib/core/extension/int_extension.dart
|
extension IntUtils on int {
String get weekdayToAbbreviatedString {
switch (this) {
case DateTime.monday:
return "Mo";
case DateTime.tuesday:
return "Tu";
case DateTime.wednesday:
return "We";
case DateTime.thursday:
return "Th";
case DateTime.friday:
return "Fr";
case DateTime.saturday:
return "Sa";
case DateTime.sunday:
return "Su";
default:
return "Su";
}
}
}
| 0
|
mirrored_repositories/netflix/lib/core
|
mirrored_repositories/netflix/lib/core/extension/date_extension.dart
|
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
enum TimeStampFormat { parse_12, parse_24 }
extension DateUtils on DateTime {
String get monthToFullString {
switch (month) {
case DateTime.january:
return "January";
case DateTime.february:
return "February ";
case DateTime.march:
return "March ";
case DateTime.april:
return "April ";
case DateTime.may:
return "May ";
case DateTime.june:
return "June ";
case DateTime.july:
return "July ";
case DateTime.august:
return "August ";
case DateTime.september:
return "September";
case DateTime.october:
return "October ";
case DateTime.november:
return "November ";
case DateTime.december:
return "December ";
default:
return "Error";
}
}
String get weekdayToFullString {
switch (weekday) {
case DateTime.monday:
return "Monday";
case DateTime.tuesday:
return "Tuesday";
case DateTime.wednesday:
return "Wednesday";
case DateTime.thursday:
return "Thursday";
case DateTime.friday:
return "Friday";
case DateTime.saturday:
return "Saturday";
case DateTime.sunday:
return "Sunday";
default:
return "Error";
}
}
String get weekdayToAbbreviatedString {
switch (weekday) {
case DateTime.monday:
return "Mo";
case DateTime.tuesday:
return "Tu";
case DateTime.wednesday:
return "We";
case DateTime.thursday:
return "Th";
case DateTime.friday:
return "Fr";
case DateTime.saturday:
return "Sa";
case DateTime.sunday:
return "Su";
default:
return "Err";
}
}
int get totalMinutes => hour * 60 + minute;
TimeOfDay get timeOfDay => TimeOfDay(hour: hour, minute: minute);
DateTime copyWith({
int? year,
int? month,
int? day,
int? hour,
int? minute,
int? second,
int? millisecond,
int? microsecond,
}) =>
DateTime(
year ?? this.year,
month ?? this.month,
day ?? this.day,
hour ?? this.hour,
minute ?? this.minute,
second ?? this.second,
millisecond ?? this.millisecond,
microsecond ?? this.microsecond,
);
String dateToStringWithFormat({String format = 'y-M-d'}) {
return DateFormat(format).format(this);
}
DateTime stringToDateWithFormat({
required String format,
required String dateString,
}) =>
DateFormat(format).parse(dateString);
String getTimeInFormat(TimeStampFormat format) => DateFormat('h:mm${format == TimeStampFormat.parse_12 ? " a" : ""}').format(this).toUpperCase();
bool compareWithoutTime(DateTime date) => day == date.day && month == date.month && year == date.year;
bool compareTime(DateTime date) => hour == date.hour && minute == date.minute && second == date.second;
}
| 0
|
mirrored_repositories/netflix/lib/core/base
|
mirrored_repositories/netflix/lib/core/base/view/base_view.dart
|
import 'package:flutter/material.dart';
import 'package:mobx/mobx.dart';
class BaseView<T extends Store> extends StatefulWidget {
const BaseView({
Key? key,
required this.viewModel,
required this.onPageBuilder,
required this.onModelReady,
this.onDispose,
}) : super(key: key);
final Widget Function(BuildContext context, T value) onPageBuilder;
final T viewModel;
final void Function(T model) onModelReady;
final VoidCallback? onDispose;
@override
_BaseViewState<T> createState() => _BaseViewState<T>();
}
class _BaseViewState<T extends Store> extends State<BaseView<T>> {
late T model;
@override
void initState() {
model = widget.viewModel;
widget.onModelReady(model);
super.initState();
}
@override
void dispose() {
super.dispose();
if (widget.onDispose != null) widget.onDispose?.call();
}
@override
Widget build(BuildContext context) {
return widget.onPageBuilder(context, model);
}
}
| 0
|
mirrored_repositories/netflix/lib/core/base
|
mirrored_repositories/netflix/lib/core/base/model/base_model.dart
|
abstract class BaseModel<T> {
Map<String, Object?> toJson();
T fromJson(Map<String, Object> json);
}
| 0
|
mirrored_repositories/netflix/lib/core/base
|
mirrored_repositories/netflix/lib/core/base/model/base_view_model.dart
|
import 'package:flutter/material.dart';
abstract class BaseViewModel {
late BuildContext viewModelContext;
void setContext(BuildContext context);
void init();
}
| 0
|
mirrored_repositories/netflix/lib/core/base
|
mirrored_repositories/netflix/lib/core/base/state/base_state.dart
|
import 'package:flutter/material.dart';
abstract class BaseState<T extends StatefulWidget> extends State<T> {
ThemeData get themeData => Theme.of(context);
double dynamicHeight(double value) =>
MediaQuery.of(context).size.height * value;
double dyanmicWidth(double value) =>
MediaQuery.of(context).size.width * value;
}
| 0
|
mirrored_repositories/netflix/lib/product
|
mirrored_repositories/netflix/lib/product/widgets/home_label.dart
|
// ignore_for_file: sized_box_for_whitespace
import 'package:flutter/material.dart';
class HomeLabel extends StatelessWidget {
const HomeLabel({super.key, required this.title});
final String title;
@override
Widget build(BuildContext context) {
var size = MediaQuery.of(context).size;
return Container(
height: size.height * 0.40,
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
SizedBox(
height: size.height * 0.1,
),
Text(
title,
style: const TextStyle(
color: Colors.white, fontSize: 25, fontWeight: FontWeight.bold),
),
],
),
);
}
}
| 0
|
mirrored_repositories/netflix/lib/product
|
mirrored_repositories/netflix/lib/product/widgets/searchbar.dart
|
import 'package:flutter/material.dart';
class SearchBar extends StatelessWidget {
const SearchBar({super.key, required this.onChanged});
final Function(String)? onChanged;
@override
Widget build(BuildContext context) {
var size = MediaQuery.of(context).size;
return Container(
width: size.width * 0.9,
decoration: BoxDecoration(
color: const Color.fromARGB(163, 66, 64, 64),
borderRadius: BorderRadius.circular(10)),
child: TextField(
onChanged: onChanged,
style: const TextStyle(
color: Colors.white,
fontWeight: FontWeight.w400,
),
decoration: const InputDecoration(
prefixIcon: Icon(
Icons.search,
color: Color.fromARGB(255, 167, 164, 164),
),
hintText: "Search",
hintStyle: TextStyle(
color: Color.fromARGB(255, 167, 164, 164),
fontSize: 17,
fontWeight: FontWeight.w500,
),
focusedBorder: InputBorder.none,
),
),
);
}
}
| 0
|
mirrored_repositories/netflix/lib/product
|
mirrored_repositories/netflix/lib/product/widgets/home_category.dart
|
import 'package:flutter/material.dart';
import 'package:netflix/core/extension/context_extension.dart';
class HomeCategory extends StatelessWidget {
const HomeCategory({super.key});
@override
Widget build(BuildContext context) {
return Padding(
padding: context.paddingLow,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
const Text(
"TV Shows",
style: TextStyle(color: Colors.white, fontSize: 17),
),
const Text(
"Movies",
style: TextStyle(color: Colors.white, fontSize: 17),
),
Row(
children: const [
Text(
"Categories",
style: TextStyle(color: Colors.white, fontSize: 17),
),
Icon(
Icons.keyboard_arrow_down,
color: Colors.white,
),
],
)
],
),
);
}
}
| 0
|
mirrored_repositories/netflix/lib/product
|
mirrored_repositories/netflix/lib/product/widgets/downloadbutton.dart
|
// ignore_for_file: sized_box_for_whitespace
import 'package:flutter/material.dart';
class DownloadButton extends StatelessWidget {
const DownloadButton({super.key});
@override
Widget build(BuildContext context) {
return Container(
width: MediaQuery.of(context).size.width - 20,
child: Padding(
padding: const EdgeInsets.only(left: 20),
child: Container(
padding: const EdgeInsets.all(10),
alignment: Alignment.center,
decoration: BoxDecoration(
color: const Color.fromARGB(255, 88, 88, 88),
borderRadius: BorderRadius.circular(8),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: const [
Icon(
Icons.file_download,
size: 30,
color: Colors.white,
),
SizedBox(
width: 5,
),
Text(
"Download",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 18,
color: Colors.white,
),
),
],
),
),
),
);
}
}
| 0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.