Skip to content

Commit

Permalink
feat: 🎸 [JIRA:HCPSDKFIORIUIKIT-2717] Feedback Patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
hengyi-zhang committed Sep 19, 2024
1 parent 2a76f63 commit d60c886
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -350,19 +350,19 @@ struct BannerMultiMessageCustomInitExample: View {
}

var result: [BannerMessageListModel] = []
if errorMessages.count > 0 {
if !errorMessages.isEmpty {
result.append(BannerMessageListModel(category: "Errors", items: errorMessages))
}
if warningMessages.count > 0 {
if !warningMessages.isEmpty {
result.append(BannerMessageListModel(category: "Warnings", items: warningMessages))
}
if informationMessages.count > 0 {
if !informationMessages.isEmpty {
result.append(BannerMessageListModel(category: "Information", items: informationMessages))
}

self.bannerMultiMessages = result

self.showingMessageDetail = self.bannerMultiMessages.count > 0
self.showingMessageDetail = !self.bannerMultiMessages.isEmpty
}

var isEmailInvalid: Bool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,19 +256,19 @@ struct BannerMultiMessageExample: View {
}

var result: [BannerMessageListModel] = []
if errorMessages.count > 0 {
if !errorMessages.isEmpty {
result.append(BannerMessageListModel(category: "Errors", items: errorMessages))
}
if warningMessages.count > 0 {
if !warningMessages.isEmpty {
result.append(BannerMessageListModel(category: "Warnings", items: warningMessages))
}
if informationMessages.count > 0 {
if !informationMessages.isEmpty {
result.append(BannerMessageListModel(category: "Information", items: informationMessages))
}

self.bannerMultiMessages = result

self.showBanner = self.bannerMultiMessages.count > 0
self.showBanner = !self.bannerMultiMessages.isEmpty
}

var isEmailInvalid: Bool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,8 @@ public extension View {
{
var finalMessageType = messageType
for bannerMessageListModel in bannerMultiMessages {
for singleMessageModel in bannerMessageListModel.wrappedValue.items {
if singleMessageModel.messageType.rawValue > finalMessageType.rawValue {
finalMessageType = singleMessageModel.messageType
}
for singleMessageModel in bannerMessageListModel.wrappedValue.items where singleMessageModel.messageType.rawValue > finalMessageType.rawValue {
finalMessageType = singleMessageModel.messageType
}
}
return self.modifier(BannerMessageModifier(icon: icon(),
Expand Down Expand Up @@ -309,7 +307,7 @@ struct BannerMessageModifier: ViewModifier {
summary.append("\(value) \(self.messageDesc(type: key, count: value))")
}

if summary.count > 0 {
if !summary.isEmpty {
var result = ""
for i in 0 ..< summary.count {
if result == "" {
Expand Down Expand Up @@ -366,7 +364,7 @@ struct BannerMessageModifier: ViewModifier {
BannerMultiMessageSheet(closeAction: {
self.showingMessageDetail = false
}, removeAction: { _, _ in
if self.bannerMultiMessages.count == 0 {
if self.bannerMultiMessages.isEmpty {
self.isPresented = false
}
}, viewDetailAction: self.viewDetailAction, turnOnSectionHeader: self.turnOnSectionHeader, bannerMultiMessages: self.$bannerMultiMessages)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ public struct BannerMultiMessageSheet: View {
.animation(.spring, value: self.popoverHeight)
.onChange(of: self.bannerMultiMessages) { _ in
// when datasource is empty, dismiss in 2 seconds
if self.bannerMultiMessages.count == 0 {
if self.bannerMultiMessages.isEmpty {
self.timer = Timer.scheduledTimer(withTimeInterval: 2, repeats: false, block: { _ in
self.dismiss()
})
Expand Down

0 comments on commit d60c886

Please sign in to comment.