OCCalorieCounterView: UI Component
The OCCalorieCounterView
is a customisable card view for displaying calorie counter details.
It can include a increment and decrement button, unit count, unit title, motivation text, calorie count, calorie count unit and a calorie count icon.
Features
- User can pass the desired details to calculate the calorie details:
- Calorie counter data includes defaultUnitValue, unitTitle, baseUnitCounter, motivationText, defaultCalorieCounter, calorieCountUnit, icon.
Parameters:
OCCalorieCounter Details
: increment and decrement button, unit count, unit title, motivation text, calorie count, calorie count unit and a calorie count iconstyle
: The appearance of the card can be customised using different background and text color and font
import SwiftUI
let calorieCounterData =
OCCalorieCounterView(calorieCounterData: OCCalorieCounter(defaultUnitValue: 0, unitTitle: "Stockwerk(e)", baseUnitCounter: 5, motivationText: "Hurra, Du hast so viele Kalorien verbrannt:", defaultCalorieCounter: 5))
struct OCCalorieCounterTemplate: View {
var body: some View {
VStack {
let calorieCounterData = OCCalorieCounter(
defaultUnitValue: 0,
unitTitle: "Stockwerk(e)",
baseUnitCounter: 5,
motivationText: "Hurra, Du hast so viele Kalorien verbrannt:",
defaultCalorieCounter: 5)
OCCalorieCounterView(
calorieCounterData: calorieCounterData,
onButtonTap: { calorieCounterData in
debugPrint("currentUnitCount: \(calorieCounterData.currentUnitCount ?? 0) currentCalorieCount: \(calorieCounterData.currentCalorieCount ?? 0)")
})
}
.padding(.horizontal, 16)
}
}