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

阅读器边距调节 #153

Merged
merged 2 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
49 changes: 49 additions & 0 deletions entry/src/main/ets/componets/Reader/LayoutMoreDialog.ets
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
@Component
export default struct LayoutMore {
@Link ReaderPadding: number

build() {
Column() {
Row() {
Text("边距")
Slider({
value: this.ReaderPadding,
max: 32,
min: 12,
step: 4,
style: SliderStyle.InSet
})
.selectedColor('rgba(0, 0, 0, 0.04)')
.blockSize({ width: 30, height: 30 })
.layoutWeight(1)
.onChange((value) => {
this.ReaderPadding = value
})
}
.width("100%")

Row() {
Text("字体")
Button("细")
Button("中")
Button("粗")

Button("简体")
Button("繁体")
}
.width("100%")

Row() {
Text("首行缩进")
// Toggle()
}
.width("100%")
}
.height(500)
.padding({
left: 20,
right: 20
})
}
}

84 changes: 60 additions & 24 deletions entry/src/main/ets/pages/view/Reader/ReaderPage.ets
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import sourceView from './sourceView';
import { FileHandler } from 'ets/common/utils/FileHandler';
import { NetworkInput } from 'ets/componets/Reader/NetworkInput';
import { LengthMetrics } from '@ohos.arkui.node';
import DownloadSettingDialog from './DownloadSettingDialog';
import { MusicPlayer } from 'ets/componets/MusicPlayer';
import DownloadSettingDialog from '../../../componets/Reader/DownloadSettingDialog';
import LayoutMoreDialog from '../../../componets/Reader/LayoutMoreDialog';
import { MusicPlayer } from 'ets/componets/Reader/MusicPlayer';
import purificationView from './purificationView';
import { chaptersItem } from 'ets/componets/dataList/ReaderChaptersItem';
import { BookList } from 'ets/componets/dataList/bookList';
Expand All @@ -16,10 +17,12 @@ import { BookList } from 'ets/componets/dataList/bookList';
struct ReaderPage {
@StorageLink('bottomRectHeight') bottomRectHeight: number = 0
@StorageLink('topRectHeight') topRectHeight: number = 0
@State ReaderPadding: number = 24 // 亮度
@State isShowSetting: boolean = true
@State isShowDownload: boolean = false
@State isShowListen: boolean = false
@State isShowContentSetting: boolean = false
@State isShowMoreLayout: boolean = false
@State CurrentChapters: number = 0
@State TotalChapters: number = 0
@State CurrentLuminance: number = 0 // 亮度
Expand All @@ -29,7 +32,20 @@ struct ReaderPage {
@State isShowSource: boolean = false
@State isShowPurification: boolean = false
@State txtFile: chaptersItem[] = [];
scroller: Scroller = new Scroller()
// 网址导入Dialog
dialogController: CustomDialogController = new CustomDialogController({
builder: Dialog({
title: '加入书架',
CancelString: "暂不加入",
ConfirmString: "加入书架",
child: () => {
this.DialogString()
},
}),
cornerRadius: 16,
gridCount: 4,
offset: { dx: 0, dy: -300 }
})

async onPageShow() {
let temp = router.getParams() as BookList
Expand Down Expand Up @@ -214,6 +230,7 @@ struct ReaderPage {
})
.width("100%")
} else {
// 下方-设置
Column({ space: 24 }) {
Row({ space: 16 }) {
Text('亮度')
Expand All @@ -239,7 +256,7 @@ struct ReaderPage {
Text('字号')
Slider({
value: this.CurrentFontSize,
max: 30,
max: 48,
min: 12,
step: 1,
style: SliderStyle.InSet
Expand Down Expand Up @@ -274,8 +291,34 @@ struct ReaderPage {
})
Row() {
Button('更多')
.bindSheet($$this.isShowMoreLayout, this.LayoutMoreDialog(), {
height: 500,
showClose: false,
dragBar: false,
blurStyle: BlurStyle.COMPONENT_ULTRA_THIN,
onDisappear: () => {
// this.clickBookType = ''
}
})
.onClick(() => {
this.isShowMoreLayout = true
})
}
}

Row({ space: 16 }) {
Text('背景')
Blank(1)
Row() {
Button('更多')
}
}

Row({ space: 16 }) {
Button('自动阅读')
Button('仿真翻页')
Button('更多设置')
}
}
.padding({
left: 20,
Expand Down Expand Up @@ -314,7 +357,9 @@ struct ReaderPage {

GridItem() {
Column() {
Image($r("app.media.my_center_set_icon")).width(24)
Image($r(this.isShowContentSetting ? "app.media.my_center_set_icon_fill" :
"app.media.my_center_set_icon"))
.width(24)
Text("设置")
}
.onClick(() => {
Expand Down Expand Up @@ -346,7 +391,7 @@ struct ReaderPage {
.width("100%")
.height(40)

Scroll(this.scroller) {
Scroll() {
Column() {
Row() {
Text(`${this.txtFile[this.CurrentChapters]?.chapterTitleNumber} ${this.txtFile[this.CurrentChapters]?.title}`.replace(new RegExp('\\s{1,}','g'),' ').replaceAll('=',''))
Expand Down Expand Up @@ -376,13 +421,12 @@ struct ReaderPage {
.width("100%")
}
.padding({
left: 24,
right: 24
left: this.ReaderPadding,
right: this.ReaderPadding
})
}
.layoutWeight(1)


Blank(1)
Row({ space: 4 }) {
Text("1/14 0.1%")
Expand Down Expand Up @@ -453,21 +497,6 @@ struct ReaderPage {
})
}

// 网址导入Dialog
dialogController: CustomDialogController = new CustomDialogController({
builder: Dialog({
title: '加入书架',
CancelString: "暂不加入",
ConfirmString: "加入书架",
child: () => {
this.DialogString()
},
}),
cornerRadius: 16,
gridCount: 4,
offset: { dx: 0, dy: -300 }
})

onBackPress() {
this.dialogController.open();
return true
Expand All @@ -489,4 +518,11 @@ struct ReaderPage {
})
}
}

@Builder
LayoutMoreDialog() {
LayoutMoreDialog({ ReaderPadding: this.ReaderPadding })
.height(500)
.width("100%")
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading