Skip to content

Instantly share code, notes, and snippets.

View hurali97's full-sized avatar
🎯
Focusing

Muhammad Hur Ali hurali97

🎯
Focusing
View GitHub Profile
@hurali97
hurali97 / App.tsx
Created February 13, 2024 07:26
App file for Callstack Blog
import React, {useState} from 'react';
import {
SafeAreaView,
StatusBar,
StyleSheet,
Text,
TouchableOpacity,
useColorScheme,
useWindowDimensions,
View,
#import "RCTDlog.h"
@implementation RCTDlog
RCT_EXPORT_MODULE(Dlog);
- (void)log:(NSString *)message {
NSLog(@"%@",message);
}
#import "CustomModules/CustomModules.h"
@interface RCTDlog: NSObject <NativeDlogSpec>
@end
"codegenConfig": {
"libraries": [
{
"name": "CustomModules",
"type": "modules",
"jsSrcsDir": "src/custom-modules/specs/"
}
]
}
#include "MainApplicationModuleProvider.h"
#include <rncore.h>
#include <CustomModules.h> // Add this line
namespace facebook {
namespace react {
std::shared_ptr<TurboModule> MainApplicationModuleProvider(
const std::string moduleName,
@hurali97
hurali97 / Android.mk
Last active July 19, 2022 19:29
Updated configuration
THIS_DIR := $(call my-dir)
include $(REACT_ANDROID_DIR)/Android-prebuilt.mk
# If you wish to add a custom TurboModule or Fabric component in your app you
# will have to include the following autogenerated makefile.
include $(GENERATED_SRC_DIR)/codegen/jni/Android.mk
include $(CLEAR_VARS)
LOCAL_PATH := $(THIS_DIR)
@hurali97
hurali97 / MainApplicationReactNativeHost.java
Last active July 19, 2022 20:54
Updated getPackages method for MainApplicationReactNativeHost
import com.facebook.react.TurboReactPackage;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.module.model.ReactModuleInfoProvider;
import com.facebook.react.module.model.ReactModuleInfo;
import java.util.HashMap;
import java.util.Map;
import com.rearchdemo.custommodules.Dlog;
import androidx.annotation.Nullable;
@hurali97
hurali97 / Dlog.java
Created April 12, 2022 21:19
Dlog module file which inherits NativeDlogSpec.java
package com.rearchdemo.custommodules;
import com.facebook.react.bridge.ReactApplicationContext;
import android.util.Log;
public class Dlog extends NativeDlogSpec {
private static final String TAG = "Dlog";
public static final String NAME = "Dlog";
@Override
public String getName() {
apply plugin: "com.android.application"
// Add the following
if (isNewArchitectureEnabled()) {
apply plugin: "com.facebook.react"
}
android {
// everything else
if (isNewArchitectureEnabled()) {
// everything else
@hurali97
hurali97 / NativeDlog.ts
Last active August 12, 2022 08:34
Spec file for our NativeDlog
import type {TurboModule} from 'react-native';
import {TurboModuleRegistry} from 'react-native';
export interface Spec extends TurboModule {
log(message: string): void;
}
export default TurboModuleRegistry.get<Spec>('Dlog');