Skip to content

Commit

Permalink
Fix minor visual issues
Browse files Browse the repository at this point in the history
  • Loading branch information
whattherestimefor committed Nov 5, 2024
1 parent fd365b8 commit 706f888
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ struct DonationCompletionView: View {
topMessage
subMessage
messageImage
buttons
Spacer()
buttons
}
.padding([.leading, .trailing], 30)
.frame(maxWidth: geometry.size.width)
Expand All @@ -74,7 +74,8 @@ struct DonationCompletionView: View {

@ViewBuilder var topMessage: some View {
Text(L10n.Scene.Donation.Success.title)
.font(.title)
.font(.largeTitle)
.bold()
.multilineTextAlignment(.center)
}
@ViewBuilder var subMessage: some View {
Expand All @@ -95,7 +96,6 @@ struct DonationCompletionView: View {
}) {
HStack {
Spacer()
Image(systemName: "megaphone.fill")
Text(L10n.Scene.Donation.Success.shareButtonTitle)
Spacer()
}
Expand Down
39 changes: 22 additions & 17 deletions Mastodon/Scene/Donation/DonationViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ class DonationViewController: UIHostingController<DonationView> {

init(
campaign: DonationCampaignViewModel?,
completion: @escaping (URL) -> Void
completion: @escaping (URL?) -> Void
) {
super.init(
rootView: DonationView(
campaign ?? DefaultDonationViewModel(), completion: completion))
self.navigationItem.leftBarButtonItem = UIBarButtonItem(systemItem: .done, primaryAction: UIAction(handler: { _ in
completion(nil)
}))
self.navigationItem.title = L10n.Scene.Donation.title
}

@MainActor required dynamic init?(coder aDecoder: NSCoder) {
Expand All @@ -38,7 +42,7 @@ extension DonationFrequency {

struct DonationView: View {
let campaign: DonationCampaignViewModel
let completion: (URL) -> Void
let completion: (URL?) -> Void

@State var selectedFrequency: DonationFrequency
@State var selectedCurrency: String
Expand All @@ -52,7 +56,7 @@ struct DonationView: View {

init(
_ campaign: DonationCampaignViewModel,
completion: @escaping (URL) -> Void
completion: @escaping (URL?) -> Void
) {
self.completion = completion
self.campaign = campaign
Expand All @@ -64,7 +68,7 @@ struct DonationView: View {
var body: some View {
HStack {
Spacer()
VStack(spacing: 36) {
VStack(spacing: 30) {
topMessage
frequencyPicker
amountEntry
Expand All @@ -73,6 +77,7 @@ struct DonationView: View {
.frame(maxWidth: 328)
Spacer()
}
.padding(.top)
}

@ViewBuilder var topMessage: some View {
Expand Down Expand Up @@ -120,9 +125,10 @@ struct DonationView: View {
value: $selectedAmount,
format: .currency(code: selectedCurrency)
) {}
.keyboardType(.numberPad)
.multilineTextAlignment(.trailing)
.padding(.trailing, 8)
.font(.title3)
.keyboardType(.numberPad)
.multilineTextAlignment(.trailing)
.padding(.trailing, 8)

}
.background(
Expand Down Expand Up @@ -165,10 +171,7 @@ struct DonationView: View {
}) {
HStack {
Spacer()
Image(systemName: "heart.fill")
.foregroundStyle(.white)
Text(L10n.Scene.Donation.donateButtonTitle)
.foregroundStyle(.white)
Spacer()
}
.frame(maxWidth: .infinity)
Expand All @@ -192,28 +195,30 @@ struct DonationButtonStyle: ButtonStyle {
switch (type, filled) {
case (.amount, true):
configuration.label
.bold()
.padding()
.background(Color(Asset.Colors.Secondary.container.color))
.foregroundStyle(Color.white)
.background(Color.indigo)
.cornerRadius(cornerRadius)
case (.amount, false):
configuration.label
.padding()
.overlay(
RoundedRectangle(cornerRadius: cornerRadius).stroke(
Color(Asset.Colors.outline.color), lineWidth: 1))
.background(Color.indigo.opacity(0.15))
.cornerRadius(cornerRadius)
case (.action, true):
configuration.label
.bold()
.foregroundStyle(.white)
.padding()
.background(Color(Asset.Colors.Primary._300.color))
.background(Color.indigo)
.cornerRadius(cornerRadius)
case (.action, false):
configuration.label
.foregroundStyle(Color(Asset.Colors.Primary._300.color))
.foregroundStyle(Color.indigo)
.padding()
.overlay(
RoundedRectangle(cornerRadius: cornerRadius).stroke(
Color(Asset.Colors.outline.color), lineWidth: 1))
Color.indigo, lineWidth: 1))
}
}
}
Expand Down
17 changes: 13 additions & 4 deletions Mastodon/Scene/Donation/NewDonationNavigationFlow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,20 @@ class NewDonationNavigationFlow: NavigationFlow {
let optionsController = DonationViewController(campaign: campaign) {
[weak self] attemptedDonation in
guard let s = self else { return }
s.showDonationPaymentWebview(
attemptedDonation, campaign: s.campaign)
if let attemptedDonation {
s.showDonationPaymentWebview(
attemptedDonation, campaign: s.campaign)
} else {
s.dismissFlow()
}
}

if flowPresenter is UINavigationController {
flowPresenter.show(optionsController, preferredDetents: [.medium()])
} else {
let navController = UINavigationController(rootViewController: optionsController)
flowPresenter.show(navController, preferredDetents: [.medium()])
}

flowPresenter.show(optionsController, preferredDetents: [.medium()])
}

private func showDonationPaymentWebview(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,8 @@ public enum L10n {
public static let currency = L10n.tr("Localizable", "Scene.Donation.Currency", fallback: "Currency")
/// Donate
public static let donateButtonTitle = L10n.tr("Localizable", "Scene.Donation.DonateButtonTitle", fallback: "Donate")
/// Donate to Mastodon
public static let title = L10n.tr("Localizable", "Scene.Donation.Title", fallback: "Donate to Mastodon")
public enum Picker {
/// Monthly
public static let monthlyTitle = L10n.tr("Localizable", "Scene.Donation.Picker.MonthlyTitle", fallback: "Monthly")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ uploaded to Mastodon.";
"Scene.FollowedTags.Header.Posts" = "posts";
"Scene.FollowedTags.Header.PostsToday" = "posts today";
"Scene.FollowedTags.Title" = "Followed Tags";
"Scene.Donation.Title" = "Donate to Mastodon";
"Scene.Donation.Picker.OnceTitle" = "Just once";
"Scene.Donation.Picker.MonthlyTitle" = "Monthly";
"Scene.Donation.Picker.YearlyTitle" = "Yearly";
Expand Down

0 comments on commit 706f888

Please sign in to comment.