We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import SwiftUI
// Sample Data (for preview purposes) let sampleData = ReferralCampaignData( availableCampaigns: [ ReferralCampaign( availableTime: "1 June - 31 August 2025", remainingInvites: "5 invites out of 30 limit", invitedFriends: [ InvitedFriend( avatar: "profile1", name: "Shirley Wong", campaignStatus: .inProgress, totalReceivedAmt: "$68", receivedTiers: [ ReceivedTier(name: "Cash Credit", receivedAmt: "$20"), ReceivedTier(name: "Stock Coupon", receivedAmt: "$28"), ReceivedTier(name: "Water Bottle", receivedAmt: "$20") ] ), InvitedFriend( avatar: "profile2", name: "Brenda Chong", campaignStatus: .inProgress, totalReceivedAmt: "$20", receivedTiers: [] ) ] ) ], receivedHistory: [ ReceivedHistory( avatar: "profile3", name: "Francis", campaignStatus: .completed, totalReceivedAmt: "$78" ), ReceivedHistory( avatar: "profile1", name: "Shirley Wong", campaignStatus: .completed, totalReceivedAmt: "$68" ) ], totalReceivedAmt: "1000 SGD" )
struct InviteView: View { let data: ReferralCampaignData
var body: some View { VStack(alignment: .leading) { // Title and Campaign Information Text("My Invites") .font(.largeTitle) .padding(.horizontal) ForEach(data.availableCampaigns, id: \.availableTime) { campaign in Text("Active Referral Campaigns (\(campaign.remainingInvites))") .font(.subheadline) .foregroundColor(.gray) .padding(.horizontal) // Active Referrals ScrollView { VStack { ForEach(campaign.invitedFriends, id: \.name) { friend in ReferralItemView(friend: friend) } } .padding(.horizontal) } } // Expired Referral Campaigns Text("Expired Referral Campaigns") .font(.subheadline) .foregroundColor(.gray) .padding(.horizontal) VStack { ForEach(data.receivedHistory, id: \.name) { history in ExpiredReferralItemView(history: history) } } .padding(.horizontal) // Total Value Received Spacer() HStack { Spacer() Text("Total Value Received") .font(.headline) .foregroundColor(.gray) Text(data.totalReceivedAmt) .font(.title) .bold() .foregroundColor(.orange) .padding(.trailing) } .padding(.bottom) } }
}
struct ReferralItemView: View { let friend: InvitedFriend
var body: some View { HStack { // Profile Image Image(friend.avatar) .resizable() .frame(width: 40, height: 40) .clipShape(Circle()) // User Details VStack(alignment: .leading) { Text(friend.name) .font(.headline) Text("You received \(friend.totalReceivedAmt)") .font(.subheadline) .foregroundColor(.green) } Spacer() // Status Button Text(friend.campaignStatus == .completed ? "Completed" : "In Progress") .padding(8) .background(friend.campaignStatus == .completed ? Color.green : Color.blue) .foregroundColor(.white) .cornerRadius(8) } .padding(.vertical, 5) }
struct ExpiredReferralItemView: View { let history: ReceivedHistory
var body: some View { HStack { // Profile Image Image(history.avatar) .resizable() .frame(width: 40, height: 40) .clipShape(Circle()) // User Details VStack(alignment: .leading) { Text(history.name) .font(.headline) Text("You received \(history.totalReceivedAmt)") .font(.subheadline) .foregroundColor(.green) } Spacer() // Status Button Text(history.campaignStatus == .completed ? "Completed" : "In Progress") .padding(8) .background(history.campaignStatus == .completed ? Color.green : Color.blue) .foregroundColor(.white) .cornerRadius(8) } .padding(.vertical, 5) }
struct InviteView_Previews: PreviewProvider { static var previews: some View { InviteView(data: sampleData) } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
import SwiftUI
// Sample Data (for preview purposes)
let sampleData = ReferralCampaignData(
availableCampaigns: [
ReferralCampaign(
availableTime: "1 June - 31 August 2025",
remainingInvites: "5 invites out of 30 limit",
invitedFriends: [
InvitedFriend(
avatar: "profile1",
name: "Shirley Wong",
campaignStatus: .inProgress,
totalReceivedAmt: "$68",
receivedTiers: [
ReceivedTier(name: "Cash Credit", receivedAmt: "$20"),
ReceivedTier(name: "Stock Coupon", receivedAmt: "$28"),
ReceivedTier(name: "Water Bottle", receivedAmt: "$20")
]
),
InvitedFriend(
avatar: "profile2",
name: "Brenda Chong",
campaignStatus: .inProgress,
totalReceivedAmt: "$20",
receivedTiers: []
)
]
)
],
receivedHistory: [
ReceivedHistory(
avatar: "profile3",
name: "Francis",
campaignStatus: .completed,
totalReceivedAmt: "$78"
),
ReceivedHistory(
avatar: "profile1",
name: "Shirley Wong",
campaignStatus: .completed,
totalReceivedAmt: "$68"
)
],
totalReceivedAmt: "1000 SGD"
)
struct InviteView: View {
let data: ReferralCampaignData
}
struct ReferralItemView: View {
let friend: InvitedFriend
}
struct ExpiredReferralItemView: View {
let history: ReceivedHistory
}
struct InviteView_Previews: PreviewProvider {
static var previews: some View {
InviteView(data: sampleData)
}
}
The text was updated successfully, but these errors were encountered: