Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Make AttachmentModal actual screens on native platforms #56219

Open
wants to merge 51 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
6701013
feat: add AttachmentModalScreen component
chrispader Feb 1, 2025
f293ff8
refactor: AttachmentModalScreen works! 🎉
chrispader Feb 2, 2025
a5b4e0b
rename load function in AuthScreens
chrispader Feb 3, 2025
328ffc2
feat: move IconAsset type
chrispader Feb 4, 2025
a4feb2b
more changes
chrispader Feb 5, 2025
d1e7701
revert: type files renaming
chrispader Feb 5, 2025
08a2c3f
fix: make AttachmentModalScreen work for ProfileAvatar
chrispader Feb 5, 2025
16ba612
fix: remove duplicate attachment route param
chrispader Feb 5, 2025
2a62f12
fix: AttachmentModal loading
chrispader Feb 5, 2025
5d604cd
fix: more IconAsset imports
chrispader Feb 5, 2025
bff5475
fix: svg file type declaration
chrispader Feb 5, 2025
21d531c
refactor: ProfileAvatar and WorkspaceAvatar screen
chrispader Feb 5, 2025
2aa1323
refactor: use modal type components
chrispader Feb 6, 2025
f353b74
fix: attachment not shown
chrispader Feb 6, 2025
3e49807
fix: optional callback calls
chrispader Feb 6, 2025
31c73ce
feat: migrate TransactionReceiptPage to AttachmentModal
chrispader Feb 6, 2025
ac78e0a
fix: add missing item in AttachmentModalScreen
chrispader Feb 6, 2025
210a5a4
fix: migrate last AttachmentModals
chrispader Feb 6, 2025
d13d776
fix: FileObject type imports
chrispader Feb 6, 2025
b04e2b9
move context
chrispader Feb 6, 2025
dedca90
fix: more imports
chrispader Feb 6, 2025
2abd624
Merge branch 'main' into @chrispader/react-navigation-modal-screens
chrispader Feb 6, 2025
2c96bec
fix: minor changes
chrispader Feb 6, 2025
bc39284
remove AttachmentModalType
chrispader Feb 6, 2025
fd598b5
fix: simplify clsoe modal logic on web
chrispader Feb 6, 2025
31698b0
add close logic for native
chrispader Feb 6, 2025
abb2447
make send attachment modals work
chrispader Feb 6, 2025
fe21a2e
fix: wrong prop name
chrispader Feb 6, 2025
d5e134f
Update BaseContent.tsx
chrispader Feb 6, 2025
2be0d66
fix: wrong url param prefix
chrispader Feb 6, 2025
2d0e58c
fix: unused import
chrispader Feb 6, 2025
8d6d816
fix: onModalHide
chrispader Feb 6, 2025
94b557e
fix: report attachments
chrispader Feb 6, 2025
e9ff45e
fix: going back
chrispader Feb 6, 2025
fdd4f1f
Merge branch 'main' into @chrispader/react-navigation-modal-screens
chrispader Feb 6, 2025
cb2e185
fix: endless loop on modal close
chrispader Feb 6, 2025
586f5de
fix: navigate back after navigation screen
chrispader Feb 6, 2025
78a2232
simplify types
chrispader Feb 6, 2025
7671f17
revert: svg icon type changes
chrispader Feb 6, 2025
1b7a075
fix: linting errors
chrispader Feb 6, 2025
0fbb9b8
Merge branch 'main' into @chrispader/react-navigation-modal-screens
chrispader Feb 6, 2025
b684ae4
fix: variable typo
chrispader Feb 6, 2025
46a5ec6
add prop comments
chrispader Feb 6, 2025
9ac0f70
fix: more linting errors
chrispader Feb 7, 2025
43918f3
fix: more lint errors
chrispader Feb 7, 2025
b3a201a
Update AvatarWithImagePicker.tsx
chrispader Feb 7, 2025
1cb31f1
Update ROUTES.ts
chrispader Feb 7, 2025
1d0e09d
fix: fallbackRoute must be of type Route
chrispader Feb 7, 2025
5636a4c
fix: add missing prop comment
chrispader Feb 7, 2025
cb3bca7
fix: TS errors
chrispader Feb 7, 2025
3c51cbb
fix: TS error
chrispader Feb 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion assets/emojis/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type IconAsset from '@src/types/utils/IconAsset';
import type {IconAsset} from '@src/types/utils/ImageTypes';

chrispader marked this conversation as resolved.
Show resolved Hide resolved
type Emoji = {
code: string;
Expand Down
40 changes: 30 additions & 10 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import type {IOURequestType} from './libs/actions/IOU';
import Log from './libs/Log';
import type {ReimbursementAccountStepToOpen} from './libs/ReimbursementAccountUtils';
import type {AvatarSource, StaticAvatarSource} from './libs/UserUtils';

Check failure on line 8 in src/ROUTES.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'AvatarSource' is defined but never used

Check failure on line 8 in src/ROUTES.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'StaticAvatarSource' is defined but never used

Check failure on line 8 in src/ROUTES.ts

View workflow job for this annotation

GitHub Actions / ESLint check

'AvatarSource' is defined but never used
chrispader marked this conversation as resolved.
Show resolved Hide resolved
import type {ExitReason} from './types/form/ExitSurveyReasonForm';
import type {ConnectionName, SageIntacctMappingName} from './types/onyx/Policy';
import type AssertTypesNotEqual from './types/utils/AssertTypesNotEqual';
Expand Down Expand Up @@ -353,22 +354,41 @@
},
ATTACHMENTS: {
route: 'attachment',
getRoute: (
reportID: string | undefined,
type: ValueOf<typeof CONST.ATTACHMENT_TYPE>,
url: string,
accountID?: number,
isAuthTokenRequired?: boolean,
fileName?: string,
attachmentLink?: string,
) => {
getRoute: ({
source,
fallbackSource,
headerTitle,
fileName,
maybeIcon,
reportID,
type,
accountID,
isAuthTokenRequired,
attachmentLink,
}: {
source: string;
fallbackSource?: string;
headerTitle?: string;
maybeIcon?: boolean;
reportID?: string | undefined;
type?: ValueOf<typeof CONST.ATTACHMENT_TYPE>;
accountID?: number;
isAuthTokenRequired?: boolean;
fileName?: string;
attachmentLink?: string;
}) => {
const sourceParam = `?source=${encodeURIComponent(source)}`;
const fallbackSourceParam = fallbackSource ? `&fallbackSource=${encodeURIComponent(fallbackSource)}` : '';
const typeParam = type ? `$type=${type as string}` : '';
const reportParam = reportID ? `&reportID=${reportID}` : '';
const accountParam = accountID ? `&accountID=${accountID}` : '';
const authTokenParam = isAuthTokenRequired ? '&isAuthTokenRequired=true' : '';
const fileNameParam = fileName ? `&fileName=${fileName}` : '';
const attachmentLinkParam = attachmentLink ? `&attachmentLink=${attachmentLink}` : '';
const headerTitleParam = headerTitle ? `&headerTitle=${headerTitle}` : '';
const maybeIconParam = maybeIcon ? `&maybeIcon=${maybeIcon}` : '';

return `attachment?source=${encodeURIComponent(url)}&type=${type as string}${reportParam}${accountParam}${authTokenParam}${fileNameParam}${attachmentLinkParam}` as const;
return `attachment${sourceParam}${fallbackSourceParam}${headerTitleParam}${fileNameParam}${maybeIconParam}${typeParam}${reportParam}${accountParam}${authTokenParam}${fileNameParam}${attachmentLinkParam}` as const;
},
},
REPORT_PARTICIPANTS: {
Expand Down
2 changes: 1 addition & 1 deletion src/components/AttachmentPicker/index.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
import useStyleUtils from '@hooks/useStyleUtils';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import * as FileUtils from '@libs/fileDownload/FileUtils';

Check failure on line 22 in src/components/AttachmentPicker/index.native.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Namespace imports from @libs are not allowed. Use named imports instead. Example: import { method } from "@libs/module"
import CONST from '@src/CONST';
import type {TranslationPaths} from '@src/languages/types';
import type IconAsset from '@src/types/utils/IconAsset';
import type {IconAsset} from '@src/types/utils/ImageTypes';
import launchCamera from './launchCamera/launchCamera';
import type AttachmentPickerProps from './types';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import useLocalize from '@hooks/useLocalize';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import type IconAsset from '@src/types/utils/IconAsset';
import type {IconAsset} from '@src/types/utils/ImageTypes';

type DefaultAttachmentViewProps = {
/** The name of the file */
Expand Down Expand Up @@ -42,7 +42,7 @@
<View style={styles.mr2}>
<Icon
fill={theme.icon}
src={icon ?? Expensicons.Paperclip}

Check failure on line 45 in src/components/Attachments/AttachmentView/DefaultAttachmentView/index.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Unsafe assignment of an `any` value
/>
</View>

Expand All @@ -52,7 +52,7 @@
<View style={styles.ml2}>
<Icon
fill={theme.icon}
src={Expensicons.Download}

Check failure on line 55 in src/components/Attachments/AttachmentView/DefaultAttachmentView/index.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Unsafe assignment of an error typed value
/>
</View>
</Tooltip>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Attachments/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type {FileObject} from '@components/AttachmentModal';
import type IconAsset from '@src/types/utils/IconAsset';
import type {IconAsset} from '@src/types/utils/ImageTypes';

type AttachmentSource = string | IconAsset | number;

Expand Down
2 changes: 1 addition & 1 deletion src/components/AvatarCropModal/AvatarCropModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import cropOrRotateImage from '@libs/cropOrRotateImage';
import type {CustomRNImageManipulatorResult} from '@libs/cropOrRotateImage/types';
import CONST from '@src/CONST';
import type IconAsset from '@src/types/utils/IconAsset';
import type {IconAsset} from '@src/types/utils/ImageTypes';
import ImageCropView from './ImageCropView';
import Slider from './Slider';

Expand Down Expand Up @@ -390,7 +390,7 @@
/>
<View style={[styles.mt5, styles.justifyContentBetween, styles.alignItemsCenter, styles.flexRow, StyleUtils.getWidthStyle(imageContainerSize)]}>
<Icon
src={Expensicons.Zoom}

Check failure on line 393 in src/components/AvatarCropModal/AvatarCropModal.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Unsafe assignment of an error typed value
fill={theme.icon}
/>

Expand All @@ -412,7 +412,7 @@
>
<View>
<Button
icon={Expensicons.Rotate}

Check failure on line 415 in src/components/AvatarCropModal/AvatarCropModal.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Unsafe assignment of an error typed value
iconFill={theme.icon}
onPress={rotateImage}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/components/AvatarCropModal/ImageCropView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import * as Expensicons from '@components/Icon/Expensicons';
import useStyleUtils from '@hooks/useStyleUtils';
import useThemeStyles from '@hooks/useThemeStyles';
import ControlSelection from '@libs/ControlSelection';
import type IconAsset from '@src/types/utils/IconAsset';
import type {IconAsset} from '@src/types/utils/ImageTypes';

type ImageCropViewProps = {
/** Link to image for cropping */
Expand Down
Loading
Loading