-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add donations UI to the app and wire it up to Obaco
- Loading branch information
1 parent
e4244e4
commit e383c57
Showing
25 changed files
with
860 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
Apps/OneBusAway/Assets.xcassets/wmata.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "wmata.jpg", | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// AnalyticsModel.swift | ||
// OBAKit | ||
// | ||
// Created by Aaron Brethorst on 11/16/23. | ||
// | ||
|
||
import SwiftUI | ||
|
||
class AnalyticsModel: ObservableObject { | ||
init(_ analytics: Analytics?) { | ||
self.analytics = analytics | ||
} | ||
|
||
let analytics: Analytics? | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
// | ||
// DonationCell.swift | ||
// OBAKit | ||
// | ||
// Created by Aaron Brethorst on 10/30/23. | ||
// | ||
|
||
import UIKit | ||
import OBAKitCore | ||
|
||
class DonationCell: OBAListViewCell { | ||
|
||
var donationRequest: DonationRequest? | ||
var viewModel: DonationListItem? | ||
|
||
public override func apply(_ config: OBAContentConfiguration) { | ||
super.apply(config) | ||
|
||
guard let config = config as? DonationContentConfiguration else { | ||
fatalError() | ||
} | ||
|
||
viewModel = config.viewModel | ||
} | ||
|
||
lazy var titleLabel: UILabel = { | ||
let label = UILabel.autolayoutNew() | ||
label.numberOfLines = 0 | ||
label.font = .preferredFont(forTextStyle: .title3).bold | ||
|
||
label.text = OBALoc("donation_cell.title", value: "🚨 OneBusAway needs your help", comment: "Title of the donation widget that appears on the stop view controller.") | ||
return label | ||
}() | ||
|
||
lazy var closeButton = { | ||
let button = UIButton.buildCloseButton() | ||
let action = UIAction { [self] _ in | ||
guard let viewModel = viewModel else { return } | ||
viewModel.onCloseAction?(viewModel) | ||
} | ||
button.addAction(action, for: .touchUpInside) | ||
return button | ||
}() | ||
|
||
lazy var closeButtonWrapper: UIView = { | ||
let wrapper = closeButton.embedInWrapperView(setConstraints: false) | ||
NSLayoutConstraint.activate([ | ||
closeButton.leadingAnchor.constraint(equalTo: wrapper.leadingAnchor), | ||
closeButton.topAnchor.constraint(equalTo: wrapper.topAnchor), | ||
closeButton.trailingAnchor.constraint(equalTo: wrapper.trailingAnchor), | ||
wrapper.heightAnchor.constraint(greaterThanOrEqualTo: closeButton.heightAnchor) | ||
]) | ||
|
||
return wrapper | ||
}() | ||
|
||
lazy var titleRow = UIStackView.horizontalStack(arrangedSubviews: [titleLabel, closeButtonWrapper]) | ||
|
||
lazy var messageLabel: UILabel = { | ||
let label = UILabel.autolayoutNew() | ||
label.numberOfLines = 0 | ||
label.text = OBALoc("donation_cell.body", value: "This app is currently built with 100% volunteer labor, and we need you to help us fund future development.", comment: "Body of the donation widget that appears on the stop view controller") | ||
return label | ||
}() | ||
|
||
lazy var learnMoreButton: UIButton = { | ||
let action = UIAction { [self] _ in | ||
guard let viewModel = viewModel else { return } | ||
viewModel.onLearnMoreAction?(viewModel) | ||
} | ||
let button = UIButton(configuration: .bordered(), primaryAction: action) | ||
button.translatesAutoresizingMaskIntoConstraints = false | ||
button.setTitle(OBALoc("donation_cell.learn_more_button_title", value: "Learn More", comment: "Title of the button that shows the donation explanation UI."), for: .normal) | ||
return button | ||
}() | ||
|
||
lazy var donateButton: UIButton = { | ||
let button = UIButton(configuration: .borderedProminent()) | ||
button.translatesAutoresizingMaskIntoConstraints = false | ||
button.setTitle(OBALoc("donation_cell.donate_button_title", value: "Donate Now", comment: "Title of the button that shows the donation UI."), for: .normal) | ||
|
||
let action = UIAction { [self] _ in | ||
guard let viewModel = viewModel else { return } | ||
viewModel.onSelectAction?(viewModel) | ||
} | ||
button.addAction(action, for: .touchUpInside) | ||
return button | ||
}() | ||
|
||
lazy var buttonStack: UIStackView = { | ||
let stack = UIStackView.horizontalStack(arrangedSubviews: [learnMoreButton, donateButton]) | ||
stack.spacing = ThemeMetrics.compactPadding | ||
|
||
return stack | ||
}() | ||
|
||
lazy var outerStack: UIStackView = { | ||
let stack = UIStackView.verticalStack(arrangedSubviews: [ | ||
titleRow, | ||
messageLabel, | ||
UIView.spacerView(height: 4.0), | ||
buttonStack | ||
]) | ||
stack.spacing = 4.0 | ||
return stack | ||
}() | ||
|
||
override init(frame: CGRect) { | ||
super.init(frame: frame) | ||
setupView() | ||
} | ||
|
||
required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
private func setupView() { | ||
addSubview(outerStack) | ||
outerStack.pinToSuperview(.edges, insets: NSDirectionalEdgeInsets(top: 8, leading: 8, bottom: -8, trailing: -8)) | ||
} | ||
} |
Oops, something went wrong.