Skip to content

Instantly share code, notes, and snippets.

View vshkl's full-sized avatar
😶‍🌫️

Pavel Vashkel vshkl

😶‍🌫️
View GitHub Profile
@vshkl
vshkl / eact-native-pdf-npm-7.0.3-6313469aca.patch
Last active December 11, 2025 20:16
Android. java.lang.IllegalStateException: Already closed. Mix of `react-native-pdf` and `react-native-pdf-jsi`.
diff --git a/android/src/main/java/org/wonday/pdf/PdfManager.java b/android/src/main/java/org/wonday/pdf/PdfManager.java
index 03e6de2fd385b833223d90375423e0b323bb5fff..dcc4e4395aff116a999f15bf53690ed1286eccd4 100644
--- a/android/src/main/java/org/wonday/pdf/PdfManager.java
+++ b/android/src/main/java/org/wonday/pdf/PdfManager.java
@@ -60,7 +60,7 @@ public class PdfManager extends SimpleViewManager<PdfView> implements RNPDFPdfVi
@Override
public void onDropViewInstance(PdfView pdfView) {
- pdfView = null;
+ this.pdfView = null;
@vshkl
vshkl / StartDateSelector.tsx
Created April 5, 2023 11:03
Start date picker componetn | react-native, typescript, hooks
import React, { Ref, useCallback, useLayoutEffect, useMemo, useRef } from 'react'
import { FlatList, StyleSheet, View, type ViewToken } from 'react-native'
import { useLayout } from '@react-native-community/hooks'
import Label from 'components/atoms/Label'
import DateView, { ITEM_WIDTH } from 'components/molecules/DateView'
import { type DateWithName } from 'components/organisms/SelectIntervalModal'
const ITEM_INTER = 12
@vshkl
vshkl / Label.tsx
Last active April 5, 2023 11:04
Label component for common typography | react-native, typescript
import React, { useMemo } from 'react'
import { Text } from 'react-native'
type LabelProps = {
children: string | number,
size: 'small' | 'normal' | 'medium' | 'large' | 'xlarge' | 'xxlarge',
weight: 'light' | 'regular' | 'medium' | 'bold',
color: 'primary' | 'secondary' | 'disabled',
}
@vshkl
vshkl / Notifications.ts
Last active April 5, 2023 11:04
Local notification management | react-native, typescript, notifee.
import { Alert } from 'react-native'
import notifee, {
TriggerType,
RepeatFrequency,
AuthorizationStatus,
EventType,
type TimestampTrigger,
type Notification,
type Event,
class MainActivity : AppCompatActivity(R.layout.activity_main),
MainCallbackAdapter, OnInterceptTouchEventListener, OnRowMoveListener {
private val viewModel by viewModels<MainViewModel>()
private val controller = MainController(this)
private var touchHelper: ItemTouchHelper? = null
private var touchedPosition = -1
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
class MainSimpleOnItemTouchListener(
private val listener: OnInterceptTouchEventListener
) : RecyclerView.SimpleOnItemTouchListener() {
interface OnInterceptTouchEventListener {
fun onInterceptTouchEvent(touchedPosition: Int)
}
class MainEpoxyTouchCallback(
controller: MainController,
private val listener: OnRowMoveListener
) : EpoxyModelTouchCallback<RowEpoxyModel>(controller, RowEpoxyModel::class.java) {
interface OnRowMoveListener {
fun onMoved(movingRowId: String, shiftingRowId: String)
}
class MainController(
private val callbackAdapter: MainCallbackAdapter
) : EpoxyController() {
private var firstRows = emptyList<Row>()
private var secondRows = emptyList<Row>()
override fun buildModels() {
header {
id("header", "1")
interface MainCallbackAdapter {
fun onDragStart()
}
@EpoxyModelClass(layout = R.layout.item_model_row)
abstract class RowEpoxyModel : EpoxyModelWithHolder<RowViewHolder>() {
@EpoxyAttribute lateinit var rowId: String
@EpoxyAttribute lateinit var title: String
@EpoxyAttribute(DoNotHash) var onDragHandleTouchListener: OnTouchListener? = null
@SuppressLint("ClickableViewAccessibility")
override fun bind(holder: RowViewHolder) {
with(holder) {