A simple and interactive grocery application built for iOS using Swift and SwiftUI. This app showcases essential SwiftUI concepts, making it an excellent project for beginners to learn and practice core SwiftUI functionalities.
- State Management: Learn how to use
@Statevariables to manage the app's state effectively. - Custom Styles: Apply styles to various UI elements for a polished look.
- Layouts: Utilize
ZStack,VStack, and other layout containers for intuitive design. - Navigation: Implement
NavigationStackfor seamless navigation between screens. - Dynamic Data: Work with arrays and
ForEachloops to dynamically generate content. - List Operations: Enable deletion of items with
onDeletefunctionality. - Lifecycle Events: Use
onAppearto perform actions when a view appears. - Component Reusability: Create reusable components to simplify the codebase.
- Xcode 14.0 or later
- iOS 16.0 or later
- Basic knowledge of Swift and SwiftUI
- Clone the repository:
git clone https://github.com/raox1/BasicGrocery.git
- Open the project in Xcode:
cd BasicGrocery open GroceryApp.xcodeproj - Build and run the app on a simulator or a physical device.
State variables are used to dynamically update the UI when the data changes.
@State private var groceries: [String] = ["Apples", "Bananas", "Carrots"]Generate UI elements dynamically from an array.
List {
ForEach(groceries, id: \ .self) { item in
Text(item)
}
.onDelete(perform: deleteItem)
}Enable navigation between screens easily.
NavigationStack {
NavigationLink("Add Grocery", destination: AddGroceryView())
}Apply custom styles to elements for a polished look.
Text("Welcome to Grocery App")
.font(.largeTitle)
.foregroundColor(.blue)Here's the app video:
groceryApp.mov
This project helped us understand:
- How to manage state with
@State. - Styling SwiftUI elements.
- Working with layout stacks like
ZStackandVStack. - Implementing navigation with
NavigationStack. - Using arrays and
ForEachfor dynamic content. - Handling list operations like deletion with
onDelete. - Reacting to lifecycle events with
onAppear. - Reusing components for cleaner and modular code.
Contributions are welcome! If you'd like to enhance this project, please:
- Fork the repository.
- Create a feature branch:
git checkout -b feature-name. - Commit your changes:
git commit -m 'Add feature-name'. - Push to the branch:
git push origin feature-name. - Open a pull request.
This project is licensed under the MIT License. See the LICENSE file for more details.
For any questions or feedback, feel free to reach out:
- Email: lalitkumaryadav9090@gmail.com
- GitHub: raox1
- Website: lalit.pro