-
Notifications
You must be signed in to change notification settings - Fork 0
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
14 changed files
with
276 additions
and
29 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
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,23 @@ | ||
import MonsterAnalyzerCore | ||
|
||
extension SwipeAction { | ||
var label: String { | ||
switch self { | ||
case .none: | ||
String(localized: "None", comment: "SwipeActions/None") | ||
case .favorite: | ||
String(localized: "Favorite", comment: "SwipeActions/Favorite") | ||
} | ||
} | ||
} | ||
|
||
// MARK: - Identifiable | ||
|
||
extension SwipeAction: Identifiable { | ||
public var id: String { | ||
@inline(__always) | ||
get { | ||
rawValue | ||
} | ||
} | ||
} |
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,45 @@ | ||
import SwiftUI | ||
|
||
#if !os(macOS) | ||
|
||
@available(macOS, unavailable) | ||
struct FavoriteSwipeButton: View { | ||
@Binding | ||
private(set) var favorite: Bool | ||
|
||
var body: some View { | ||
let text: LocalizedStringKey, image: String | ||
if favorite { | ||
text = "Remove Favorite" | ||
image = "star.slash.fill" | ||
} else { | ||
text = "Add to Favorites" | ||
image = "star.fill" | ||
} | ||
|
||
return Button(text, systemImage: image) { | ||
favorite.toggle() | ||
} | ||
.tint(.yellow) | ||
} | ||
} | ||
|
||
#Preview("Favorite") { | ||
List { | ||
Text(verbatim: "Sample Context Menu") | ||
.swipeActions(edge: .trailing, allowsFullSwipe: false) { | ||
FavoriteSwipeButton(favorite: .constant(false)) | ||
} | ||
} | ||
} | ||
|
||
#Preview("Unfavorite") { | ||
List { | ||
Text(verbatim: "Sample Context Menu") | ||
.swipeActions(edge: .trailing, allowsFullSwipe: false) { | ||
FavoriteSwipeButton(favorite: .constant(true)) | ||
} | ||
} | ||
} | ||
|
||
#endif |
Oops, something went wrong.