Skip to content

Commit

Permalink
Add withContext for all responsive dimensions
Browse files Browse the repository at this point in the history
  • Loading branch information
thecodepapaya committed Jul 19, 2023
1 parent 746dd64 commit 0064d19
Show file tree
Hide file tree
Showing 22 changed files with 146 additions and 146 deletions.
10 changes: 5 additions & 5 deletions lib/app/common/add_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class AddButton extends StatelessWidget {
return InkWell(
onTap: onPressed,
child: Container(
height: 42.toAutoScaledHeight,
width: 119.toAutoScaledWidth,
height: 42.toAutoScaledHeightWithContext(context),
width: 119.toAutoScaledWidthWithContext(context),
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(
Expand All @@ -27,7 +27,7 @@ class AddButton extends StatelessWidget {
child: Text(
'Add',
style: TextStyle(
fontSize: 12.toAutoScaledWidth,
fontSize: 12.toAutoScaledWidthWithContext(context),
color: const Color(0xFF3D54FF),
),
),
Expand All @@ -39,7 +39,7 @@ class AddButton extends StatelessWidget {
// onPressed: onPressed,
// style: OutlinedButton.styleFrom(
// elevation: 0,
// fixedSize: Size(119.toAutoScaledWidth, 42.toAutoScaledHeight),
// fixedSize: Size(119.toAutoScaledWidthWithContext(context), 42.toAutoScaledHeightWithContext(context)),
// padding: EdgeInsets.zero,
// side: const BorderSide(
// color: Color(0xFF3D54FF),
Expand All @@ -51,7 +51,7 @@ class AddButton extends StatelessWidget {
// child: Text(
// 'Add',
// style: TextStyle(
// fontSize: 12.toAutoScaledWidth,
// fontSize: 12.toAutoScaledWidthWithContext(context),
// color: const Color(0xFF3D54FF),
// ),
// ),
Expand Down
12 changes: 6 additions & 6 deletions lib/app/common/counter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ class _DishCounterState extends State<DishCounter> {
children: [
_Button.dec(onPressed: _onDecrease),
Container(
height: 42.toAutoScaledHeight,
width: 47.toAutoScaledWidth,
height: 42.toAutoScaledHeightWithContext(context),
width: 47.toAutoScaledWidthWithContext(context),
decoration: BoxDecoration(
color: const Color(0xFFE0E4FF),
border: Border.all(
Expand All @@ -61,7 +61,7 @@ class _DishCounterState extends State<DishCounter> {
'$count',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 12.toAutoScaledWidth,
fontSize: 12.toAutoScaledWidthWithContext(context),
fontWeight: FontWeight.w600,
color: const Color(0xFF3D54FF),
),
Expand Down Expand Up @@ -89,8 +89,8 @@ class _Button extends StatelessWidget {
return InkWell(
onTap: onPressed,
child: Container(
height: 42.toAutoScaledHeight,
width: 36.toAutoScaledWidth,
height: 42.toAutoScaledHeightWithContext(context),
width: 36.toAutoScaledWidthWithContext(context),
decoration: BoxDecoration(
color: const Color(0xFF3D54FF),
borderRadius: BorderRadius.only(
Expand All @@ -102,7 +102,7 @@ class _Button extends StatelessWidget {
),
child: Icon(
symbol,
size: 16.toAutoScaledWidth,
size: 16.toAutoScaledWidthWithContext(context),
color: Colors.white,
),
),
Expand Down
6 changes: 3 additions & 3 deletions lib/presentation/categories/view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ class CategoryPage extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const _CloseButton(),
8.toAutoScaledHeight.toVerticalSpace,
8.toAutoScaledHeightWithContext(context).toVerticalSpace,
Container(
padding: EdgeInsets.only(
top: 24.toAutoScaledHeight,
bottom: 16.toAutoScaledWidth,
top: 24.toAutoScaledHeightWithContext(context),
bottom: 16.toAutoScaledWidthWithContext(context),
),
decoration: const BoxDecoration(
color: Colors.white,
Expand Down
10 changes: 5 additions & 5 deletions lib/presentation/categories/widgets/category_header.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ class _CategoryHeader extends StatelessWidget {
),
),
padding: EdgeInsets.only(
top: 24.toAutoScaledHeight,
bottom: 8.toAutoScaledHeight,
left: 16.toAutoScaledWidth,
right: 16.toAutoScaledWidth,
top: 24.toAutoScaledHeightWithContext(context),
bottom: 8.toAutoScaledHeightWithContext(context),
left: 16.toAutoScaledWidthWithContext(context),
right: 16.toAutoScaledWidthWithContext(context),
),
child: Text(
"CATEGORIES ($categoriesCount)",
style: TextStyle(
fontSize: 12.toAutoScaledWidth,
fontSize: 12.toAutoScaledWidthWithContext(context),
fontWeight: FontWeight.w600,
color: Color(0xFFA9AAAE),
),
Expand Down
14 changes: 7 additions & 7 deletions lib/presentation/categories/widgets/category_image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,27 +50,27 @@ class _CategoryImage extends StatelessWidget {
errorBuilder: (context, error, stackTrace) {
return Image.asset(
"assets/images/no_image.jpeg",
height: 36.toAutoScaledHeight,
width: 164.toAutoScaledWidth,
height: 36.toAutoScaledHeightWithContext(context),
width: 164.toAutoScaledWidthWithContext(context),
fit: BoxFit.cover,
);
},
height: 36.toAutoScaledHeight,
width: 164.toAutoScaledWidth,
height: 36.toAutoScaledHeightWithContext(context),
width: 164.toAutoScaledWidthWithContext(context),
fit: BoxFit.cover,
),
),
Positioned(
bottom: 9.toAutoScaledHeight,
left: 16.toAutoScaledWidth,
bottom: 9.toAutoScaledHeightWithContext(context),
left: 16.toAutoScaledWidthWithContext(context),
child: SizedBox(
width: 100,
child: Text(
menu.name,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 12.toAutoScaledWidth,
fontSize: 12.toAutoScaledWidthWithContext(context),
fontWeight: FontWeight.w800,
color: Colors.white,
),
Expand Down
4 changes: 2 additions & 2 deletions lib/presentation/categories/widgets/category_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class _CategoryList extends StatelessWidget {
child: SingleChildScrollView(
child: Column(
children: [
8.toAutoScaledHeight.toVerticalSpace,
8.toAutoScaledHeightWithContext(context).toVerticalSpace,
...categoriesMap.entries
.map(
(e) => _CategoryTile(
Expand All @@ -28,7 +28,7 @@ class _CategoryList extends StatelessWidget {
),
)
.toList(),
20.toAutoScaledHeight.toVerticalSpace,
20.toAutoScaledHeightWithContext(context).toVerticalSpace,
],
),
),
Expand Down
16 changes: 8 additions & 8 deletions lib/presentation/categories/widgets/category_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ class _CategoryTile extends StatelessWidget {
},
child: Container(
margin: EdgeInsets.symmetric(
horizontal: 16.toAutoScaledWidth,
vertical: 4.toAutoScaledHeight,
horizontal: 16.toAutoScaledWidthWithContext(context),
vertical: 4.toAutoScaledHeightWithContext(context),
),
padding: EdgeInsets.symmetric(
horizontal: 8.toAutoScaledWidth,
vertical: 12.toAutoScaledHeight,
horizontal: 8.toAutoScaledWidthWithContext(context),
vertical: 12.toAutoScaledHeightWithContext(context),
),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
Expand All @@ -48,16 +48,16 @@ class _CategoryTile extends StatelessWidget {
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
),
),
12.toAutoScaledWidth.toHorizontalSpace,
12.toAutoScaledWidthWithContext(context).toHorizontalSpace,
SizedBox(
width: 220.toAutoScaledWidth,
width: 220.toAutoScaledWidthWithContext(context),
child: Text(
value,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: isSelected ? const Color(0xFF3D54FF) : Colors.black,
fontSize: 12.toAutoScaledWidth,
fontSize: 12.toAutoScaledWidthWithContext(context),
fontWeight: isSelected ? FontWeight.w700 : FontWeight.w400,
),
),
Expand All @@ -67,7 +67,7 @@ class _CategoryTile extends StatelessWidget {
"($valueCount)",
style: TextStyle(
color: isSelected ? const Color(0xFF3D54FF) : Colors.black,
fontSize: 12.toAutoScaledWidth,
fontSize: 12.toAutoScaledWidthWithContext(context),
fontWeight: isSelected ? FontWeight.w700 : FontWeight.w400,
),
),
Expand Down
4 changes: 2 additions & 2 deletions lib/presentation/categories/widgets/close_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class _CloseButton extends StatelessWidget {
onPressed: controller._returnToMenuScreen,
icon: SvgPicture.asset(
"assets/icons/close_icon.svg",
height: 24.toAutoScaledHeight,
width: 24.toAutoScaledWidth,
height: 24.toAutoScaledHeightWithContext(context),
width: 24.toAutoScaledWidthWithContext(context),
),
);
}
Expand Down
6 changes: 3 additions & 3 deletions lib/presentation/categories/widgets/menu_types.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ class MenuType extends StatelessWidget {
final menuTypeLength = menus.length;

return Padding(
padding: EdgeInsets.symmetric(horizontal: 16.toAutoScaledWidth),
padding: EdgeInsets.symmetric(horizontal: 16.toAutoScaledWidthWithContext(context)),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"MENU TYPE ($menuTypeLength)",
style: TextStyle(
color: const Color(0xFFA9AAAE),
fontSize: 12.toAutoScaledWidth,
fontSize: 12.toAutoScaledWidthWithContext(context),
fontWeight: FontWeight.w600,
),
),
...menus
.map(
(m) => Padding(
padding: EdgeInsets.only(top: 16.toAutoScaledHeight),
padding: EdgeInsets.only(top: 16.toAutoScaledHeightWithContext(context)),
child: _CategoryImage(menu: m),
),
)
Expand Down
16 changes: 8 additions & 8 deletions lib/presentation/categories/widgets/scroll_down_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class _ScrollDownButtonState extends State<_ScrollDownButton> with SingleTickerP
Widget build(BuildContext context) {
return InkWell(
child: Padding(
padding: EdgeInsets.only(bottom: padding.toAutoScaledHeight),
padding: EdgeInsets.only(bottom: padding.toAutoScaledHeightWithContext(context)),
child: Material(
elevation: 26,
borderRadius: BorderRadius.circular(40),
Expand All @@ -73,24 +73,24 @@ class _ScrollDownButtonState extends State<_ScrollDownButton> with SingleTickerP
borderRadius: BorderRadius.circular(40),
),
padding: EdgeInsets.only(
top: 24.toAutoScaledHeight - padding.toAutoScaledHeight,
left: 10.toAutoScaledWidth,
right: 10.toAutoScaledWidth,
bottom: 12.toAutoScaledHeight,
top: 24.toAutoScaledHeightWithContext(context) - padding.toAutoScaledHeightWithContext(context),
left: 10.toAutoScaledWidthWithContext(context),
right: 10.toAutoScaledWidthWithContext(context),
bottom: 12.toAutoScaledHeightWithContext(context),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.keyboard_arrow_down_rounded,
size: 24.toAutoScaledWidth,
size: 24.toAutoScaledWidthWithContext(context),
),
4.toAutoScaledHeight.toVerticalSpace,
4.toAutoScaledHeightWithContext(context).toVerticalSpace,
Text(
'Scroll\nDown',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 8.toAutoScaledWidth,
fontSize: 8.toAutoScaledWidthWithContext(context),
),
),
],
Expand Down
2 changes: 1 addition & 1 deletion lib/presentation/dish/view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class _DishPageState extends State<DishPage> {
children: [
const Expanded(child: SizedBox()),
const _CloseButton(),
8.toAutoScaledHeight.toVerticalSpace,
8.toAutoScaledHeightWithContext(context).toVerticalSpace,
const _ImageHeader(),
const _DishHeader(),
const _ButtonRow(),
Expand Down
20 changes: 10 additions & 10 deletions lib/presentation/dish/widgets/button_row.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,23 @@ class _ButtonRow extends StatelessWidget {
),
),
padding: EdgeInsets.only(
right: 16.toAutoScaledWidth,
left: 32.toAutoScaledWidth,
bottom: 16.toAutoScaledHeight,
top: 16.toAutoScaledHeight,
right: 16.toAutoScaledWidthWithContext(context),
left: 32.toAutoScaledWidthWithContext(context),
bottom: 16.toAutoScaledHeightWithContext(context),
top: 16.toAutoScaledHeightWithContext(context),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const DishCounter(initialCount: 1),
16.toAutoScaledWidth.toHorizontalSpace,
16.toAutoScaledWidthWithContext(context).toHorizontalSpace,
InkWell(
onTap: Get.back,
child: Container(
width: 176.toAutoScaledWidth,
height: 42.toAutoScaledHeight,
width: 176.toAutoScaledWidthWithContext(context),
height: 42.toAutoScaledHeightWithContext(context),
padding: EdgeInsets.symmetric(
horizontal: 16.toAutoScaledWidth,
horizontal: 16.toAutoScaledWidthWithContext(context),
),
decoration: BoxDecoration(
color: Color(0xFF3D54FF),
Expand All @@ -48,15 +48,15 @@ class _ButtonRow extends StatelessWidget {
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w600,
fontSize: 12.toAutoScaledWidth,
fontSize: 12.toAutoScaledWidthWithContext(context),
),
),
Text(
"₹$price",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w600,
fontSize: 12.toAutoScaledWidth,
fontSize: 12.toAutoScaledWidthWithContext(context),
),
),
],
Expand Down
4 changes: 2 additions & 2 deletions lib/presentation/dish/widgets/close_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class _CloseButton extends StatelessWidget {
onPressed: Get.back,
icon: SvgPicture.asset(
"assets/icons/close_icon.svg",
height: 24.toAutoScaledHeight,
width: 24.toAutoScaledWidth,
height: 24.toAutoScaledHeightWithContext(context),
width: 24.toAutoScaledWidthWithContext(context),
),
);
}
Expand Down
Loading

0 comments on commit 0064d19

Please sign in to comment.