Skip to content

Commit

Permalink
Implement new button designs
Browse files Browse the repository at this point in the history
  • Loading branch information
jotaemepereira committed Dec 19, 2024
1 parent cde71c3 commit d68d8a4
Showing 1 changed file with 32 additions and 21 deletions.
53 changes: 32 additions & 21 deletions DuckDuckGo/RemoteMessaging/TabBarRemoteMessageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,44 +31,55 @@ struct TabBarRemoteMessageView: View {
let onAppear: () -> Void

var body: some View {
HStack {
Text(model.buttonTitle)
.font(.system(size: 13))
.fixedSize(horizontal: true, vertical: false)
.foregroundColor(.white)
HStack(spacing: 0) {
HStack {
Text(model.buttonTitle)
.font(.system(size: 13))
.fixedSize(horizontal: true, vertical: false)
.foregroundColor(.white)
}
.padding([.leading, .top, .bottom], 8)
.padding(.trailing, 4)
.cornerRadius(8)
.background(wasViewHovered
? Color("PrimaryButtonHover")
: Color("PrimaryButtonRest"))
.onTapGesture { onTap(model.surveyURL) }
.onHover { hovering in
wasViewHovered = hovering

if hovering {
onHover()
} else {
onHoverEnd()
}
}

Button(action: { onClose() }) {
HStack {
Image(.close)
.resizable()
.scaledToFit()
.frame(width: 16, height: 16)
}
.frame(width: 16, height: 16)
.buttonStyle(PlainButtonStyle())
.background(wasCloseButtonHovered && !wasViewHovered
.padding([.top, .bottom, .trailing], 8)
.background(wasCloseButtonHovered
? Color("PrimaryButtonHover")
: Color("PrimaryButtonRest"))
.cornerRadius(2)
.cornerRadius(8)
.onTapGesture {
onClose()
}
.onHover { hovering in
wasCloseButtonHovered = hovering
}
.frame(maxWidth: .infinity)
}
.padding(8)
.background(wasViewHovered
.background(wasCloseButtonHovered || wasViewHovered
? Color("PrimaryButtonHover")
: Color("PrimaryButtonRest"))
.frame(height: 24)
.cornerRadius(8)
.onAppear(perform: { onAppear() })
.onHover { hovering in
wasViewHovered = hovering

if hovering {
onHover()
} else {
onHoverEnd()
}
}
}
}

Expand Down

0 comments on commit d68d8a4

Please sign in to comment.