Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 48 additions & 4 deletions Bitkit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
4A319B512E8F24F2002B9AC9 /* WidgetKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4A319B502E8F24F2002B9AC9 /* WidgetKit.framework */; };
4A319B532E8F24F2002B9AC9 /* SwiftUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4A319B522E8F24F2002B9AC9 /* SwiftUI.framework */; };
4A319B622E8F24F4002B9AC9 /* BitkitWidgetExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 4A319B4F2E8F24F2002B9AC9 /* BitkitWidgetExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
4A319B702E8F2600002B9AC9 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 4A319B712E8F2600002B9AC9 /* Localizable.strings */; };
4AAB08CA2E1FE77600BA63DF /* Lottie in Frameworks */ = {isa = PBXBuildFile; productRef = 4AAB08C92E1FE77600BA63DF /* Lottie */; };
961058E32C355B5500E1F1D8 /* BitkitNotification.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 961058DC2C355B5500E1F1D8 /* BitkitNotification.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
968FDF162DFAFE230053CD7F /* LDKNode in Frameworks */ = {isa = PBXBuildFile; productRef = 9613018B2C5022D700878183 /* LDKNode */; };
Expand Down Expand Up @@ -79,6 +80,21 @@
4A319B502E8F24F2002B9AC9 /* WidgetKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WidgetKit.framework; path = System/Library/Frameworks/WidgetKit.framework; sourceTree = SDKROOT; };
4A319B522E8F24F2002B9AC9 /* SwiftUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftUI.framework; path = System/Library/Frameworks/SwiftUI.framework; sourceTree = SDKROOT; };
4A319B6E2E8F25F6002B9AC9 /* BitkitWidgetExtension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = BitkitWidgetExtension.entitlements; sourceTree = "<group>"; };
4A319B722E8F2600002B9AC9 /* ar */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ar; path = Bitkit/Resources/Localization/ar.lproj/Localizable.strings; sourceTree = SOURCE_ROOT; };
4A319B732E8F2600002B9AC9 /* ca */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ca; path = Bitkit/Resources/Localization/ca.lproj/Localizable.strings; sourceTree = SOURCE_ROOT; };
4A319B742E8F2600002B9AC9 /* cs */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = cs; path = Bitkit/Resources/Localization/cs.lproj/Localizable.strings; sourceTree = SOURCE_ROOT; };
4A319B752E8F2600002B9AC9 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = Bitkit/Resources/Localization/de.lproj/Localizable.strings; sourceTree = SOURCE_ROOT; };
4A319B762E8F2600002B9AC9 /* el */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = el; path = Bitkit/Resources/Localization/el.lproj/Localizable.strings; sourceTree = SOURCE_ROOT; };
4A319B772E8F2600002B9AC9 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = Bitkit/Resources/Localization/en.lproj/Localizable.strings; sourceTree = SOURCE_ROOT; };
4A319B782E8F2600002B9AC9 /* es-419 */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "es-419"; path = "Bitkit/Resources/Localization/es-419.lproj/Localizable.strings"; sourceTree = SOURCE_ROOT; };
4A319B792E8F2600002B9AC9 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = Bitkit/Resources/Localization/es.lproj/Localizable.strings; sourceTree = SOURCE_ROOT; };
4A319B7A2E8F2600002B9AC9 /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = Bitkit/Resources/Localization/fr.lproj/Localizable.strings; sourceTree = SOURCE_ROOT; };
4A319B7B2E8F2600002B9AC9 /* it */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = it; path = Bitkit/Resources/Localization/it.lproj/Localizable.strings; sourceTree = SOURCE_ROOT; };
4A319B7C2E8F2600002B9AC9 /* nl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nl; path = Bitkit/Resources/Localization/nl.lproj/Localizable.strings; sourceTree = SOURCE_ROOT; };
4A319B7D2E8F2600002B9AC9 /* pl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pl; path = Bitkit/Resources/Localization/pl.lproj/Localizable.strings; sourceTree = SOURCE_ROOT; };
4A319B7E2E8F2600002B9AC9 /* pt-BR */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "pt-BR"; path = "Bitkit/Resources/Localization/pt-BR.lproj/Localizable.strings"; sourceTree = SOURCE_ROOT; };
4A319B7F2E8F2600002B9AC9 /* pt */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pt; path = Bitkit/Resources/Localization/pt.lproj/Localizable.strings; sourceTree = SOURCE_ROOT; };
4A319B802E8F2600002B9AC9 /* ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ru; path = Bitkit/Resources/Localization/ru.lproj/Localizable.strings; sourceTree = SOURCE_ROOT; };
961058DC2C355B5500E1F1D8 /* BitkitNotification.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = BitkitNotification.appex; sourceTree = BUILT_PRODUCTS_DIR; };
96FE1F612C2DE6AA006D0C8B /* Bitkit.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Bitkit.app; sourceTree = BUILT_PRODUCTS_DIR; };
96FE1F722C2DE6AC006D0C8B /* BitkitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = BitkitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -177,6 +193,7 @@
Models/BlocksWidgetData.swift,
Models/BlocksWidgetFields.swift,
Models/BlocksWidgetOptions.swift,
Models/BitcoinFacts.swift,
Models/NewsWidgetData.swift,
Models/NewsWidgetOptions.swift,
Models/PriceWidgetData.swift,
Expand Down Expand Up @@ -274,6 +291,7 @@
96A44F562CEF5F5400FBACFF /* BitkitUITests */,
96A44F5C2CEF5F5800FBACFF /* BitkitNotification */,
4A319B542E8F24F2002B9AC9 /* BitkitWidget */,
4A319B712E8F2600002B9AC9 /* Localizable.strings */,
96FE1F622C2DE6AA006D0C8B /* Products */,
961058EC2C35798C00E1F1D8 /* Frameworks */,
);
Expand Down Expand Up @@ -496,6 +514,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
4A319B702E8F2600002B9AC9 /* Localizable.strings in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -529,6 +548,31 @@
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXVariantGroup section */
4A319B712E8F2600002B9AC9 /* Localizable.strings */ = {
isa = PBXVariantGroup;
children = (
4A319B722E8F2600002B9AC9 /* ar */,
4A319B732E8F2600002B9AC9 /* ca */,
4A319B742E8F2600002B9AC9 /* cs */,
4A319B752E8F2600002B9AC9 /* de */,
4A319B762E8F2600002B9AC9 /* el */,
4A319B772E8F2600002B9AC9 /* en */,
4A319B782E8F2600002B9AC9 /* es-419 */,
4A319B792E8F2600002B9AC9 /* es */,
4A319B7A2E8F2600002B9AC9 /* fr */,
4A319B7B2E8F2600002B9AC9 /* it */,
4A319B7C2E8F2600002B9AC9 /* nl */,
4A319B7D2E8F2600002B9AC9 /* pl */,
4A319B7E2E8F2600002B9AC9 /* pt-BR */,
4A319B7F2E8F2600002B9AC9 /* pt */,
4A319B802E8F2600002B9AC9 /* ru */,
);
name = Localizable.strings;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */

/* Begin PBXShellScriptBuildPhase section */
96EMBED0012026012000FRAME /* Remove Static Framework Stubs */ = {
isa = PBXShellScriptBuildPhase;
Expand Down Expand Up @@ -621,7 +665,7 @@
ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground;
CODE_SIGN_ENTITLEMENTS = BitkitWidgetExtension.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 186;
CURRENT_PROJECT_VERSION = 187;
DEVELOPMENT_TEAM = KYH47R284B;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = BitkitWidget/Info.plist;
Expand All @@ -633,7 +677,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 2.2.0;
MARKETING_VERSION = 2.2.1;
PRODUCT_BUNDLE_IDENTIFIER = "to.bitkit.widget";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
Expand All @@ -654,7 +698,7 @@
ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground;
CODE_SIGN_ENTITLEMENTS = BitkitWidgetExtension.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 186;
CURRENT_PROJECT_VERSION = 187;
DEVELOPMENT_TEAM = KYH47R284B;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = BitkitWidget/Info.plist;
Expand All @@ -666,7 +710,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 2.2.0;
MARKETING_VERSION = 2.2.1;
PRODUCT_BUNDLE_IDENTIFIER = "to.bitkit.widget";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"images" : [
{
"filename" : "btc.pdf",
"filename" : "bitcoin.pdf",
"idiom" : "universal"
}
],
Expand Down
Binary file not shown.
87 changes: 43 additions & 44 deletions Bitkit/Components/Widgets/FactsWidget.swift
Original file line number Diff line number Diff line change
@@ -1,45 +1,17 @@
import SwiftUI

/// Options for configuring the FactsWidget
struct FactsWidgetOptions: Codable, Equatable {
var showSource: Bool = true
}

struct FactsWidget: View {
/// Configuration options for the widget
var options: FactsWidgetOptions = .init()

/// Flag indicating if the widget is in editing mode
var isEditing: Bool = false

/// Callback to signal when editing should end
var onEditingEnd: (() -> Void)?

/// View model for handling facts data
@StateObject private var viewModel = FactsViewModel.shared

/// Initialize the widget
init(
options: FactsWidgetOptions = FactsWidgetOptions(),
isEditing: Bool = false,
onEditingEnd: (() -> Void)? = nil
) {
self.options = options
self.isEditing = isEditing
self.onEditingEnd = onEditingEnd
}

/// Initialize with a custom view model (for previews)
init(
viewModel: FactsViewModel,
options: FactsWidgetOptions = FactsWidgetOptions(),
isEditing: Bool = false,
onEditingEnd: (() -> Void)? = nil
) {
self.options = options
self.isEditing = isEditing
self.onEditingEnd = onEditingEnd
_viewModel = StateObject(wrappedValue: viewModel)
}

var body: some View {
Expand All @@ -48,30 +20,57 @@ struct FactsWidget: View {
isEditing: isEditing,
onEditingEnd: onEditingEnd
) {
VStack(spacing: 0) {
TitleText(viewModel.fact)
.lineLimit(2)
.frame(maxWidth: .infinity, alignment: .leading)
FactsWidgetWideContent(fact: viewModel.fact)
}
}
}

if options.showSource {
WidgetContentBuilder.sourceRow(source: "synonym.to")
}
}
struct FactsWidgetWideContent: View {
let fact: String

var body: some View {
HStack(alignment: .top, spacing: 32) {
TitleText(fact)
.lineLimit(4)
.frame(maxWidth: .infinity, alignment: .leading)

BitcoinLogo()
}
.frame(maxWidth: .infinity, alignment: .leading)
}
}

struct FactsWidgetCompactContent: View {
let fact: String

var body: some View {
BodyMSBText(fact)
.lineLimit(4)
.frame(maxWidth: .infinity, alignment: .leading)
.minimumScaleFactor(0.85)
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
.overlay(alignment: .bottomTrailing) {
BitcoinLogo()
}
.padding(16)
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
.background(Color.gray6)
.cornerRadius(16)
}
}

private struct BitcoinLogo: View {
var body: some View {
Image("bitcoin")
.resizable()
.frame(width: 32, height: 32)
}
}

#Preview {
VStack(spacing: 16) {
FactsWidget()

FactsWidget(
options: FactsWidgetOptions(showSource: false)
)

FactsWidget(
isEditing: true
)
FactsWidget(isEditing: true)
}
.padding()
.background(Color.black)
Expand Down
2 changes: 2 additions & 0 deletions Bitkit/MainNavView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,8 @@ struct MainNavView: View {
NewsWidgetPreviewView()
case .blocks:
BlocksWidgetPreviewView()
case .facts:
FactsWidgetPreviewView()
default:
WidgetDetailView(id: widgetType)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,7 @@
import Foundation

/// Service for managing Bitcoin facts
class FactsService {
static let shared = FactsService()

private init() {}

/// Returns a random Bitcoin fact
/// - Returns: A Bitcoin fact string
func getRandomFact() -> String {
return facts.randomElement()!
}

/// Returns all available Bitcoin facts
/// - Returns: Array of Bitcoin facts
func getAllFacts() -> [String] {
return facts
}

// MARK: - Private Properties

private let facts = [
enum BitcoinFacts {
static let all = [
"Satoshi Nakamoto mined more than 1M Bitcoin.",
"You don't need permission to use Bitcoin.",
"You don't need a bank account to use Bitcoin.",
Expand All @@ -36,7 +17,7 @@ class FactsService {
"The largest transaction was 500,000 bitcoin.",
"Bitcoin is legal tender in El Salvador.",
"Not your keys, not your coins.",
"Bitcoin is the network, bitcoin is the currency.",
"'Bitcoin' is the network, 'bitcoin' is the currency.",
"Bitcoin was not the first digital currency.",
"Bitcoin was first created with 31,000 lines of code.",
"Bitcoin does not have a CEO.",
Expand All @@ -48,10 +29,10 @@ class FactsService {
"The identity of Bitcoin's inventor is unknown.",
"If you lose your keys, you lose your coins.",
"Bitcoins don't grow on trees.",
"There can only be 21 million bitcoins. ",
"There can only be 21 million bitcoins.",
"Bitcoins are created when a block is mined.",
"One bitcoin is 100,000,000 satoshis.",
"The smallest unit of Bitcoin is a satoshi.",
"The smallest unit of Bitcoin is a \"satoshi.\"",
"Bitcoins live on the blockchain, not in wallets.",
"You can hold keys, but you cannot hold bitcoin.",
"Private keys allow you to sign transactions.",
Expand Down Expand Up @@ -84,7 +65,7 @@ class FactsService {
"The genesis block reward is not spendable.",
"You can count 1 day of blocks on 2 hands.",
"There are enough sats for everyone.",
"More computing power more bitcoin.",
"More computing power != more bitcoin.",
"Bitcoin doesn't need your personal info.",
"Satoshi considered calling it Netcoin.",
]
Expand Down
15 changes: 0 additions & 15 deletions Bitkit/Services/MigrationsService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,6 @@ private struct MigrationNewsWidgetOptions: Codable {
var showSource: Bool
}

private struct MigrationFactsWidgetOptions: Codable {
var showSource: Bool
}

// MARK: - RN Migration Keys

enum RNKeychainKey {
Expand Down Expand Up @@ -1961,17 +1957,6 @@ extension MigrationsService {
}
}

let factsPrefs = (widgetsDict["factsPreferences"] as? [String: Any])
?? (widgetsDict["facts"] as? [String: Any])
if let prefs = factsPrefs {
let options = MigrationFactsWidgetOptions(
showSource: getBool(from: prefs, key: "showSource", defaultValue: false)
)
if let data = try? JSONEncoder().encode(options) {
result["facts"] = data
}
}

return result
}
}
Expand Down
1 change: 1 addition & 0 deletions Bitkit/Styles/Colors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ extension Color {
static let redAccent = Color(hex: 0xE95164)
static let yellowAccent = Color(hex: 0xFFD200)
static let pubkyGreen = Color(hex: 0xBEFF00)
static let bitcoin = Color(hex: 0xF7931A)

// MARK: - Base

Expand Down
Loading
Loading