Skip to content

Commit

Permalink
merge andrew_testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Isthisanmol committed Jun 17, 2024
2 parents ad74e95 + e69e507 commit a2bb2f1
Show file tree
Hide file tree
Showing 17 changed files with 98 additions and 47 deletions.
24 changes: 19 additions & 5 deletions packages/app/components/card/PackCardHeader/PackCardHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,39 @@ interface PackCardHeaderProps {
export const PackCardHeader = ({ data, title }: PackCardHeaderProps) => {
const { isLoading, refetch } = useFetchSinglePack(data?.id);
const user = useAuthUser();
const handleDeletePack = useDeletePack(data.id);
const { handleActionsOpenChange, handleEdit, handleSaveTitle, isEditMode } =
usePackTitleInput(data);
const { handleDeletePack } = useDeletePack(data.id);
const {
handleActionsOpenChange,
handleEdit,
handleSaveTitle,
isEditMode,
isOpen,
setIsOpen,
} = usePackTitleInput(data);

const { isDark, currentTheme } = useTheme();

const router = useRouter();
const { editPack } = useEditPack();

const handleDelete = () => {
handleDeletePack();
setIsOpen(false);
};
const handleSavePack = () => {
const packDetails = {
id: data.id,
name: data.name,
is_public: data.is_public,
};
setIsOpen(false);
editPack(packDetails);
};

return (
<>
<CustomCardHeader
link={''}
data={data}
title={
<RStack
Expand Down Expand Up @@ -89,11 +103,11 @@ export const PackCardHeader = ({ data, title }: PackCardHeaderProps) => {
}
actionsComponent={
user?.id === data.owner_id && (
<ThreeDotsMenu onOpenChange={handleActionsOpenChange}>
<ThreeDotsMenu open={isOpen} onOpenChange={handleActionsOpenChange}>
<YStack space="$1">
<RButton onPress={handleEdit}>Edit</RButton>
<RButton onPress={handleSavePack}>Save</RButton>
<RButton onPress={handleDeletePack}>Delete</RButton>
<RButton onPress={handleDelete}>Delete</RButton>
</YStack>
</ThreeDotsMenu>
)
Expand Down
15 changes: 13 additions & 2 deletions packages/app/components/card/PackCardHeader/usePackTitleInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,21 @@ import { useRef, useState } from 'react';
export const usePackTitleInput = (data) => {
const [isEditMode, setIsEditMode] = useState(false);
const isEditModeRef = useRef(false);
const [isOpen, setIsOpen] = useState(false);
const { editPack } = useEditPack();

const handleActionsOpenChange = (state) => {
setIsOpen(true);
if (!state && isEditModeRef.current) {
isEditModeRef.current = false;
setIsEditMode(true);
setIsOpen(true);
}
};

const handleEdit = () => {
isEditModeRef.current = true;
setIsOpen(false);
};

const handleSaveTitle = (title) => {
Expand All @@ -23,10 +27,17 @@ export const usePackTitleInput = (data) => {
name: title,
is_public: data.is_public,
};

setIsOpen(false);
editPack(packDetails);
setIsEditMode(false);
};

return { handleActionsOpenChange, isEditMode, handleEdit, handleSaveTitle };
return {
handleActionsOpenChange,
isEditMode,
handleEdit,
handleSaveTitle,
isOpen,
setIsOpen,
};
};
2 changes: 1 addition & 1 deletion packages/app/components/dashboard/QuickActionButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const loadStyles = (theme: any) => {
},
text: {
fontSize: 13,
fontWeight:'bold',
fontWeight: 'bold',
color: currentTheme.colors.iconColor,
},
};
Expand Down
2 changes: 1 addition & 1 deletion packages/app/components/feed/FeedSearchFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,4 @@ const loadStyles = (theme: any) => {
};
};

export default FeedSearchFilter;
export default FeedSearchFilter;
2 changes: 1 addition & 1 deletion packages/app/components/map/MapButtonsOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ const loadStyles = (theme) => {
downloadText: {
fontSize: 15,
fontWeight: '500',
marginRight:8
marginRight: 8,
},
modal: {
alignItems: 'center',
Expand Down
8 changes: 7 additions & 1 deletion packages/app/components/map/NativeMap.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,13 @@ function NativeMap({ shape: shapeProp }) {
/>
</AlertDialog.Body>
<AlertDialog.Footer>
<RStack style={{width:'60%', justifyContent:'space-between', flexDirection:'row'}}>
<RStack
style={{
width: '60%',
justifyContent: 'space-between',
flexDirection: 'row',
}}
>
<RButton
variant="unstyled"
colorScheme="coolGray"
Expand Down
2 changes: 1 addition & 1 deletion packages/app/components/navigation/NavigationList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const NavigationList: React.FC<NavigationListProps> = ({
style={{
width: '100%',
borderRadius: 8,
marginBottom: isMobileView ? 6:0,
marginBottom: isMobileView ? 6 : 0,
backgroundColor: currentTheme.colors.background,
color: currentTheme.colors.white,
}}
Expand Down
6 changes: 4 additions & 2 deletions packages/app/components/pack/PackDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export function PackDetails() {
if (isLoading) return <RText>Loading...</RText>;

return (
<>
<ScrollView>
<Layout>
<View
style={[
Expand Down Expand Up @@ -158,6 +158,8 @@ export function PackDetails() {
bottom: 30,
width: 60,
height: 60,
marginBottom: 20,

justifyContent: 'center',
alignItems: 'center',
}}
Expand All @@ -168,7 +170,7 @@ export function PackDetails() {
trigger="Open Chat"
/>
</View>
</>
</ScrollView>
);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/app/hooks/packs/useDeletePack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ export const useDeletePack = (id) => {
} catch {}
};

return handleDeletePack;
return { handleDeletePack };
};
10 changes: 5 additions & 5 deletions packages/app/screens/dashboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ const loadStyles = (theme) => {
alignItems: 'stretch',
paddingHorizontal: 20,
width:
Platform.OS === 'web'
? screenWidth <= SCREEN_WIDTH
? '100vw'
: '90vw'
: '100%',
Platform.OS === 'web'
? screenWidth <= SCREEN_WIDTH
? '100vw'
: '90vw'
: '100%',
},
cardContainer: {
flexDirection: 'column',
Expand Down
1 change: 1 addition & 0 deletions packages/app/screens/user/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export default function Settings() {
paddingVertical={20}
paddingHorizontal={8}
marginHorizontal="auto"
marginVertical={40}
>
<RStack
style={{
Expand Down
4 changes: 3 additions & 1 deletion packages/crosspath/types/lib-interface.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { LinkComponent, Router, CreateParam } from './model';
export declare function Link(props: Parameters<LinkComponent>): ReturnType<LinkComponent>;
export declare function Link(
props: Parameters<LinkComponent>,
): ReturnType<LinkComponent>;
export declare const createParam: CreateParam;
export declare function useRouter(): Router;
41 changes: 23 additions & 18 deletions packages/crosspath/types/model/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
import { FC } from 'react';
import { LinkProps } from 'solito/link';
export interface CreateParamOptions {
initial?: string;
parse?: (param: string) => unknown;
stringify?: (param: unknown) => string;
initial?: string;
parse?: (param: string) => unknown;
stringify?: (param: unknown) => string;
}
export interface Router {
push: (url: URL) => void;
replace: (url: URL) => void;
back: () => void;
push: (url: URL) => void;
replace: (url: URL) => void;
back: () => void;
}
export type LinkComponent = FC<LinkProps>;
export type URL = string | {
pathname?: string;
query?: Record<string, any>;
state?: Record<string, any>;
hash?: string;
as?: string | object;
};
export type CreateParam = <T>() => {
useParam: (key: keyof T, options?: CreateParamOptions) => [value: any, setValue: (value: any) => void];
useParams: (key: keyof T) => {
params: T;
setParams: (value: any) => void;
export type URL =
| string
| {
pathname?: string;
query?: Record<string, any>;
state?: Record<string, any>;
hash?: string;
as?: string | object;
};
export type CreateParam = <T>() => {
useParam: (
key: keyof T,
options?: CreateParamOptions,
) => [value: any, setValue: (value: any) => void];
useParams: (key: keyof T) => {
params: T;
setParams: (value: any) => void;
};
};
4 changes: 2 additions & 2 deletions packages/ui/src/Bento/elements/tables/Basic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export function BasicTable({
header: () => 'Category',
cell: (info) => info.getValue(),
// footer: (info) => 'category',
})
}),
];

if (hasPermissions) {
Expand All @@ -161,7 +161,7 @@ export function BasicTable({
id: 'actions',
cell: (props) => <ActionButtons item={props.row.original} />,
header: () => 'Actions',
})
}),
);
}

Expand Down
3 changes: 2 additions & 1 deletion packages/ui/src/RSelect/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
Sheet,
YStack as OriginalYStack,
getFontSize,
Text,
} from 'tamagui';

const YStack: any = OriginalYStack;
Expand Down Expand Up @@ -83,7 +84,7 @@ export function SelectItem(props) {

// Conditional rendering based on options
if (options.length === 0) {
return <div>No options available</div>;
return <Text>No options available</Text>;
}

return (
Expand Down
10 changes: 9 additions & 1 deletion packages/ui/src/ThreeDotsMenu/ThreeDotsMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
import React, { ReactNode } from 'react';
import { MoreHorizontal } from '@tamagui/lucide-icons';
import { Adapt, Button, Popover as OriginalPopover } from 'tamagui';
import { Platform } from 'react-native';

// Bypass TypeScript's type checking on opacity and borderWidth, since component is directly from the library
const Popover: any = OriginalPopover;

interface ThreeDotsMenuProps {
children: ReactNode;
onOpenChange: (open: boolean) => void;
open: boolean;
}

export function ThreeDotsMenu({ children, onOpenChange }: ThreeDotsMenuProps) {
export function ThreeDotsMenu({
children,
onOpenChange,
open,
}: ThreeDotsMenuProps) {
console.log('ksksksks', open);
return (
<Popover
size="$5"
allowFlip
placement="bottom"
onOpenChange={onOpenChange}
open={Platform.OS != 'web' ? open : undefined}
disableFocus
>
<Popover.Trigger asChild backgroundColor="transparent">
Expand Down
9 changes: 5 additions & 4 deletions packages/ui/src/dialog/BaseDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const BaseDialog = ({
</Dialog.Trigger>
<Adapt when="sm" platform="touch">
<Sheet zIndex={200000} modal dismissOnSnapToBottom>
<Sheet.Frame padding="$4" gap="$4">
<Sheet.Frame padding="$4" gap="$0">
<Adapt.Contents />
</Sheet.Frame>

Expand Down Expand Up @@ -74,9 +74,10 @@ export const BaseDialog = ({
exitStyle={{ x: 0, y: 10, opacity: 0, scale: 0.95 }}
gap="$4"
>
<Dialog.Title>{title}</Dialog.Title>

<Dialog.Description>{description}</Dialog.Description>
{title && <Dialog.Title>{title}</Dialog.Title>}
{description && (
<Dialog.Description>{description}</Dialog.Description>
)}
{children}
</Dialog.Content>
</Dialog.Portal>
Expand Down

0 comments on commit a2bb2f1

Please sign in to comment.