mirror of
https://github.com/zoriya/yoshiki.git
synced 2026-05-29 17:12:36 +00:00
Fix native image issue with typescript
This commit is contained in:
@@ -4,10 +4,8 @@
|
||||
//
|
||||
|
||||
import { AppProps } from "next/app";
|
||||
import { useMemo } from "react";
|
||||
import {
|
||||
useYoshiki,
|
||||
createStyleRegistry,
|
||||
useMobileHover,
|
||||
StyleRegistryProvider,
|
||||
Theme,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "yoshiki",
|
||||
"version": "1.0.6",
|
||||
"version": "1.0.7",
|
||||
"author": "Zoe Roux <zoe.roux@sdg.moe> (https://github.com/AnonymusRaccoon)",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
|
||||
@@ -3,7 +3,13 @@
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for details.
|
||||
//
|
||||
|
||||
import { PressableProps, useWindowDimensions, ViewStyle } from "react-native";
|
||||
import {
|
||||
ImageStyle,
|
||||
PressableProps,
|
||||
TextStyle,
|
||||
useWindowDimensions,
|
||||
ViewStyle,
|
||||
} from "react-native";
|
||||
import { breakpoints, Theme, useTheme } from "../theme";
|
||||
import {
|
||||
Breakpoints,
|
||||
@@ -15,8 +21,8 @@ import {
|
||||
} from "../type";
|
||||
import { isBreakpoints } from "../utils";
|
||||
import { shorthandsFn } from "../shorthands";
|
||||
import { StyleFunc, NativeCssFunc, NativeStyle } from "./type";
|
||||
import { useReducer, useRef, useState } from "react";
|
||||
import { StyleFunc, NativeCssFunc } from "./type";
|
||||
import { useReducer, useRef } from "react";
|
||||
|
||||
const useBreakpoint = (): number => {
|
||||
const { width } = useWindowDimensions();
|
||||
@@ -62,7 +68,7 @@ export const useYoshiki = () => {
|
||||
const breakpoint = useBreakpoint();
|
||||
const theme = useTheme();
|
||||
const rerender = useForceRerender();
|
||||
const childStyles = useRef<Record<string, NativeStyle | undefined>>({});
|
||||
const childStyles = useRef<Record<string, ViewStyle | TextStyle | ImageStyle | undefined>>({});
|
||||
|
||||
const css: NativeCssFunc = (cssList, leftOvers) => {
|
||||
// The as any is because we can't be sure the style type is right one.
|
||||
|
||||
@@ -41,19 +41,39 @@ export type StyleFunc<Style> = (state: {
|
||||
}) => Style;
|
||||
|
||||
type AddLO<T, LO> = [LO] extends [never] ? T : Omit<LO, "style"> & T;
|
||||
type NativeStyle = ViewStyle | TextStyle | ImageStyle;
|
||||
|
||||
export type NativeStyle = ViewStyle | TextStyle | ImageStyle;
|
||||
|
||||
declare function nativeCss<Style extends NativeStyle, Leftover = never>(
|
||||
cssList: StyleList<EnhancedStyle<Style> | string>,
|
||||
leftOvers?: Leftover & { style?: StyleProp<Style> | null },
|
||||
): AddLO<{ style?: Style }, Leftover>;
|
||||
|
||||
declare function nativeCss<Style extends NativeStyle, Leftover = never>(
|
||||
declare function nativeCss<Leftover = never>(
|
||||
cssList: StyleList<EnhancedStyle<ViewStyle> | string>,
|
||||
leftOvers?: Leftover & { style?: StyleProp<ViewStyle> | null },
|
||||
): AddLO<{ style?: ViewStyle }, Leftover>;
|
||||
declare function nativeCss<Leftover = never>(
|
||||
cssList: StyleList<
|
||||
(EnhancedStyle<Style> & Partial<WithState<EnhancedStyle<NativeStyle>>>) | string
|
||||
(EnhancedStyle<ViewStyle> & Partial<WithState<EnhancedStyle<NativeStyle>>>) | string
|
||||
>,
|
||||
leftOvers?: Leftover & { style?: StyleProp<Style> | StyleFunc<StyleProp<Style>> | null },
|
||||
leftOvers?: Leftover & { style?: StyleProp<ViewStyle> | StyleFunc<StyleProp<ViewStyle>> | null },
|
||||
): AddLO<PressableProps, Leftover>;
|
||||
|
||||
declare function nativeCss<Leftover = never>(
|
||||
cssList: StyleList<EnhancedStyle<TextStyle> | string>,
|
||||
leftOvers?: Leftover & { style?: StyleProp<TextStyle> | null },
|
||||
): AddLO<{ style?: TextStyle }, Leftover>;
|
||||
declare function nativeCss<Leftover = never>(
|
||||
cssList: StyleList<
|
||||
(EnhancedStyle<TextStyle> & Partial<WithState<EnhancedStyle<NativeStyle>>>) | string
|
||||
>,
|
||||
leftOvers?: Leftover & { style?: StyleProp<TextStyle> | StyleFunc<StyleProp<ViewStyle>> | null },
|
||||
): AddLO<PressableProps, Leftover>;
|
||||
|
||||
declare function nativeCss<Leftover = never>(
|
||||
cssList: StyleList<EnhancedStyle<ImageStyle> | string>,
|
||||
leftOvers?: Leftover & { style?: StyleProp<ImageStyle> | null },
|
||||
): AddLO<{ style?: ImageStyle }, Leftover>;
|
||||
declare function nativeCss<Leftover = never>(
|
||||
cssList: StyleList<
|
||||
(EnhancedStyle<ImageStyle> & Partial<WithState<EnhancedStyle<NativeStyle>>>) | string
|
||||
>,
|
||||
leftOvers?: Leftover & { style?: StyleProp<ImageStyle> | StyleFunc<StyleProp<ViewStyle>> | null },
|
||||
): AddLO<PressableProps, Leftover>;
|
||||
|
||||
export type NativeCssFunc = typeof nativeCss;
|
||||
|
||||
Reference in New Issue
Block a user