-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into chore/bump-3.8.1
- Loading branch information
Showing
27 changed files
with
952 additions
and
376 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
2 changes: 1 addition & 1 deletion
2
Example/FlagsmithClient.xcodeproj/xcshareddata/xcschemes/FlagsmithClient_Example.xcscheme
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,68 @@ | ||
// | ||
// SwiftUIView.swift | ||
// FlagsmithClient_Example | ||
// | ||
// Created by Gareth Reese on 16/09/2024. | ||
// Copyright © 2024 CocoaPods. All rights reserved. | ||
// | ||
|
||
#if canImport(SwiftUI) | ||
import SwiftUI | ||
#endif | ||
import FlagsmithClient | ||
|
||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) | ||
struct SwiftUIView: View { | ||
@State private var flags: [Flag] = [] | ||
@State private var isLoading = true | ||
|
||
let flagsmith = Flagsmith.shared | ||
|
||
var body: some View { | ||
VStack { | ||
if isLoading { | ||
ProgressView() | ||
} else { | ||
Text("Feature Flags") | ||
.font(.title) | ||
.padding() | ||
List(flags, id: \.feature.name) { flag in | ||
HStack { | ||
Text("\(flag.feature.name): \(flag.value)") | ||
Spacer() | ||
Text("\(flag.enabled ? "✅" : "❌")") | ||
} | ||
} | ||
} | ||
} | ||
.onAppear { | ||
initializeFlagsmith() | ||
subscribeToFlagUpdates() | ||
} | ||
} | ||
|
||
func initializeFlagsmith() { | ||
// Fetch initial flags | ||
flagsmith.getFeatureFlags { result in | ||
DispatchQueue.main.async { | ||
switch result { | ||
case .success(let fetchedFlags): | ||
flags = fetchedFlags | ||
case .failure(let error): | ||
print("Error fetching flags: \(error)") | ||
} | ||
isLoading = false | ||
} | ||
} | ||
} | ||
|
||
func subscribeToFlagUpdates() { | ||
Task { | ||
for await updatedFlags in flagsmith.flagStream { | ||
DispatchQueue.main.async { | ||
flags = updatedFlags | ||
} | ||
} | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.