-
-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
80 additions
and
58 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
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
33 changes: 33 additions & 0 deletions
33
ACHNBrowserUI/ACHNBrowserUI/views/shared/ResidentButton.swift
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,33 @@ | ||
// | ||
// ResidentButton.swift | ||
// ACHNBrowserUI | ||
// | ||
// Created by Thomas Ricouard on 07/06/2020. | ||
// Copyright © 2020 Thomas Ricouard. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
import Backend | ||
|
||
struct ResidentButton: View { | ||
@EnvironmentObject private var collection: UserCollection | ||
let villager: Villager | ||
|
||
var body: some View { | ||
Button(action: { | ||
_ = self.collection.toggleResident(villager: self.villager) | ||
FeedbackGenerator.shared.triggerNotification(type: .success) | ||
}) { | ||
Image(systemName: collection.residents.contains(villager) ? "house.fill" : "house") | ||
.foregroundColor(.acTabBarBackground) | ||
.imageScale(.medium) | ||
} | ||
.buttonStyle(BorderlessButtonStyle()) | ||
} | ||
} | ||
|
||
struct ResidentButton_Previews: PreviewProvider { | ||
static var previews: some View { | ||
ResidentButton(villager: static_villager).environmentObject(UserCollection.shared) | ||
} | ||
} |
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