Skip to content
This repository has been archived by the owner on Nov 28, 2024. It is now read-only.

Commit

Permalink
Recipe Selection (4/n) - Add/Remove Icons
Browse files Browse the repository at this point in the history
  • Loading branch information
aadityayadav17 committed Sep 19, 2024
1 parent 498c8f6 commit 7628b52
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
40 changes: 38 additions & 2 deletions lib/screens/recipe_selection_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,13 @@ class RecipeSelectionScreen extends StatelessWidget {
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
_buildActionIcon(Icons.close, Colors.red),
// Remove button with background
_buildActionIconWithBackground(
'assets/icons/screens/recipe_selection_screen/recipe-reject-accept-rectangle.png',
'assets/icons/screens/recipe_selection_screen/recipe-rejected.png',
),

// Done Button
ElevatedButton(
onPressed: () {
// Handle Done action
Expand All @@ -161,7 +167,12 @@ class RecipeSelectionScreen extends StatelessWidget {
),
child: const Text('Done'),
),
_buildActionIcon(Icons.add, Colors.green),

// Add button with background
_buildActionIconWithBackground(
'assets/icons/screens/recipe_selection_screen/recipe-reject-accept-rectangle.png',
'assets/icons/screens/recipe_selection_screen/recipe-accepted.png',
),
],
),

Expand Down Expand Up @@ -219,6 +230,31 @@ class RecipeSelectionScreen extends StatelessWidget {
);
}

// Helper method to build the icon with a background rectangle and hard alignment
Widget _buildActionIconWithBackground(
String backgroundPath, String iconPath) {
return Stack(
children: [
// Rectangle background (60x60)
Image.asset(
backgroundPath,
width: 60,
height: 60,
),
// Foreground icon (24x24) with hard alignment using Positioned
Positioned(
top: 15, // Adjust the top value to align vertically
left: 15, // Adjust the left value to align horizontally
child: Image.asset(
iconPath,
width: 24,
height: 24,
),
),
],
);
}

// Helper method to build the action icon
Widget _buildActionIcon(IconData icon, Color color) {
return IconButton(
Expand Down
3 changes: 3 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ flutter:
- assets/icons/screens/recipe_selection_screen/cooking-difficulty-easy.png
- assets/icons/screens/recipe_selection_screen/price.png
- assets/icons/screens/recipe_selection_screen/protein.png
- assets/icons/screens/recipe_selection_screen/recipe-accepted.png
- assets/icons/screens/recipe_selection_screen/recipe-reject-accept-rectangle.png
- assets/icons/screens/recipe_selection_screen/recipe-rejected.png
- assets/icons/screens/recipe_selection_screen/time-clock.png

# An image asset can refer to one or more resolution-specific "variants", see
Expand Down

0 comments on commit 7628b52

Please # to comment.