Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
analyzer:
errors:
public_member_api_docs: ignore
include: package:very_good_analysis/analysis_options.yaml

linter:
Expand Down
Binary file added assets/food_delivery/img_cui_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/food_delivery/img_cui_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/food_delivery/img_cui_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/food_delivery/img_deals_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/food_delivery/img_deals_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/food_delivery/img_deals_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/food_delivery/img_dine_in.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/food_delivery/img_food_delivery.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/food_delivery/img_pick_up.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/food_delivery/img_shops.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions lib/feature/food_delivery/core/food_body_items.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import 'package:only_code/feature/food_delivery/core/food_delivery_images.dart';

final class FoodBodyItems {
FoodBodyItems._();

static final List<String> dailyDeals = [
FoodDeliveryImages.deals1.assetPath,
FoodDeliveryImages.deals2.assetPath,
FoodDeliveryImages.deals3.assetPath
];

static final List<String> cuisines = [
FoodDeliveryImages.cuisine1.assetPath,
FoodDeliveryImages.cuisine2.assetPath,
FoodDeliveryImages.cuisine3.assetPath
];
}
40 changes: 40 additions & 0 deletions lib/feature/food_delivery/core/food_body_top_model.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import 'package:only_code/feature/food_delivery/core/food_delivery_images.dart';

final class _FoodBodyTopModel {
const _FoodBodyTopModel({
required this.imagePath,
required this.title,
required this.subtitle,
});
final String imagePath;
final String title;
final String subtitle;
}

final class FoodBodyTopModelItems {
FoodBodyTopModelItems._();

static final foodDelivery = _FoodBodyTopModel(
imagePath: FoodDeliveryImages.topFoodDelivery.assetPath,
title: 'Food Delivery',
subtitle: 'Order from your favourite \n restaurants and home chefs',
);

static final foodShops = _FoodBodyTopModel(
imagePath: FoodDeliveryImages.topShops.assetPath,
title: 'Shops',
subtitle: 'everyday essentials',
);

static final foodPickUp = _FoodBodyTopModel(
imagePath: FoodDeliveryImages.topPickUp.assetPath,
title: 'Pick Up',
subtitle: 'Enjoy 50% off',
);

static final foodDineIn = _FoodBodyTopModel(
imagePath: FoodDeliveryImages.topDineIn.assetPath,
title: 'Dine In',
subtitle: 'Eat out and save 75% off',
);
}
14 changes: 14 additions & 0 deletions lib/feature/food_delivery/core/food_delivery_constants.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
final class FoodDeliveryConstants {
FoodDeliveryConstants._();

static _Keys keys = _Keys._();
}

final class _Keys {
_Keys._();

final university = 'COMSATS UNIVERSITY ISLAMABAD ';
final search = 'Search for shops & restaurants';
final dailyDeals = 'Your daily deals';
final cuisines = 'Cuisines';
}
17 changes: 17 additions & 0 deletions lib/feature/food_delivery/core/food_delivery_images.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
enum FoodDeliveryImages {
topFoodDelivery('img_food_delivery'),
topShops('img_shops'),
topPickUp('img_pick_up'),
topDineIn('img_dine_in'),
deals1('img_deals_1'),
deals2('img_deals_2'),
deals3('img_deals_3'),
cuisine1('img_cui_1'),
cuisine2('img_cui_2'),
cuisine3('img_cui_3');

final String _path;
const FoodDeliveryImages(String path) : _path = path;

String get assetPath => 'assets/food_delivery/$_path.png';
}
51 changes: 51 additions & 0 deletions lib/feature/food_delivery/core/food_delivery_view_style.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import 'package:flutter/material.dart';

final class FoodDeliveryViewColors {
FoodDeliveryViewColors._();
static const Color white = Colors.white;
static const Color customRed = Color(0xffD00764);
static const Color grey = Color(0xffBDBDBD);
static const Color black = Colors.black;
static const Color lightGrey = Color(0xffE8ECEF);
}

final class FoodDeliveryViewPadding {
FoodDeliveryViewPadding._();
static const EdgeInsets screenPadding = EdgeInsets.all(16);
static const EdgeInsets screenPaddingHalf = EdgeInsets.all(8);
static const EdgeInsets horizontalPadding =
EdgeInsets.symmetric(horizontal: 16);
static const EdgeInsets verticalPadding = EdgeInsets.symmetric(vertical: 16);
static const EdgeInsets topPadding = EdgeInsets.only(top: 16);
static const EdgeInsets bottomPadding = EdgeInsets.only(bottom: 16);
static const EdgeInsets leftPadding = EdgeInsets.only(left: 16);
static const EdgeInsets rightPadding = EdgeInsets.only(right: 16);
}

final class FoodDeliveryViewTextStyle {
final BuildContext context;

FoodDeliveryViewTextStyle(this.context);

TextStyle? get titleLarge =>
Theme.of(context).textTheme.headlineMedium?.copyWith(
color: FoodDeliveryViewColors.white,
);

TextStyle? get titleMedium =>
Theme.of(context).textTheme.titleMedium?.copyWith(
color: FoodDeliveryViewColors.white,
);

TextStyle? get bodyLarge => Theme.of(context).textTheme.bodyLarge?.copyWith(
color: FoodDeliveryViewColors.white,
);

TextStyle? get bodyMedium => Theme.of(context).textTheme.bodyMedium?.copyWith(
color: FoodDeliveryViewColors.white,
);

TextStyle? get bodySmall => Theme.of(context).textTheme.bodySmall?.copyWith(
color: FoodDeliveryViewColors.white,
);
}
95 changes: 95 additions & 0 deletions lib/feature/food_delivery/food_delivery_view.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import 'package:flutter/material.dart';
import 'package:only_code/feature/food_delivery/core/food_body_items.dart';
import 'package:only_code/feature/food_delivery/core/food_body_top_model.dart';
import 'package:only_code/feature/food_delivery/core/food_delivery_constants.dart';
import 'package:only_code/feature/food_delivery/core/food_delivery_view_style.dart';
import 'package:only_code/feature/food_delivery/widget/food_delivery_app_bar.dart';

part './widget/food_delivery_body_top.dart';

final class FoodDeliveryView extends StatefulWidget {
const FoodDeliveryView({Key? key}) : super(key: key);
@override
State<FoodDeliveryView> createState() => _FoodDeliveryViewState();
}

class _FoodDeliveryViewState extends State<FoodDeliveryView> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: FoodDeliveryAppBar(
onSearch: (String value) {},
),
body: ListView(
children: [
const _FoodDeliveryBodyTop(),
Padding(
padding: FoodDeliveryViewPadding.horizontalPadding,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_Title(
context: context,
data: FoodDeliveryConstants.keys.dailyDeals),
const _DailyDeals(),
_Title(
context: context,
data: FoodDeliveryConstants.keys.cuisines),
const _Cuisines(),
],
),
),
],
),
);
}
}

final class _DailyDeals extends StatelessWidget {
const _DailyDeals();

@override
Widget build(BuildContext context) {
return SizedBox(
height: 200,
child: ListView.builder(
itemCount: FoodBodyItems.dailyDeals.length,
scrollDirection: Axis.horizontal,
itemBuilder: (context, index) {
return Image.asset(FoodBodyItems.dailyDeals[index]);
},
),
);
}
}

class _Cuisines extends StatelessWidget {
const _Cuisines({
super.key,
});

@override
Widget build(BuildContext context) {
return SizedBox(
height: 100,
child: ListView.builder(
itemCount: FoodBodyItems.cuisines.length,
scrollDirection: Axis.horizontal,
itemBuilder: (context, index) {
return Image.asset(FoodBodyItems.cuisines[index]);
},
),
);
}
}

final class _Title extends Text {
_Title({required String data, required BuildContext context})
: super(
data,
style: FoodDeliveryViewTextStyle(context).titleMedium?.copyWith(
color: FoodDeliveryViewColors.black,
fontWeight: FontWeight.bold,
),
);
}
79 changes: 79 additions & 0 deletions lib/feature/food_delivery/widget/food_delivery_app_bar.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import 'package:flutter/material.dart';
import 'package:only_code/feature/food_delivery/core/food_delivery_constants.dart';
import 'package:only_code/feature/food_delivery/core/food_delivery_view_style.dart';

class FoodDeliveryAppBar extends StatelessWidget
implements PreferredSizeWidget {
const FoodDeliveryAppBar({required this.onSearch, super.key});

/// Callback when user searches for a food item
final ValueChanged<String> onSearch;

@override
Widget build(BuildContext context) {
return ColoredBox(
color: FoodDeliveryViewColors.customRed,
child: SafeArea(
child: Padding(
padding: FoodDeliveryViewPadding.horizontalPadding,
child: Column(
children: [const _Header(), _SearchField(onSearch: onSearch)],
),
),
),
);
}

@override
Size get preferredSize => const Size.fromHeight(100);
}

final class _SearchField extends StatelessWidget {
const _SearchField({
required this.onSearch,
});

final ValueChanged<String> onSearch;
@override
Widget build(BuildContext context) {
return Padding(
padding: FoodDeliveryViewPadding.topPadding,
child: TextField(
onChanged: onSearch,
decoration: InputDecoration(
hintText: FoodDeliveryConstants.keys.search,
hintStyle: FoodDeliveryViewTextStyle(context).bodyMedium?.copyWith(
color: FoodDeliveryViewColors.black,
fontWeight: FontWeight.normal),
prefixIcon:
const Icon(Icons.search, color: FoodDeliveryViewColors.black),
border: OutlineInputBorder(
borderSide: BorderSide.none,
borderRadius: BorderRadius.circular(24),
),
filled: true,
contentPadding: EdgeInsets.zero,
fillColor: FoodDeliveryViewColors.white,
)),
);
}
}

final class _Header extends StatelessWidget {
const _Header();

@override
Widget build(BuildContext context) {
return Row(
children: [
const Icon(Icons.location_on, color: FoodDeliveryViewColors.white),
Expanded(
child: Text(
FoodDeliveryConstants.keys.university,
style: FoodDeliveryViewTextStyle(context).bodyMedium,
),
),
],
);
}
}
Loading