Skip to content

Commit

Permalink
[RatingInput#894] Rename function isEnabled..
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-zimmermann committed Apr 18, 2024
1 parent 8a743e2 commit 98a21d9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,16 @@ final class RatingDisplayViewModel: ObservableObject {
state: self.ratingState)
}

func updateState(isEnabled: Bool) {
guard self.ratingState.isEnabled != isEnabled else { return }
@discardableResult
func updateState(isEnabled: Bool) -> Self {
guard self.ratingState.isEnabled != isEnabled else { return self }

self.ratingState.isEnabled = isEnabled
self.colors = self.colorsUseCase.execute(
theme: self.theme,
intent: self.intent,
state: self.ratingState)
}

func isEnabled(_ enabled: Bool) -> Self {
self.updateState(isEnabled: enabled)
return self
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public struct RatingInputView: View {

// MARK: - View
public var body: some View {
RatingInputInternalView(viewModel: viewModel.isEnabled(self.isEnabled), rating: self.rating)
RatingInputInternalView(viewModel: viewModel.updateState(isEnabled: self.isEnabled), rating: self.rating, configuration: self.configuration)
}

// MARK: - Internal functions
Expand All @@ -68,11 +68,11 @@ struct RatingInputInternalView: View {
/// - Parameters:
/// - viewModel: The view model of the view.
/// - rating: A binding containg the rating value. This should be a value within the range 0...5
/// - configuration: A configuration of the star. A default value is defined.
/// - configuration: A configuration of the star
init(
viewModel: RatingDisplayViewModel,
rating: Binding<CGFloat>,
configuration: StarConfiguration = .default
configuration: StarConfiguration
) {
self._rating = rating
self._displayRating = State(initialValue: rating.wrappedValue)
Expand Down

0 comments on commit 98a21d9

Please sign in to comment.