-
-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
95 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { ListItemText, Slider, Typography } from "@mui/material"; | ||
import { useContext, useEffect, useRef, useState } from "react"; | ||
import { useTranslation } from "react-i18next"; | ||
import AppContext from "../../AppContext"; | ||
|
||
const FontSizeSlider = () => { | ||
const { fontSize: _fontSize, setFontSize: setAppFontSize } = | ||
useContext(AppContext); | ||
const { t } = useTranslation(); | ||
const [fontSize, setFontSize] = useState<number>(_fontSize); | ||
const value = useRef<number>(fontSize); | ||
|
||
useEffect(() => { | ||
return () => { | ||
setAppFontSize(value.current); | ||
}; | ||
}, [setAppFontSize]); | ||
|
||
return ( | ||
<ListItemText | ||
primary={<Typography sx={{ fontSize }}>{t("字體大小")}</Typography>} | ||
secondary={ | ||
<Slider | ||
step={2} | ||
min={10} | ||
max={26} | ||
value={fontSize} | ||
valueLabelDisplay="auto" | ||
size="small" | ||
onChange={(_, v: number) => { | ||
setFontSize(v); | ||
value.current = v; | ||
}} | ||
/> | ||
} | ||
/> | ||
); | ||
}; | ||
|
||
export default FontSizeSlider; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters