Skip to content
Merged
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
8 changes: 4 additions & 4 deletions Bitkit/BitkitApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import SwiftUI

// MARK: - Quick Action Notification

// Communication bridge between delegates and SwiftUI views
/// Communication bridge between delegates and SwiftUI views
extension Notification.Name {
static let quickActionSelected = Notification.Name("quickActionSelected")
}
Expand All @@ -28,7 +28,7 @@ class AppDelegate: NSObject, UIApplicationDelegate {

// MARK: - Scene Configuration

// Required for SwiftUI apps to handle quick actions
/// Required for SwiftUI apps to handle quick actions
func application(
_ application: UIApplication,
configurationForConnecting connectingSceneSession: UISceneSession,
Expand Down Expand Up @@ -58,7 +58,7 @@ extension AppDelegate: UNUserNotificationCenterDelegate {
Logger.error("🔔 AppDelegate: didFailToRegisterForRemoteNotificationsWithError: \(error)")
}

// Foreground notification presentation
/// Foreground notification presentation
func userNotificationCenter(
_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
Expand All @@ -73,7 +73,7 @@ extension AppDelegate: UNUserNotificationCenterDelegate {
completionHandler([[.banner, .badge, .sound]])
}

// Handle taps on notifications
/// Handle taps on notifications
func userNotificationCenter(
_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
Expand Down
6 changes: 3 additions & 3 deletions Bitkit/Components/Button/Button.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ struct CustomButton: View {

@State private var isPressed = false

// Base initializer for optional action
/// Base initializer for optional action
init(
title: String,
variant: Variant = .primary,
Expand All @@ -93,7 +93,7 @@ struct CustomButton: View {
destination = nil
}

// Trailing closure initializer
/// Trailing closure initializer
init(
title: String,
variant: Variant = .primary,
Expand All @@ -117,7 +117,7 @@ struct CustomButton: View {
destination = nil
}

// Navigation link initializer
/// Navigation link initializer
init(
title: String,
variant: Variant = .primary,
Expand Down
4 changes: 2 additions & 2 deletions Bitkit/Components/CircularIcon.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ struct CircularIcon: View {
let backgroundColor: Color
let size: CGFloat

// Initializer for string icons
/// Initializer for string icons
init(icon: String, iconColor: Color = .white, backgroundColor: Color = .white10, size: CGFloat = 32) {
content = AnyView(
Image(icon)
Expand All @@ -18,7 +18,7 @@ struct CircularIcon: View {
self.size = size
}

// Initializer for view icons (direct View parameter)
/// Initializer for view icons (direct View parameter)
init(icon: some View, backgroundColor: Color = .white10, size: CGFloat = 32) {
content = AnyView(icon)
self.backgroundColor = backgroundColor
Expand Down
5 changes: 0 additions & 5 deletions Bitkit/Components/Core/ButtonLocationTracking.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ private struct ButtonLocationModifier: ViewModifier {
/// Callback when the view's location changes
let onLocationChanged: (CGRect) -> Void

init(coordinateSpace: String, onLocationChanged: @escaping (CGRect) -> Void) {
self.coordinateSpace = coordinateSpace
self.onLocationChanged = onLocationChanged
}
Comment thread
ovitrif marked this conversation as resolved.

func body(content: Content) -> some View {
content
.background(
Expand Down
6 changes: 3 additions & 3 deletions Bitkit/Components/Core/DraggableList.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import SwiftUI

/// Helper component that implements reorderable list functionality
struct DraggableList<Data, ID, Content>: View
where Data: RandomAccessCollection, ID: Hashable, Content: View, Data.Element: Identifiable
struct DraggableList<Data: RandomAccessCollection, ID: Hashable, Content: View>: View
where Data.Element: Identifiable
{
/// The data to render in the list
let data: Data
Expand Down Expand Up @@ -174,7 +174,7 @@ struct DraggableList<Data, ID, Content>: View
}
}

// Default initializer for DraggableList that uses Element.id
/// Default initializer for DraggableList that uses Element.id
extension DraggableList where ID == Data.Element.ID {
/// Convenience initializer that uses the element's id property
/// - Parameters:
Expand Down
6 changes: 3 additions & 3 deletions Bitkit/Components/DrawerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ enum DrawerMenuItem: Int, CaseIterable, Identifiable, Hashable {
case settings
case appStatus

var id: Int { rawValue }
var id: Int {
rawValue
}

var icon: String {
switch self {
Expand Down Expand Up @@ -81,7 +83,6 @@ struct DrawerView: View {
}
}

@ViewBuilder
private var backdrop: some View {
Color.black.opacity(0.6)
.ignoresSafeArea()
Expand Down Expand Up @@ -170,7 +171,6 @@ struct DrawerView: View {
}
}

@ViewBuilder
private func menuItemContent(item: DrawerMenuItem) -> some View {
VStack(alignment: .leading, spacing: 0) {
HStack(spacing: 12) {
Expand Down
4 changes: 2 additions & 2 deletions Bitkit/Components/Home/Suggestions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,13 @@ struct Suggestions: View {
@EnvironmentObject var suggestionsManager: SuggestionsManager

@State private var showShareSheet = false
// Prevent duplicate item taps when the card is dismissed
/// Prevent duplicate item taps when the card is dismissed
@State private var ignoringCardTaps = false

let cardSize: CGFloat = 152
let cardSpacing: CGFloat = 16

// Filter out cards that have already been completed or dismissed
/// Filter out cards that have already been completed or dismissed
private var filteredCards: [SuggestionCardData] {
cards.filter { card in
// Filter out completed actions
Expand Down
4 changes: 2 additions & 2 deletions Bitkit/Components/LightningChannel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,14 @@ struct LightningChannel: View {
}
}

// Extension to apply rounded corners to specific corners
/// Extension to apply rounded corners to specific corners
extension View {
func cornerRadius(_ radius: CGFloat, corners: UIRectCorner) -> some View {
clipShape(RoundedCornerShape(radius: radius, corners: corners))
}
}

// Custom shape for specific rounded corners
/// Custom shape for specific rounded corners
struct RoundedCornerShape: Shape {
var radius: CGFloat = .infinity
var corners: UIRectCorner = .allCorners
Expand Down
2 changes: 1 addition & 1 deletion Bitkit/Components/MoneyCell.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import SwiftUI

// MoneyCell - Cell/row style display for lists (right-aligned, compact layout)
/// MoneyCell - Cell/row style display for lists (right-aligned, compact layout)
struct MoneyCell: View {
let sats: Int
let prefix: String
Expand Down
2 changes: 1 addition & 1 deletion Bitkit/Components/MoneyStack.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import SwiftUI

// MoneyStack - Stacked display with toggle functionality, optional eye icon and swipe gestures
/// MoneyStack - Stacked display with toggle functionality, optional eye icon and swipe gestures
struct MoneyStack: View {
let sats: Int
var prefix: String?
Expand Down
2 changes: 1 addition & 1 deletion Bitkit/Components/MoneyText.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import SwiftUI

// MoneyText - Single text display component for monetary values
/// MoneyText - Single text display component for monetary values
enum MoneySize {
case display
case title
Expand Down
4 changes: 2 additions & 2 deletions Bitkit/Components/NodeStateView.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import LDKNode
import SwiftUI

// So we can iterate through the balances
/// So we can iterate through the balances
extension LightningBalance {
var channelIdString: String {
switch self {
Expand All @@ -16,7 +16,7 @@ extension LightningBalance {
}
}

// Create a wrapper struct that conforms to Identifiable
/// Create a wrapper struct that conforms to Identifiable
struct IdentifiableLightningBalance: Identifiable {
let id: String
let balance: LightningBalance
Expand Down
2 changes: 1 addition & 1 deletion Bitkit/Components/NumberPadTextField.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import SwiftUI

// NumberPadTextField - Amount view to be used with number pad
/// NumberPadTextField - Amount view to be used with number pad
struct NumberPadTextField: View {
@EnvironmentObject var currency: CurrencyViewModel
@ObservedObject var viewModel: AmountInputViewModel
Expand Down
5 changes: 0 additions & 5 deletions Bitkit/Components/RadioGroup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ struct RadioGroup<T: Hashable>: View {
struct RadioOption<T: Hashable> {
let title: String
let value: T

init(title: String, value: T) {
self.title = title
self.value = value
}
}

private struct RadioButton: View {
Expand Down
3 changes: 1 addition & 2 deletions Bitkit/Components/ShareSheet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ struct ShareSheet: UIViewControllerRepresentable {
let activityItems: [Any]

func makeUIViewController(context: Context) -> UIActivityViewController {
let controller = UIActivityViewController(
return UIActivityViewController(
activityItems: activityItems,
applicationActivities: nil
)
return controller
}

func updateUIViewController(_ uiViewController: UIActivityViewController, context: Context) {}
Expand Down
20 changes: 3 additions & 17 deletions Bitkit/Components/SnapCarousel.swift
Original file line number Diff line number Diff line change
@@ -1,26 +1,12 @@
import SwiftUI

// UIKit Scroll View for better snapping behavior
/// UIKit Scroll View for better snapping behavior
struct SnapCarousel<Item: Identifiable, Content: View>: UIViewRepresentable {
var items: [Item]
var itemSize: CGFloat
var itemSpacing: CGFloat
var onItemTap: (Item) -> Void
var content: (Item) -> Content

init(
items: [Item],
itemSize: CGFloat,
itemSpacing: CGFloat,
onItemTap: @escaping (Item) -> Void,
@ViewBuilder content: @escaping (Item) -> Content
) {
self.items = items
self.itemSize = itemSize
self.itemSpacing = itemSpacing
self.onItemTap = onItemTap
self.content = content
}
@ViewBuilder var content: (Item) -> Content

func makeCoordinator() -> Coordinator {
Coordinator(self)
Expand Down Expand Up @@ -102,7 +88,7 @@ struct SnapCarousel<Item: Identifiable, Content: View>: UIViewRepresentable {
}
}

// Snap to the nearest item when scrolling ends
/// Snap to the nearest item when scrolling ends
func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>)
{
let itemWidthWithSpacing = parent.itemSize + parent.itemSpacing
Expand Down
1 change: 0 additions & 1 deletion Bitkit/Components/Tags/Tag.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ struct Tag: View {
self.onDelete = onDelete
}

@ViewBuilder
private var tagContent: some View {
HStack(spacing: 0) {
BodySSBText(value).lineLimit(1)
Expand Down
2 changes: 1 addition & 1 deletion Bitkit/Components/Widgets/BaseWidget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ struct WidgetButtonStyle: ButtonStyle {
}
}

/// Preview for the BaseWidget
// Preview for the BaseWidget
#Preview {
VStack {
BaseWidget(
Expand Down
2 changes: 1 addition & 1 deletion Bitkit/Components/Widgets/WidgetListItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ struct WidgetListItem: View {
@EnvironmentObject private var navigation: NavigationViewModel
@EnvironmentObject private var currency: CurrencyViewModel

// Widget data computed from the ID
/// Widget data computed from the ID
private var widget: (name: String, description: String, icon: String) {
let name = t("widgets__\(id.rawValue)__name")

Expand Down
2 changes: 1 addition & 1 deletion Bitkit/Constants/Env.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ enum Env {
return isNotificationExtension ? .pushNotificationExtension : .foregroundApp
}

// {Team ID}.{Keychain Group}
/// {Team ID}.{Keychain Group}
/// Returns the keychain access group based on the current network
static var keychainGroup: String {
let base = "KYH47R284B.to.bitkit"
Expand Down
9 changes: 7 additions & 2 deletions Bitkit/Extensions/HexBytes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@ extension Data {
}

extension StringProtocol {
var hexaData: Data { .init(hexa) }
var hexaBytes: [UInt8] { .init(hexa) }
var hexaData: Data {
.init(hexa)
}

var hexaBytes: [UInt8] {
.init(hexa)
}

private var hexa: UnfoldSequence<UInt8, Index> {
sequence(state: startIndex) { startIndex in
Expand Down
2 changes: 1 addition & 1 deletion Bitkit/Extensions/View+SafeArea.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var hasHomeIndicator: Bool {
return window.safeAreaInsets.bottom > 0
}

// For phones without a home indicator, we add padding to the bottom of the view
/// For phones without a home indicator, we add padding to the bottom of the view
struct BottomSafeAreaPadding: ViewModifier {
func body(content: Content) -> some View {
content
Expand Down
1 change: 0 additions & 1 deletion Bitkit/MainNavView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@ struct MainNavView: View {

// MARK: - Computed Properties for Better Organization

@ViewBuilder
private var navigationContent: some View {
Group {
switch navigation.activeDrawerMenuItem {
Expand Down
4 changes: 1 addition & 3 deletions Bitkit/Managers/BalanceManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -239,12 +239,10 @@ class BalanceManager {

/// Calculates maximum sendable Lightning amount (outbound capacity)
private func calculateMaxSendLightning(channels: [ChannelDetails]) -> UInt64 {
let totalNextOutboundHtlcLimitSats = channels
return channels
.filter(\.isUsable)
.map(\.nextOutboundHtlcLimitMsat)
.reduce(0, +) / 1000 // Convert from msat to sat

return totalNextOutboundHtlcLimitSats
}
}

Expand Down
8 changes: 4 additions & 4 deletions Bitkit/Managers/NetworkMonitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ import SwiftUI

@MainActor
final class NetworkMonitor: ObservableObject {
// This will be used to track the network connectivity
/// This will be used to track the network connectivity
@Published
var isConnected = true

// This will be used to track if the network is expensive (e.g. cellular data)
/// This will be used to track if the network is expensive (e.g. cellular data)
@Published
var isExpensive = false

@Published
var networkType: NWInterface.InterfaceType? = .other

// This will be used to track the network path (e.g. Wi-Fi, cellular data, etc.)
/// This will be used to track the network path (e.g. Wi-Fi, cellular data, etc.)
@Published
var nwPath: NWPath?

// Create an instance of NWPathMonitor
/// Create an instance of NWPathMonitor
let monitor = NWPathMonitor()

init() {
Expand Down
Loading
Loading