Skip to content

Commit

Permalink
fix(prefs): add ios impl
Browse files Browse the repository at this point in the history
  • Loading branch information
liambutler-lawrence committed Aug 1, 2024
1 parent 33201b1 commit dbc3322
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 410 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,10 @@
"-DFOLLY_CFG_NO_COROUTINES=1",
"-DFOLLY_HAVE_CLOCK_GETTIME=1",
);
OTHER_LDFLAGS = "$(inherited) ";
OTHER_LDFLAGS = (
"$(inherited)",
" ",
);
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
SDKROOT = iphoneos;
USE_HERMES = false;
Expand Down Expand Up @@ -628,7 +631,10 @@
"-DFOLLY_CFG_NO_COROUTINES=1",
"-DFOLLY_HAVE_CLOCK_GETTIME=1",
);
OTHER_LDFLAGS = "$(inherited) ";
OTHER_LDFLAGS = (
"$(inherited)",
" ",
);
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
SDKROOT = iphoneos;
USE_HERMES = false;
Expand Down
6 changes: 3 additions & 3 deletions packages/npm/financekit/example/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PODS:
- boost (1.83.0)
- candlefinance-financekit (0.3.14):
- candlefinance-financekit (0.3.22):
- DoubleConversion
- glog
- RCT-Folly (= 2024.01.01.00)
Expand Down Expand Up @@ -1314,7 +1314,7 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
boost: d3f49c53809116a5d38da093a8aa78bf551aed09
candlefinance-financekit: 163bc73bfd7b8926c2c84cf55ad28989854c8088
candlefinance-financekit: f9a0683d4c3b1fc8945c42d8724f8dd8534e93fb
DoubleConversion: 76ab83afb40bddeeee456813d9c04f67f78771b5
FBLazyVector: 898d14d17bf19e2435cafd9ea2a1033efe445709
fmt: 4c2741a687cc09f0634a2e2c72a838b99f1ff120
Expand Down Expand Up @@ -1370,4 +1370,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 978a9588449ad9b8f7fc872a181d9140e7705193

COCOAPODS: 1.15.2
COCOAPODS: 1.14.3
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ class PrefsModule(reactContext: ReactApplicationContext) :
fun getPref(key: String, promise: Promise) {
try {
promise.resolve(sharedPreferences.getString(key, null))
} catch (e: ClassCastException) {
promise.reject(
CODE_NON_STRING_VALUE, MESSAGE_NON_STRING_VALUE, e
)
} catch (e: Exception) {
promise.reject(
CODE_UNEXPECTED, MESSAGE_UNEXPECTED, e
Expand Down Expand Up @@ -72,10 +76,13 @@ class PrefsModule(reactContext: ReactApplicationContext) :
const val NAME = "Prefs"

const val CODE_EDIT_COMMIT_FAILED = "@candlefinance.prefs.edit_commit_failed"
const val CODE_NON_STRING_VALUE = "@candlefinance.prefs.non_string_value"
const val CODE_UNEXPECTED = "@candlefinance.prefs.unexpected"

const val MESSAGE_EDIT_COMMIT_FAILED =
"SharedPreferences edit could not be committed. Please file an issue on GitHub or try again."
const val MESSAGE_NON_STRING_VALUE =
"SharedPreferences value was found, but is not a string. You can use deletePref() to remove the existing value and try again. If you're setting this value from native Android code, make sure to use putString()."
const val MESSAGE_UNEXPECTED =
"Something went wrong. Please file an issue on GitHub or try again."
}
Expand Down
8 changes: 4 additions & 4 deletions packages/npm/prefs/example/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PODS:
- boost (1.83.0)
- candlefinance-prefs (0.3.14):
- candlefinance-prefs (0.3.22):
- DoubleConversion
- glog
- RCT-Folly (= 2024.01.01.00)
Expand Down Expand Up @@ -1314,7 +1314,7 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
boost: d3f49c53809116a5d38da093a8aa78bf551aed09
candlefinance-prefs: 163bc73bfd7b8926c2c84cf55ad28989854c8088
candlefinance-prefs: c8c40d2f240a9863a4007961eb619e2811ee2a06
DoubleConversion: 76ab83afb40bddeeee456813d9c04f67f78771b5
FBLazyVector: 898d14d17bf19e2435cafd9ea2a1033efe445709
fmt: 4c2741a687cc09f0634a2e2c72a838b99f1ff120
Expand Down Expand Up @@ -1368,6 +1368,6 @@ SPEC CHECKSUMS:
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
Yoga: 348f8b538c3ed4423eb58a8e5730feec50bce372

PODFILE CHECKSUM: 978a9588449ad9b8f7fc872a181d9140e7705193
PODFILE CHECKSUM: 27ba4f851636a15e1da45729e0af04ae188312fd

COCOAPODS: 1.15.2
COCOAPODS: 1.14.3
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,10 @@
"-DFOLLY_CFG_NO_COROUTINES=1",
"-DFOLLY_HAVE_CLOCK_GETTIME=1",
);
OTHER_LDFLAGS = "$(inherited) ";
OTHER_LDFLAGS = (
"$(inherited)",
" ",
);
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
SDKROOT = iphoneos;
USE_HERMES = false;
Expand Down Expand Up @@ -628,7 +631,10 @@
"-DFOLLY_CFG_NO_COROUTINES=1",
"-DFOLLY_HAVE_CLOCK_GETTIME=1",
);
OTHER_LDFLAGS = "$(inherited) ";
OTHER_LDFLAGS = (
"$(inherited)",
" ",
);
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
SDKROOT = iphoneos;
USE_HERMES = false;
Expand Down
14 changes: 3 additions & 11 deletions packages/npm/prefs/ios/Prefs.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,9 @@

@interface RCT_EXTERN_MODULE(Prefs, NSObject)

RCT_EXTERN_METHOD(requestAuthorization:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(authorizationStatus:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(transactions:(NSString *)stringifiedQuery withResolver:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(transactionHistory:(NSString *)stringifiedParams withResolver:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(accounts:(NSString *)stringifiedQuery withResolver:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(accountHistory:(NSString *)stringifiedParams withResolver:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(accountBalances:(NSString *)stringifiedQuery withResolver:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(accountBalanceHistory:(NSString *)stringifiedParams withResolver:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(getPref:(NSString *)key withResolver:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(setPref:(NSString *)key toValue:(NSString *)value withResolver:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(deletePref:(NSString *)key withResolver:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject)

+ (BOOL)requiresMainQueueSetup
{
Expand Down
Loading

0 comments on commit dbc3322

Please sign in to comment.