96 lines
4.0 KiB
TypeScript
96 lines
4.0 KiB
TypeScript
// Metro module 10315 (f10316).
|
|
import { useEffect } from "react";
|
|
import { View } from "react-native";
|
|
import { intl, t } from "../../../../intl/index.native";
|
|
import { Presets } from "../utils/notificationSettingsPresetUtils";
|
|
import { CircleCheckIcon } from "../../../../design/components/Icon/native/redesign/generated/CircleCheckIcon";
|
|
import { MagicWandIcon } from "../../../../design/components/Icon/native/redesign/generated/MagicWandIcon";
|
|
import { BellSlashIcon } from "../../../../design/components/Icon/native/redesign/generated/BellSlashIcon";
|
|
import { createStyles } from "../../../../design/components/Styles/native/createStyles";
|
|
import Module712 from "../../../../_bundle/Module712";
|
|
import { useSegmentedControlState } from "../../../../design/components/SegmentedControl/native/SegmentedControlState.native";
|
|
import { Text } from "../../../../design/components/Text/native/Text";
|
|
import { Button } from "../../../../design/components/Button/native/Button.native";
|
|
import { SegmentedControl } from "../../../../design/components/SegmentedControl/native/SegmentedControl.native";
|
|
import { useGuildPresetSettings, updateGuildPreset } from "../utils/notificationSettingsGuildFlagUtils";
|
|
import { useChannelPresetSettings, updateChannelPreset } from "../utils/notficationSettingsChannelFlagUtils";
|
|
let useStyles;
|
|
const NotificationSettingsPresets = function NotificationSettingsPresets(props) {
|
|
let c17863_0 = props;
|
|
const styles = useStyles();
|
|
const defaultIndex = props.preset !== Presets.ALL_MESSAGES ? props.preset !== Presets.MENTIONS ? props.preset === Presets.NOTHING ? 2 : void 0 : 1 : 0;
|
|
let c17863_1 = defaultIndex;
|
|
const segmentedControlState = useSegmentedControlState({
|
|
pageWidth: 0,
|
|
onSetActiveIndex: function onSetActiveIndex(a0) {
|
|
if (a0 === 0 && c17863_0.preset !== Presets.ALL_MESSAGES) {
|
|
c17863_0.updatePreset(Presets.ALL_MESSAGES);
|
|
}
|
|
if (a0 === 1 && c17863_0.preset !== Presets.MENTIONS) {
|
|
c17863_0.updatePreset(Presets.MENTIONS);
|
|
}
|
|
if (a0 === 2 && c17863_0.preset !== Presets.NOTHING) {
|
|
c17863_0.updatePreset(Presets.NOTHING);
|
|
}
|
|
},
|
|
items: [{
|
|
label: intl.string(t.hZrr6k),
|
|
id: Presets.ALL_MESSAGES,
|
|
icon: <CircleCheckIcon />,
|
|
page: null
|
|
}, {
|
|
label: intl.string(t.y59NJm),
|
|
id: Presets.MENTIONS,
|
|
icon: <MagicWandIcon />,
|
|
page: null
|
|
}, {
|
|
label: intl.string(t["pGn/bJ"]),
|
|
id: Presets.NOTHING,
|
|
icon: <BellSlashIcon />,
|
|
page: null
|
|
}],
|
|
defaultIndex
|
|
});
|
|
useEffect(() => {
|
|
if (!(c17863_1 == null || c17863_1 >= 3)) {
|
|
segmentedControlState.setActiveIndex(c17863_1);
|
|
}
|
|
}, [defaultIndex, segmentedControlState]);
|
|
return props.preset === Presets.CUSTOM ? <View style={styles.customContainer}>
|
|
<View style={{
|
|
flex: 1,
|
|
marginRight: 8
|
|
}}>
|
|
<Text variant="text-sm/semibold">
|
|
{intl.string(t["32yow9"])}
|
|
</Text>
|
|
<Text variant="text-xs/medium">
|
|
{intl.string(t.l3doVX)}
|
|
</Text>
|
|
</View>
|
|
<Button variant="secondary" text={intl.string(t["ztO+l+"])} onPress={() => {
|
|
c17863_0.updatePreset(Presets.MENTIONS);
|
|
}} />
|
|
</View> : <SegmentedControl variant="experimental_Large" state={segmentedControlState} />;
|
|
};
|
|
useStyles = createStyles({
|
|
customContainer: {
|
|
padding: 16,
|
|
minHeight: 82,
|
|
display: "flex",
|
|
flexDirection: "row",
|
|
alignItems: "center",
|
|
justifyContent: "center",
|
|
borderRadius: Module712.radii.lg + 8,
|
|
backgroundColor: Module712.colors.REDESIGN_INPUT_CONTROL_ACTIVE_BG
|
|
}
|
|
});
|
|
export function NotificationSettingsGuildPresets(props) {
|
|
let c17864_0 = props;
|
|
return <NotificationSettingsPresets preset={useGuildPresetSettings(props.guildId).preset} updatePreset={(a0) => updateGuildPreset(c17864_0.guildId, a0)} />;
|
|
}
|
|
export function NotificationSettingsChannelPresets(props) {
|
|
let c17865_0 = props;
|
|
return <NotificationSettingsPresets preset={useChannelPresetSettings(props.channel).preset} updatePreset={(a0) => updateChannelPreset(c17865_0.channel.guild_id, c17865_0.channel.id, a0)} />;
|
|
}
|