Skip to content

Commit

Permalink
Merge pull request #220 from mgz0227/dev_2008
Browse files Browse the repository at this point in the history
订阅源页面debug、更多功能
  • Loading branch information
MaoXiaoone authored Jul 22, 2024
2 parents 3db6a57 + 374b5ee commit 5eb9dc2
Show file tree
Hide file tree
Showing 11 changed files with 408 additions and 55 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 21 additions & 7 deletions entry/src/main/ets/componets/dialog/help.ets
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ export default struct Help {
btnText: string = ''
btnClick: Function = () => {
}
@Builder contentBuilders() {}
// 自定义左侧区域
@BuilderParam contentBuilder: () => void = this.contentBuilders
@StorageLink('bottomRectHeight') bottomRectHeight: number = 0

isShowContent:boolean = true
build() {
Flex({
direction: FlexDirection.Column,
Expand All @@ -31,13 +34,24 @@ export default struct Help {
.padding({
bottom: PaddingConstants.PADDING_12
})
if (this.contentBuilders !== this.contentBuilder) {
Column(){
this.contentBuilder()
}
.padding({
top: PaddingConstants.PADDING_12,
bottom: PaddingConstants.PADDING_12
})
}
if (this.isShowContent){
Flex() {
Text(!this.context ? HelpInfo.HELP_INFO_MESSAGE : this.context)
}.padding({
top: PaddingConstants.PADDING_12,
bottom: PaddingConstants.PADDING_12
})
}

Flex() {
Text(!this.context ? HelpInfo.HELP_INFO_MESSAGE : this.context)
}.padding({
top: PaddingConstants.PADDING_12,
bottom: PaddingConstants.PADDING_12
})
}

Button(!this.btnText ? $r('app.string.i_know') : this.btnText)
Expand Down
10 changes: 9 additions & 1 deletion entry/src/main/ets/database/AppDatabase/index.ets
Original file line number Diff line number Diff line change
Expand Up @@ -1291,6 +1291,14 @@ export default {
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "autoComplete",
"columnName": "autoComplete",
"affinity": "INTEGER",
"boolean": true,
"notNull": true,
"defaultValue": "0"
},
],
"primaryKey": {
"autoGenerate": false,
Expand Down Expand Up @@ -1979,7 +1987,7 @@ export default {
},
{
"tableName": "rss_sources_history",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`sourceType` INTEGER NOT NULL ,`sourceGroup` TEXT,`sourceUrl` TEXT NOT NULL, `sourceName` TEXT NOT NULL, `sourceIcon` TEXT NOT NULL,`lastUpdateTime` INTEGER NOT NULL DEFAULT 0,`sourceIconIsUrl` INTEGER ,`showRecentIcon` INTEGER NOT NULL DEFAULT 1,`customizeTitle` TEXT, PRIMARY KEY(`sourceUrl`))",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`sourceType` INTEGER NOT NULL ,`sourceGroup` TEXT,`sourceUrl` TEXT NOT NULL, `sourceName` TEXT NOT NULL, `sourceIcon` TEXT NOT NULL,`lastUpdateTime` INTEGER NOT NULL DEFAULT 0,`sourceIconIsUrl` INTEGER ,`showRecentIcon` INTEGER NOT NULL DEFAULT 1 ,`autoComplete` INTEGER NOT NULL DEFAULT 0,`customizeTitle` TEXT, PRIMARY KEY(`sourceUrl`))",
"fields": [
{
"fieldPath": "sourceType",
Expand Down
2 changes: 1 addition & 1 deletion entry/src/main/ets/database/entities/rssSources.ets
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class rssSources{
// 图标是否使用链接
sourceIconIsUrl:boolean = false
// 分组
sourceGroup:string = SUBSCRIPTION_GROUP_TYPE[0]
sourceGroup:string = SUBSCRIPTION_GROUP_TYPE[4]
//源注解
sourceComment?:string
//是否启用
Expand Down
2 changes: 2 additions & 0 deletions entry/src/main/ets/entryability/EntryAbility.ets
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { AbilityConstant, Want } from '@kit.AbilityKit';
import display from '@ohos.display';
import DbUtil from '../common/utils/DbUtil';
import DataBase from '../database'
import { webview } from '@kit.ArkWeb';

export default class EntryAbility extends UIAbility {

Expand Down Expand Up @@ -33,6 +34,7 @@ export default class EntryAbility extends UIAbility {
}

onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) {
webview.WebviewController.initializeWebEngine()//初始化web控件
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
}

Expand Down
1 change: 1 addition & 0 deletions entry/src/main/ets/pages/Index.ets
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ struct Main {
justifyContent:FlexAlign.Center
}){
Image(this.currentTabIndex === index?icon_select:unselected).height(25)
.draggable(false)
Text(name).fontSize(11).margin(5).fontColor(this.currentTabIndex === index ?'rgb(255,119, 50)' : '#000000')
}
}.gesture(
Expand Down
218 changes: 197 additions & 21 deletions entry/src/main/ets/pages/view/Subscription/RssSources/newSources.ets
Original file line number Diff line number Diff line change
@@ -1,47 +1,109 @@
/**
* @author 2008
* @datetime 2024/7/16 18:13
* @className: newSources
* 新建/修改订阅源
*/
import CommonConstants from '../../../../common/constants/CommonConstants'
import FontConstants from '../../../../common/constants/FontConstants'
import ImageConstants from '../../../../common/constants/ImageConstants'
import PaddingConstants from '../../../../common/constants/PaddingConstants'
import TextConstants from '../../../../common/constants/TextConstants'
import { isNetworkUrl } from '../../../../common/utils/utils'
import buttonCommon from '../../../../componets/common/buttonCommon'
import dialogTitleFuction from '../../../../componets/common/dialogTitleFuction'
import { showMessage } from '../../../../componets/common/promptShow'
import Help from '../../../../componets/dialog/help'
import FormItem from '../../../../componets/Form/FormItem'
import SubscriptionDao from '../../../../database/dao/SubscriptionDao'
import { rssSources, SUBSCRIPTION_GROUP_TYPE } from '../../../../database/entities/rssSources'
import { rssListRule } from '../../../../database/entities/rule/rssListRule'
import { rssWebViewRule } from '../../../../database/entities/rule/rssWebViewRule'
import programDataPreferences from '../../../../preferences/programDataPreferences'
import SourceDebug from '../../Find/BookSource/components/SourceDebug'
import PreviewEffectImage from '../components/PreviewEffectImage'
import RssSourceCheckImage from '../components/RssSourceCheckImage'
import rssSourcesHelp from '../components/rssSourcesHelp'

@Component
export default struct newSources{
@State isShowHelp: boolean = false
@State isShowMenu: boolean = false
hideNewSources:Function = ()=>{}
@State currentIndex: number = 0
@Prop isEdit:boolean = false
private controller: TabsController = new TabsController()
private headController: TabsController = new TabsController()
@State @Watch('onReadChange') readIndex: number = 0
onReadChange() {
console.log(this.readIndex + '')
this.headController.changeIndex(this.readIndex)
}
@State readIndex: number = 0


build() {
Column(){
Column(){
Text(`${this.isEdit?'编辑':'新建'}订阅源`)
.fontSize(FontConstants.FONT_SIZE_16)
.fontWeight(FontConstants.FONT_WEIGHT_500)
.lineHeight(24)
.fontColor($r('app.string.color_black_88'))
.textAlign(TextAlign.Center)
Flex({
justifyContent:FlexAlign.SpaceBetween,
alignItems:ItemAlign.Center
}){
if (this.readIndex===1){
Image($r('app.media.return_left'))
.width(25)
.height(25)
.onClick(()=>{
this.headController.changeIndex(0)
})
}
Text(this.readIndex===0?`${this.isEdit?'编辑':'新建'}订阅源`:'调试源')
.fontSize(FontConstants.FONT_SIZE_18)
.fontWeight(FontConstants.FONT_WEIGHT_500)
.lineHeight(26)
.fontColor($r('app.string.color_black_88'))
.textAlign(TextAlign.Center)

Row({
space:20
}){
Row({
space: 4
}){
if (this.readIndex === 0){
Image($r('app.media.icon_dubug'))
.fillColor($r('app.string.color_black_88'))
.width(ImageConstants.IMG_WIDTH_20)
.height(ImageConstants.IMG_HEIGHT_20)
Text('调试')
.font({
size: FontConstants.FONT_SIZE_14,
weight: FontConstants.FONT_WEIGHT_400,
family: CommonConstants.FAMILY_PingFANG
})
.fontColor($r('app.string.color_black_88'))
.lineHeight(22)
}
}
.onClick(()=>{
this.headController.changeIndex(1)
})
Image(this.readIndex === 0?$r('app.media.more'):$r('app.media.more_translate'))
.fillColor($r('app.string.color_black_88'))
.width(ImageConstants.IMG_WIDTH_24)
.height(ImageConstants.IMG_HEIGHT_24)
.bindPopup(
this.isShowMenu,{
builder: this.rightMoreDialogBuilder(),//todo dubug弹窗菜单不一样
placement: Placement.Bottom,
radius:10,
enableArrow: false,
popupColor:Color.Transparent,
onStateChange: (e) => {
if (!e.isVisible) {
this.isShowMenu = false;
}
},
transition:!this.isShowMenu?TransitionEffect.asymmetric(
TransitionEffect.OPACITY.animation({ duration: 1000, curve: Curve.Ease }).combine(
TransitionEffect.translate({ x: 0, y: 1 })), TransitionEffect.IDENTITY)
:TransitionEffect.scale({ x: 1, y: 0 }).animation({ duration: 500, curve: Curve.Ease })
}
)
.onClick(() => {
this.isShowMenu = !this.isShowMenu
})
}
}
Tabs({ barPosition: BarPosition.Start, index: this.readIndex, controller: this.headController }) {
TabContent() {
Column() {
Expand Down Expand Up @@ -72,7 +134,7 @@ export default struct newSources{
}.layoutWeight(1)

TabContent() {
// SourceDebug()
SourceDebug() //todo 需要写一个订阅源页面
}.layoutWeight(1)
}
.barWidth(0)
Expand Down Expand Up @@ -126,6 +188,15 @@ export default struct newSources{
this.isShowPresetIcon = false
}
})
Flex()
.bindSheet($$this.isShowHelp, this.dialogHelpFuction(), {
height: '65%',
showClose: false,
dragBar: false,
onDisappear: () => {
this.isShowHelp = false
}
})
}
}
private scroller: Scroller = new Scroller()
Expand All @@ -139,7 +210,7 @@ export default struct newSources{
lastUpdateTime: new Date().getTime(),
customOrder: 0,
autoComplete: false,
sourceGroup: SUBSCRIPTION_GROUP_TYPE[0],
sourceGroup: SUBSCRIPTION_GROUP_TYPE[4],
enabled: true,
singleUrl: true,
showRecentIcon: true,
Expand All @@ -166,6 +237,7 @@ export default struct newSources{
if (!this.formModel.rssWebViewRule) {
this.formModel.rssWebViewRule = new rssWebViewRule()
}
this.readIndex = 0
}

@Builder
Expand Down Expand Up @@ -215,7 +287,10 @@ export default struct newSources{

Row() {
Select(this.sourceGroupList)
.value(this.formModel.sourceGroup.length === 0?SUBSCRIPTION_GROUP_TYPE[0]:this.formModel.sourceGroup)
.selected(this.sourceGroupList.findIndex((item) => {
return item.value === this.formModel.sourceGroup
}))
.value(this.formModel.sourceGroup?this.formModel.sourceGroup:SUBSCRIPTION_GROUP_TYPE[4])
.borderRadius(4)
.fontColor(this.formModel.sourceGroup !== undefined ? '#E0000000' : '#73000000')
.onSelect((index: number, text?: string | undefined) => {
Expand Down Expand Up @@ -615,4 +690,105 @@ export default struct newSources{
}
}
}
}

Item_Right_MORE_Dialog_Data: string[] = ['清除Cookie','自动补全','拷贝源','粘贴源','设置原变量','字符串分享','帮助']
dialogMoreRightChange(index:number){
switch (index) {
case 0:
showMessage('清除Cookie')
break
case 2:
showMessage('拷贝源')
break
case 3:
showMessage('粘贴源')
break
case 4:
showMessage('设置原变量')
break
case 5:
showMessage('字符串分享')
break
case 6:
this.isShowHelp = true
showMessage('帮助')
break
}
}
@Builder
rightMoreDialogBuilder() {
Column(){
ForEach(this.Item_Right_MORE_Dialog_Data, (item: string, index) => {
if (index === 1) {
this.toggleBuilder(item)
} else {
dialogTitleFuction({
title: item,
isBorder: this.Item_Right_MORE_Dialog_Data.length !== index + 1
})
.onClick(() => {
this.dialogMoreRightChange(index)
})
}
})
}
.alignItems(HorizontalAlign.Start)
}
@Builder
toggleBuilder(title:string) {
Column() {
Row({
space:5
}){
Text(title)
.font({
size:FontConstants.FONT_SIZE_14,
weight:FontConstants.FONT_WEIGHT_400,
family:CommonConstants.FAMILY_PingFANG
})
.fontColor($r('app.string.color_black_88'))
.lineHeight(TextConstants.TEXT_LINE_HEIGHT_22)
Toggle({ type: ToggleType.Switch, isOn: this.formModel.autoComplete})
.selectedColor(0xff6600)
.margin({ left: 8 })
.onChange((val: boolean) => {
this.formModel.autoComplete = val
})
}
.border({
style: BorderStyle.Solid,
width: 1,
color: '#f5f5f5'
})
.padding({
top:PaddingConstants.PADDING_12,
bottom:PaddingConstants.PADDING_12})
.alignItems(VerticalAlign.Center)
.justifyContent(FlexAlign.Center)
}
.padding({
left:PaddingConstants.PADDING_20,
right:PaddingConstants.PADDING_20,})
}


@Builder
dialogHelpFuction() {
Column() {
Help({
title:'源规则帮助',
btnClick:()=>{
this.isShowHelp = false
},
contentBuilder:this.helpContent,
isShowContent:false
})
}
}
@Builder
helpContent(){
Column(){
rssSourcesHelp()
}
}
}
Loading

0 comments on commit 5eb9dc2

Please sign in to comment.