Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.9.6 #1217

Merged
merged 19 commits into from
Nov 6, 2023
Merged

1.9.6 #1217

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
66 changes: 66 additions & 0 deletions .swiftpm/xcode/xcshareddata/xcschemes/Database.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1500"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "Database"
BuildableName = "Database"
BlueprintName = "Database"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "Database"
BuildableName = "Database"
BlueprintName = "Database"
ReferencedContainer = "container:">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
4 changes: 3 additions & 1 deletion Example/IntegrationTests/Push/NotifyTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,11 @@ final class NotifyTests: XCTestCase {
keychainStorage: keychain,
environment: .sandbox)
let keyserverURL = URL(string: "https://keys.walletconnect.com")!
let sqlite = try! MemorySqlite()
// Note:- prod project_id do not exists on staging, we can use gmDappProjectId
let client = NotifyClientFactory.create(projectId: InputConfig.gmDappProjectId,
keyserverURL: keyserverURL,
keyserverURL: keyserverURL,
sqlite: sqlite,
logger: notifyLogger,
keyValueStorage: keyValueStorage,
keychainStorage: keychain,
Expand Down
2 changes: 1 addition & 1 deletion Example/WalletApp/ApplicationLayer/LoggingService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ final class LoggingService {
SentrySDK.capture(error: LoggingError.networking(log.aggregated))
case .warn(let log):
// Example of setting level to warning
var event = Event(level: .warning)
let event = Event(level: .warning)
event.message = SentryMessage(formatted: log.aggregated)
SentrySDK.capture(event: event)
default:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "subscription_empty_icon.png",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "subscriptions_empty_background.png",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "subscriptions_empty_icon.svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,51 @@ struct NotificationsView: View {
List {
Section {
if selectedIndex == 0 {
notifications()
if presenter.subscriptionViewModels.isEmpty {
emptySubscriptionsView()
} else {
notifications()
}
} else {
discover()
}
} header: {
HStack {
SegmentedPicker(["Notifications", "Discover"],
selectedIndex: Binding(
get: { selectedIndex },
set: { selectedIndex = $0 ?? 0 }),
content: { item, isSelected in
Text(item)
.font(.system(size: 16, weight: .medium))
.foregroundColor(isSelected ? Color.primary : Color.secondary )
.padding(.trailing, 32)
.padding(.vertical, 8)
}, selection: {
VStack(spacing: 0) {
Spacer()
Rectangle()
.fill(.Blue100)
.frame(height: 2)
VStack(spacing: 0) {
HStack {
SegmentedPicker(["Subscriptions", "Discover"],
selectedIndex: Binding(
get: { selectedIndex },
set: { selectedIndex = $0 ?? 0 }),
content: { item, isSelected in
Text(item)
.font(.system(size: 16, weight: .medium))
.foregroundColor(isSelected ? Color.primary : Color.secondary )
.padding(.trailing, 32)
}
})
.padding(.vertical, 8)
}, selection: {
VStack(spacing: 0) {
Spacer()
Rectangle()
.fill(.Blue100)
.frame(height: 2)
.padding(.trailing, 32)
}
})
.padding(.horizontal, 20)
.animation(.easeInOut(duration: 0.3))

Spacer()
}

Rectangle()
.foregroundColor(.black.opacity(0.03))
.frame(maxWidth: .infinity)
.frame(height: 1)
}
.animation(.easeInOut(duration: 0.3))
.listRowBackground(Color.clear)
}
.listRowInsets(EdgeInsets())
.listRowSeparator(.hidden)
}
.listStyle(PlainListStyle())
}
Expand All @@ -57,28 +73,37 @@ struct NotificationsView: View {
discoverListRow(listing: listing)
.listRowSeparator(.hidden)
.listRowBackground(Color.clear)
.listRowInsets(EdgeInsets(top: 16, leading: 20, bottom: 0, trailing: 20))
}
}

private func emptySubscriptionsView() -> some View {
VStack(spacing: 10) {
Spacer()

Image(systemName: "bell.badge.fill")
ZStack {
Image("subscriptions_empty_background")
.resizable()
.frame(width: 32, height: 32)
.aspectRatio(contentMode: .fit)
.foregroundColor(.grey50)
.frame(maxWidth: .infinity)
.ignoresSafeArea()

Text("Notifications from connected apps will appear here. To enable notifications, visit the app in your browser and look for a \(Image(systemName: "bell.fill")) notifications toggle \(Image(systemName: "switch.2"))")
.foregroundColor(.grey50)
.font(.system(size: 15, weight: .regular, design: .rounded))
.multilineTextAlignment(.center)
.lineSpacing(4)
VStack(spacing: 0) {
Image("subscriptions_empty_icon")

Spacer()
Text("Add your first app")
.foregroundColor(.Foreground100)
.font(.large700)
.padding(.bottom, 8.0)

Text("Head over to “Discover” and\nsubscribe to one of our apps to start\nreceiving notifications")
.multilineTextAlignment(.center)
.foregroundColor(.Foreground200)
.font(.paragraph500)
.padding(.bottom, 16.0)

Button("Discover apps") {
selectedIndex = 1
}
.buttonStyle(W3MButtonStyle(size: .m, variant: .main))
}
}
.padding(20)
}

private func notifications() -> some View {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import SwiftUI
import Web3ModalUI

struct SubscriptionView: View {

Expand Down Expand Up @@ -140,20 +141,21 @@ struct SubscriptionView: View {
}

func emptyStateView() -> some View {
VStack(spacing: 10) {
Image(systemName: "bell.badge.fill")
.resizable()
.frame(width: 32, height: 32)
.aspectRatio(contentMode: .fit)
.foregroundColor(.grey50)

Text("Notifications from connected apps will appear here. To enable notifications, visit the app in your browser and look for a \(Image(systemName: "bell.fill")) notifications toggle \(Image(systemName: "switch.2"))")
.foregroundColor(.grey50)
.font(.system(size: 15, weight: .regular, design: .rounded))
.multilineTextAlignment(.center)
.lineSpacing(4)
VStack(spacing: 0) {
Image("subscription_empty_icon")
.padding(.bottom, 24)

Text("You’re ready to go")
.font(.large700)
.foregroundColor(.Foreground100)
.padding(.bottom, 8)

Text("All new notifications will appear here.")
.font(.paragraph500)
.foregroundColor(.Foreground150)
}
.padding(20)
.frame(maxWidth: .infinity)
.frame(height: 410)
}
}

Expand Down
5 changes: 4 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ let package = Package(
path: "Sources/Web3Wallet"),
.target(
name: "WalletConnectNotify",
dependencies: ["WalletConnectPairing", "WalletConnectPush", "WalletConnectIdentity", "WalletConnectSigner"],
dependencies: ["WalletConnectPairing", "WalletConnectPush", "WalletConnectIdentity", "WalletConnectSigner", "Database"],
path: "Sources/WalletConnectNotify"),
.target(
name: "WalletConnectPush",
Expand Down Expand Up @@ -130,6 +130,9 @@ let package = Package(
.target(
name: "WalletConnectVerify",
dependencies: ["WalletConnectUtils", "WalletConnectNetworking"]),
.target(
name: "Database",
dependencies: []),
.target(
name: "WalletConnectModal",
dependencies: ["QRCode", "WalletConnectSign"],
Expand Down
46 changes: 46 additions & 0 deletions Sources/Database/DiskSqlite.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import Foundation
import SQLite3

public final class DiskSqlite: Sqlite {

private let path: String

private var db: OpaquePointer?

public init(path: String) {
self.path = path
}

public func openDatabase() throws {
guard sqlite3_open_v2(path, &db, SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE|SQLITE_OPEN_FULLMUTEX, nil) == SQLITE_OK else {
throw SQLiteError.openDatabase(path: path)
}
}

public func query<Row: SqliteRow>(sql: String) throws -> [Row] {
var queryStatement: OpaquePointer?
guard sqlite3_prepare_v2(db, sql, -1, &queryStatement, nil) == SQLITE_OK else {
throw SQLiteError.queryPrepare(statement: sql)
}
var rows: [Row] = []
while sqlite3_step(queryStatement) == SQLITE_ROW {
let decoder = SqliteRowDecoder(statement: queryStatement)
guard let row = try? Row(decoder: decoder) else { continue }
rows.append(row)
}
sqlite3_finalize(queryStatement)
return rows
}

public func execute(sql: String) throws {
var error: UnsafeMutablePointer<CChar>?
guard sqlite3_exec(db, sql, nil, nil, &error) == SQLITE_OK else {
let message = error.map { String(cString: $0) }
throw SQLiteError.exec(error: message)
}
}

public func closeConnection() {
sqlite3_close(db)
}
}
Loading
Loading