Skip to content

Commit

Permalink
add setting for tap to collapse (#684)
Browse files Browse the repository at this point in the history
  • Loading branch information
gkasdorf authored Jul 15, 2023
1 parent 8daabb2 commit d5c6dba
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 5 deletions.
5 changes: 5 additions & 0 deletions src/components/screens/Post/components/PostHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import PostActionBar from "./PostActionBar";
import PostTitle from "./PostTitle";
import { onGenericHapticFeedback } from "../../../../helpers/HapticFeedbackHelpers";
import { ILemmyVote } from "../../../../types/lemmy/ILemmyVote";
import { useAppSelector } from "../../../../../store";
import { selectSettings } from "../../../../slices/settings/settingsSlice";

interface IProps {
currentPost: PostView;
Expand All @@ -41,12 +43,15 @@ function PostHeader({
doVote,
}: IProps) {
const theme = useTheme();
const { tapToCollapse } = useAppSelector(selectSettings);

const instanceBaseUrl = getBaseUrl(currentPost.community.actor_id);

const [hideSLA, setHideSLA] = useState(false);

const onPress = () => {
if (!tapToCollapse) return;

onGenericHapticFeedback();
setCollapsed((prev) => !prev);
};
Expand Down
17 changes: 17 additions & 0 deletions src/components/screens/Settings/Appearance/AppearanceScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,23 @@ function AppearanceScreen({ navigation }: IProps) {
/>
</CSection>
)}

<CSection header={t("settings.appearance.gestures.header")}>
<CCell
cellStyle="Basic"
title={t("settings.appearance.gestures.tapToCollapse")}
backgroundColor={theme.colors.app.fg}
titleTextColor={theme.colors.app.textPrimary}
rightDetailColor={theme.colors.app.textSecondary}
cellAccessoryView={
<Switch
value={settings.tapToCollapse}
onValueChange={(v) => onChange("tapToCollapse", v)}
/>
}
/>
</CSection>

<CSection header={t("settings.appearance.themes.header")}>
<CCell
cellStyle="Basic"
Expand Down
9 changes: 7 additions & 2 deletions src/hooks/post/useComment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { showToast } from "../../slices/toast/toastSlice";
import { setResponseTo } from "../../slices/comments/newCommentSlice";
import { useAppActionSheet } from "../app/useAppActionSheet";
import { handleLemmyError } from "../../helpers/LemmyErrorHelper";
import { selectSettings } from "../../slices/settings/settingsSlice";

interface UseComment {
onCommentPress: () => void;
Expand All @@ -43,20 +44,24 @@ const useComment = ({

const currentAccount = useAppSelector(selectCurrentAccount);
const { unread } = useAppSelector(selectSite);
const { tapToCollapse } = useAppSelector(selectSettings);
const navigation = useNavigation<NativeStackNavigationProp<any>>();

const dispatch = useAppDispatch();

const { showAppActionSheetWithOptions } = useAppActionSheet();

const onCommentPress = () => {
onGenericHapticFeedback();

if (onPressOverride) {
onGenericHapticFeedback();
onPressOverride();
return;
}

if (!tapToCollapse) return;

onGenericHapticFeedback();

setComments((prev) =>
prev.map((c) => {
if (c.comment.comment.id === comment.comment.comment.id) {
Expand Down
6 changes: 5 additions & 1 deletion src/plugins/i18n/locales/cz.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,11 @@
"useSystemFontSize": "Použít Systémovou Velikost Písma",
"textSize": "Velikost Textu",
"postTitleFontWeight": "Tloušťka Písma - Titulek Příspěvku"
}
},
"gestures": {
"header": "GESTURES",
"tapToCollapse": "Klepněte pro sbalení"
}
},
"accounts": {
"current": "Aktuální Účet",
Expand Down
6 changes: 5 additions & 1 deletion src/plugins/i18n/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,11 @@
"useSystemFontSize": "System Schriftgröße übernehmen",
"textSize": "Textgröße",
"postTitleFontWeight": "Schriftstärke - Post Titel"
}
},
"gestures": {
"header": "GESTURES",
"tapToCollapse": "Zum Zusammenklappen antippen"
}
},
"accounts": {
"current": "Aktueller Account",
Expand Down
6 changes: 5 additions & 1 deletion src/plugins/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,11 @@
"useSystemFontSize": "Use System Font Size",
"textSize": "Text Size",
"postTitleFontWeight": "Font Weight - Post Title"
}
},
"gestures": {
"header": "GESTURES",
"tapToCollapse": "Tap to Collapse"
}
},
"accounts": {
"current": "Current Account",
Expand Down
2 changes: 2 additions & 0 deletions src/slices/settings/settingsSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export interface SettingsState {
appIcon: string;
showCommentActions: boolean;
useDefaultBrowser: boolean;
tapToCollapse: boolean;
}

const initialState: SettingsState = {
Expand Down Expand Up @@ -74,6 +75,7 @@ const initialState: SettingsState = {
appIcon: "purple",
showCommentActions: true,
useDefaultBrowser: false,
tapToCollapse: true,
};

const settingsSlice = createSlice({
Expand Down

0 comments on commit d5c6dba

Please sign in to comment.