134 lines
5.8 KiB
TypeScript
134 lines
5.8 KiB
TypeScript
// Metro module 14864 (f14865).
|
|
import { View } from "react-native";
|
|
import { MultiAccountTokenStatus } from "../MultiAccountStore";
|
|
import { MAX_ACCOUNTS, MultiAccountSwitchLocation } from "../Constants";
|
|
import { AnalyticEvents, AuthStates } from "../../../Constants";
|
|
import { createStyles } from "../../../design/components/Styles/native/createStyles";
|
|
import Module712 from "../../../_bundle/Module712";
|
|
import { useNavigation } from "../../../design/components/Navigator/native/useNavigation.native";
|
|
import { useMultiAccountUsers } from "../useMultiAccount";
|
|
import AnalyticsUtils from "../../../utils/AnalyticsUtils";
|
|
import { removeAccount, switchAccount } from "../MultiAccountActionCreators";
|
|
import AlertActionCreators from "../../../actions/native/AlertActionCreators";
|
|
import { intl, t } from "../../../intl/index.native";
|
|
import { ButtonColors, Icon } from "../../../design/void/native";
|
|
import ActionSheetActionCreators from "../../action_sheet/native/ActionSheetActionCreators";
|
|
import { showSimpleActionSheet } from "../../action_sheet/native/showSimpleActionSheet";
|
|
import AuthFormView from "../../auth/native/components/AuthFormView";
|
|
import { Text } from "../../../design/components/Text/native/Text";
|
|
import Module13002 from "../../../_bundle/Module13002";
|
|
import AccountSwitcherListItem from "./AccountSwitcherListItem";
|
|
import { PressableOpacity } from "../../../design/void/Pressables/native/Pressables";
|
|
import Module8334 from "../../../_bundle/Module8334";
|
|
import { FormRow } from "../../../design/void/Form/native/index";
|
|
import Module14867 from "../../../_bundle/Module14867";
|
|
const useStyles = createStyles({
|
|
container: {
|
|
backgroundColor: Module712.colors.BACKGROUND_BASE_LOW,
|
|
borderRadius: Module712.radii.sm,
|
|
paddingTop: Module712.space.PX_16,
|
|
margin: Module712.space.PX_16
|
|
},
|
|
mainCard: {
|
|
marginVertical: Module712.space.PX_16,
|
|
borderRadius: Module712.radii.sm,
|
|
flexDirection: "column",
|
|
alignItems: "stretch",
|
|
alignSelf: "stretch",
|
|
display: "flex"
|
|
},
|
|
addAccountLabel: {
|
|
color: Module712.colors.TEXT_LINK
|
|
}
|
|
});
|
|
export default function ChooseAccount() {
|
|
let navigation, multiAccountUsers;
|
|
let _handlePressRemove2 = function _handlePressRemove() {
|
|
const r9 = async (c30795_0) => {
|
|
let c30795_2;
|
|
c30795_2 = void 0;
|
|
let c31743_0 = c30795_0;
|
|
if (await AlertActionCreators.confirm({
|
|
title: intl.string(t.n0Fbg6),
|
|
body: intl.formatToPlainString(t.phEQmS, {
|
|
username: c30795_0.discriminator === "0" ? `${c30795_0.username}` : `${c30795_0.username}#${c30795_0.discriminator}`
|
|
}),
|
|
confirmText: intl.string(t.N86XcP),
|
|
confirmColor: ButtonColors.RED,
|
|
cancelText: intl.string(t["ETE/oC"]),
|
|
isDismissable: true
|
|
})) {
|
|
ActionSheetActionCreators.hideActionSheet();
|
|
removeAccount(c31743_0.id);
|
|
}
|
|
};
|
|
_handlePressRemove2 = r9;
|
|
return r9.apply(this, arguments);
|
|
};
|
|
const styles = useStyles();
|
|
navigation = useNavigation();
|
|
multiAccountUsers = useMultiAccountUsers().multiAccountUsers;
|
|
return <AuthFormView headerText={intl.string(t.bVbB63)} subHeader={<Text variant="text-sm/medium" color="text-default">
|
|
{intl.string(t["0M5fN7"])}
|
|
</Text>} backgroundImageSource={Module13002} backgroundImageCover contentStyle={styles.container}>
|
|
<View style={styles.mainCard}>
|
|
{multiAccountUsers.map((multiAccountUser) => {
|
|
return <AccountSwitcherListItem key={multiAccountUser.id} user={multiAccountUser} onPressUser={() => {
|
|
if (multiAccountUser.tokenStatus === MultiAccountTokenStatus.INVALID) {
|
|
navigation.push(AuthStates.LOGIN);
|
|
AnalyticsUtils.track(AnalyticEvents.LOGIN_VIEWED, {
|
|
source: "choose_account_user_invalid"
|
|
});
|
|
} else {
|
|
switchAccount(multiAccountUser.id, void 0, MultiAccountSwitchLocation.CHOOSE_ACCOUNT);
|
|
}
|
|
}} trailing={<PressableOpacity accessibilityRole="button" onPress={() => {
|
|
let c30796_0 = multiAccountUser;
|
|
ActionSheetActionCreators.hideActionSheet();
|
|
showSimpleActionSheet({
|
|
key: "RemoveAccount",
|
|
options: [{
|
|
label: intl.string(t["DSN+hw"]),
|
|
onPress: () => {
|
|
if (c30796_0.tokenStatus === MultiAccountTokenStatus.INVALID) {
|
|
navigation.push(AuthStates.LOGIN);
|
|
AnalyticsUtils.track(AnalyticEvents.LOGIN_VIEWED, {
|
|
source: "choose_account_user_invalid"
|
|
});
|
|
} else {
|
|
switchAccount(c30796_0.id, void 0, MultiAccountSwitchLocation.CHOOSE_ACCOUNT);
|
|
}
|
|
}
|
|
}, {
|
|
label: intl.string(t.lSLMaU),
|
|
onPress: () => (function handlePressRemove(a0) {
|
|
return _handlePressRemove2.apply(this, arguments);
|
|
})(c30796_0),
|
|
isDestructive: true
|
|
}],
|
|
hasIcons: false
|
|
});
|
|
}}>
|
|
<Icon size={Icon.Sizes.SMALL_20} source={Module8334} disableColor />
|
|
</PressableOpacity>} />;
|
|
})}
|
|
<FormRow leading={<FormRow.Icon themedColor={Module712.colors.TEXT_LINK} size={Icon.Sizes.SMALL_20} source={Module14867} />} label={intl.string(t.bPP34Q)} labelStyle={styles.addAccountLabel} onPress={function handlePressAddAccount() {
|
|
if (multiAccountUsers.length >= MAX_ACCOUNTS) {
|
|
AlertActionCreators.show({
|
|
title: intl.string(t.w7wfXi),
|
|
body: intl.formatToPlainString(t.WOyelG, {
|
|
maxNumAccounts: MAX_ACCOUNTS
|
|
}),
|
|
isDismissable: true
|
|
});
|
|
} else {
|
|
navigation.push(AuthStates.LOGIN);
|
|
AnalyticsUtils.track(AnalyticEvents.LOGIN_VIEWED, {
|
|
source: "choose_account_add_account"
|
|
});
|
|
}
|
|
}} />
|
|
</View>
|
|
</AuthFormView>;
|
|
};
|