|
@@ -2,10 +2,28 @@ import { YTAvoid } from 'basic'
|
|
|
import { DateInfo } from '../models/DateInfo'
|
|
import { DateInfo } from '../models/DateInfo'
|
|
|
import { RecodeViewModel } from '../viewModels/RecodeViewModel'
|
|
import { RecodeViewModel } from '../viewModels/RecodeViewModel'
|
|
|
import { DiaryDatePicker } from '../components/DiaryDatePicker'
|
|
import { DiaryDatePicker } from '../components/DiaryDatePicker'
|
|
|
|
|
+import { DiaryTimePicker } from '../components/DiaryTimePicker'
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 记录页面
|
|
* 记录页面
|
|
|
*/
|
|
*/
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 日历组件
|
|
|
|
|
+ * 1. 懒加载用上
|
|
|
|
|
+ * 2. 纵向 swiper, 最右边(今天)作为头
|
|
|
|
|
+ *
|
|
|
|
|
+ * 加载方式
|
|
|
|
|
+ * 1. 通过监听 swiper index 的变化来触发相应逻辑
|
|
|
|
|
+ *
|
|
|
|
|
+ * * 未通过日历进行跳转日期
|
|
|
|
|
+ * 1. 向左滑动时, 如果日期剩余 < 10,则加载下一周 ( index == list.length - 10 )
|
|
|
|
|
+ *
|
|
|
|
|
+ * * 通过日历进行跳转日期
|
|
|
|
|
+ * * *
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
|
|
+// 小 《 《 《 大
|
|
|
@Component
|
|
@Component
|
|
|
export struct RecodView {
|
|
export struct RecodView {
|
|
|
@StorageProp(YTAvoid.SAFE_BOTTOM_KEY) bottom: number = 0
|
|
@StorageProp(YTAvoid.SAFE_BOTTOM_KEY) bottom: number = 0
|
|
@@ -13,6 +31,13 @@ export struct RecodView {
|
|
|
// ViewModel
|
|
// ViewModel
|
|
|
@State Vm: RecodeViewModel = new RecodeViewModel()
|
|
@State Vm: RecodeViewModel = new RecodeViewModel()
|
|
|
|
|
|
|
|
|
|
+ @State heightList: number[] = []
|
|
|
|
|
+
|
|
|
|
|
+ private linearInfo: LinearGradientOptions = {
|
|
|
|
|
+ colors: [ ['#B9FD2A', 0.01], ['#F5FD6D', 1] ],
|
|
|
|
|
+ angle: 150
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
aboutToAppear(): void {
|
|
aboutToAppear(): void {
|
|
|
this.Vm.selectedDateChange = this.selectDateChange
|
|
this.Vm.selectedDateChange = this.selectDateChange
|
|
|
}
|
|
}
|
|
@@ -34,39 +59,57 @@ export struct RecodView {
|
|
|
animateToImmediately({
|
|
animateToImmediately({
|
|
|
duration: 200
|
|
duration: 200
|
|
|
}, () => {
|
|
}, () => {
|
|
|
- this.Vm.showTimePicker = !this.Vm.showTimePicker;
|
|
|
|
|
|
|
+ if(this.Vm.showDatePicker) {
|
|
|
|
|
+ this.Vm.showDatePicker = false
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.Vm.showDatePicker = true
|
|
|
|
|
+ this.Vm.showTimePicker = -1
|
|
|
|
|
+ }
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
.width("100%")
|
|
.width("100%")
|
|
|
|
|
+ .height(76)
|
|
|
.justifyContent(FlexAlign.SpaceBetween)
|
|
.justifyContent(FlexAlign.SpaceBetween)
|
|
|
|
|
+ .alignItems(VerticalAlign.Center)
|
|
|
|
|
+ .padding({ left: 17, right: 17, bottom: 17, top: 17})
|
|
|
|
|
+ .onClick(() => {
|
|
|
|
|
+ this.Vm.showTimePicker = -1
|
|
|
|
|
+ this.Vm.showDatePicker = false
|
|
|
|
|
+ })
|
|
|
|
|
|
|
|
|
|
+ // 主体内容
|
|
|
Stack({alignContent: Alignment.TopEnd}){
|
|
Stack({alignContent: Alignment.TopEnd}){
|
|
|
- /**
|
|
|
|
|
- * 日历组件
|
|
|
|
|
- * 1. 懒加载用上
|
|
|
|
|
- * 2. 纵向 swiper, 最右边(今天)作为头
|
|
|
|
|
- *
|
|
|
|
|
- * 加载方式
|
|
|
|
|
- * 1. 通过监听 swiper index 的变化来触发相应逻辑
|
|
|
|
|
- *
|
|
|
|
|
- * * 未通过日历进行跳转日期
|
|
|
|
|
- * 1. 向左滑动时, 如果日期剩余 < 10,则加载下一周 ( index == list.length - 10 )
|
|
|
|
|
- *
|
|
|
|
|
- * * 通过日历进行跳转日期
|
|
|
|
|
- * * *
|
|
|
|
|
- */
|
|
|
|
|
-
|
|
|
|
|
- // 小 《 《 《 大
|
|
|
|
|
Column(){
|
|
Column(){
|
|
|
|
|
+ // 日期选择
|
|
|
Swiper(this.Vm.swiperController){
|
|
Swiper(this.Vm.swiperController){
|
|
|
LazyForEach(this.Vm.weekLoop, (item: DateInfo, index: number) => {
|
|
LazyForEach(this.Vm.weekLoop, (item: DateInfo, index: number) => {
|
|
|
- Column() {
|
|
|
|
|
- Text(item.week)
|
|
|
|
|
- Text(`${item.month}-${item.day}`)
|
|
|
|
|
|
|
+ Column({space: 2}) {
|
|
|
|
|
+ Column({space: 15}){
|
|
|
|
|
+ Text(item.week)
|
|
|
|
|
+ // ${item.month}-
|
|
|
|
|
+ Text(`${item.day}`)
|
|
|
|
|
+ }
|
|
|
|
|
+ .width("100%")
|
|
|
|
|
+ .padding({ top: 5, bottom: 5 })
|
|
|
|
|
+ .borderRadius(10)
|
|
|
|
|
+ .linearGradient(this.Vm.selectedDate === index ? this.linearInfo : null)
|
|
|
|
|
+
|
|
|
|
|
+ // TODO 表示某天有数据
|
|
|
|
|
+ if(true) {
|
|
|
|
|
+ Row()
|
|
|
|
|
+ .width(6)
|
|
|
|
|
+ .height(6)
|
|
|
|
|
+ .borderRadius(3)
|
|
|
|
|
+ .backgroundColor('#BAFE2B')
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- .border({
|
|
|
|
|
- width: this.Vm.selectedDate === index ? 1 : 0
|
|
|
|
|
|
|
+ .width(50)
|
|
|
|
|
+ .height(80)
|
|
|
|
|
+ .padding({
|
|
|
|
|
+ left: 7,
|
|
|
|
|
+ right: 7,
|
|
|
|
|
+ top: 9,
|
|
|
})
|
|
})
|
|
|
.onClick(() => {
|
|
.onClick(() => {
|
|
|
this.Vm.selectedDate = index
|
|
this.Vm.selectedDate = index
|
|
@@ -80,32 +123,192 @@ export struct RecodView {
|
|
|
.onChange((index: number) => {
|
|
.onChange((index: number) => {
|
|
|
this.Vm.swiperOnChange(index)
|
|
this.Vm.swiperOnChange(index)
|
|
|
})
|
|
})
|
|
|
|
|
+
|
|
|
|
|
+ // 记录内容主体
|
|
|
|
|
+ List({space: 10}) {
|
|
|
|
|
+ ListItem()
|
|
|
|
|
+ .height(20)
|
|
|
|
|
+ .onClick(() => {
|
|
|
|
|
+ this.Vm.showTimePicker = -1
|
|
|
|
|
+ this.Vm.showDatePicker = false
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ ForEach(new Array(10).fill(0), (item: number, index: number) => {
|
|
|
|
|
+ ListItem(){
|
|
|
|
|
+ Stack({alignContent: Alignment.TopStart}){
|
|
|
|
|
+ Row({space: 20}){
|
|
|
|
|
+ // 时间 和 分隔线
|
|
|
|
|
+ Column({space: 5}){
|
|
|
|
|
+ Row(){
|
|
|
|
|
+ Text("13:49")
|
|
|
|
|
+ .fontSize(14)
|
|
|
|
|
+ .padding({
|
|
|
|
|
+ top: 5,
|
|
|
|
|
+ left: 8,
|
|
|
|
|
+ right: 8,
|
|
|
|
|
+ bottom: 5
|
|
|
|
|
+ })
|
|
|
|
|
+ .fontWeight(400)
|
|
|
|
|
+ .borderRadius(8)
|
|
|
|
|
+ .fontColor(Color.Black)
|
|
|
|
|
+ .linearGradient(this.linearInfo)
|
|
|
|
|
+ }
|
|
|
|
|
+ .width(54)
|
|
|
|
|
+ .height(30)
|
|
|
|
|
+ .alignItems(VerticalAlign.Center)
|
|
|
|
|
+ .justifyContent(FlexAlign.Center)
|
|
|
|
|
+ .onClick(() => {
|
|
|
|
|
+ if(this.Vm.showTimePicker === index) {
|
|
|
|
|
+ this.Vm.showTimePicker = -1
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.Vm.showTimePicker = index
|
|
|
|
|
+ this.Vm.showDatePicker = false
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ // 分隔线
|
|
|
|
|
+ Column(){
|
|
|
|
|
+ Row() {
|
|
|
|
|
+ Row()
|
|
|
|
|
+ .width(7)
|
|
|
|
|
+ .aspectRatio(1)
|
|
|
|
|
+ .borderRadius(4)
|
|
|
|
|
+ .backgroundColor(Color.White)
|
|
|
|
|
+ }
|
|
|
|
|
+ .width(10)
|
|
|
|
|
+ .aspectRatio(1)
|
|
|
|
|
+ .borderRadius(5)
|
|
|
|
|
+ .backgroundColor('#B9FD2A')
|
|
|
|
|
+ .alignItems(VerticalAlign.Center)
|
|
|
|
|
+ .justifyContent(FlexAlign.Center)
|
|
|
|
|
+
|
|
|
|
|
+ Row()
|
|
|
|
|
+ .width(3)
|
|
|
|
|
+ .backgroundColor('#E9E9EC')
|
|
|
|
|
+ .layoutWeight(1)
|
|
|
|
|
+
|
|
|
|
|
+ Row() {
|
|
|
|
|
+ Row()
|
|
|
|
|
+ .width(7)
|
|
|
|
|
+ .aspectRatio(1)
|
|
|
|
|
+ .borderRadius(4)
|
|
|
|
|
+ .backgroundColor(Color.White)
|
|
|
|
|
+ }
|
|
|
|
|
+ .width(10)
|
|
|
|
|
+ .aspectRatio(1)
|
|
|
|
|
+ .borderRadius(5)
|
|
|
|
|
+ .backgroundColor('#B9FD2A')
|
|
|
|
|
+ .alignItems(VerticalAlign.Center)
|
|
|
|
|
+ .justifyContent(FlexAlign.Center)
|
|
|
|
|
+ }
|
|
|
|
|
+ .width(30)
|
|
|
|
|
+ .height(this.heightList[index] + 15)
|
|
|
|
|
+ }
|
|
|
|
|
+ // .layoutWeight(1)
|
|
|
|
|
+
|
|
|
|
|
+ // 标题 和 内容
|
|
|
|
|
+ Column({space: 5}){
|
|
|
|
|
+ Row(){
|
|
|
|
|
+ Text("生活日记")
|
|
|
|
|
+ .fontSize(14)
|
|
|
|
|
+ .fontWeight(600)
|
|
|
|
|
+ .padding({
|
|
|
|
|
+ top: 5,
|
|
|
|
|
+ left: 8,
|
|
|
|
|
+ right: 8,
|
|
|
|
|
+ bottom: 5
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ .height(30)
|
|
|
|
|
+ .alignItems(VerticalAlign.Center)
|
|
|
|
|
+ .justifyContent(FlexAlign.Center)
|
|
|
|
|
+
|
|
|
|
|
+ // 内容
|
|
|
|
|
+ Column({space: 8}){
|
|
|
|
|
+ Text("内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容")
|
|
|
|
|
+ .fontSize(12)
|
|
|
|
|
+ .fontColor('#212245')
|
|
|
|
|
+ .opacity(0.5)
|
|
|
|
|
+
|
|
|
|
|
+ // 图片显示
|
|
|
|
|
+ Scroll(){
|
|
|
|
|
+ Row({space: 5}){
|
|
|
|
|
+ ForEach(new Array(5).fill(0), (item: number, index: number) => {
|
|
|
|
|
+ Image('https://hm-static.ytpm.net/upload/20250820/fa210da5-b364-4469-a6c8-d8a9038af687-1755657677967.jpeg')
|
|
|
|
|
+ .width(100)
|
|
|
|
|
+ .height(150)
|
|
|
|
|
+ .borderRadius(12)
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ .scrollable(ScrollDirection.Horizontal)
|
|
|
|
|
+ .scrollBar(BarState.Off)
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ .alignItems(HorizontalAlign.Start)
|
|
|
|
|
+ .justifyContent(FlexAlign.Start)
|
|
|
|
|
+ .onAreaChange((_o: Area, _n: Area) => {
|
|
|
|
|
+ this.heightList[index] = _n.height as number
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ Blank().height(15)
|
|
|
|
|
+ }
|
|
|
|
|
+ .layoutWeight(1)
|
|
|
|
|
+ .alignItems(HorizontalAlign.Start)
|
|
|
|
|
+ .justifyContent(FlexAlign.Start)
|
|
|
|
|
+ }
|
|
|
|
|
+ .onClick(() => {
|
|
|
|
|
+ this.Vm.showTimePicker = -1
|
|
|
|
|
+ this.Vm.showDatePicker = false
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ // 时间选择器
|
|
|
|
|
+ if(this.Vm.showTimePicker == index) {
|
|
|
|
|
+ DiaryTimePicker()
|
|
|
|
|
+ .offset({
|
|
|
|
|
+ x: 5,
|
|
|
|
|
+ y: 35
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ .width("100%")
|
|
|
|
|
+ .layoutWeight(1)
|
|
|
|
|
+ .padding({ left: 24, right: 24, top: 10})
|
|
|
|
|
+ .scrollBar(BarState.Off)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if(this.Vm.showTimePicker) {
|
|
|
|
|
|
|
+ // 时间选择器
|
|
|
|
|
+ if(this.Vm.showDatePicker) {
|
|
|
DiaryDatePicker({
|
|
DiaryDatePicker({
|
|
|
selectedDate: this.Vm.weekLoop.getData(this.Vm.swiperCurrentIndex).id,
|
|
selectedDate: this.Vm.weekLoop.getData(this.Vm.swiperCurrentIndex).id,
|
|
|
selectDateBack: (date: Date) => {
|
|
selectDateBack: (date: Date) => {
|
|
|
- this.Vm.showTimePicker = false
|
|
|
|
|
|
|
+ this.Vm.showDatePicker = false
|
|
|
this.Vm.jumpToDate(date)
|
|
this.Vm.jumpToDate(date)
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
- .width("80%")
|
|
|
|
|
|
|
+ .width(267)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
.width("100%")
|
|
.width("100%")
|
|
|
.layoutWeight(1)
|
|
.layoutWeight(1)
|
|
|
-
|
|
|
|
|
- Button("check")
|
|
|
|
|
- .onClick(() => {
|
|
|
|
|
- for (let index = 0; index < this.Vm.weekLoop.totalCount(); index++) {
|
|
|
|
|
- console.log(`${ this.Vm.swiperCurrentIndex == index ? 'ToDay' : '' } ${this.Vm.weekLoop.getData(index).month} 月 ${this.Vm.weekLoop.getData(index).day} 日 `)
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ .backgroundColor(Color.White)
|
|
|
|
|
+ .borderRadius({
|
|
|
|
|
+ topLeft: 20,
|
|
|
|
|
+ topRight: 20
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
.width("100%")
|
|
.width("100%")
|
|
|
.height("100%")
|
|
.height("100%")
|
|
|
- .padding({ top: this.safeTop + 22, left: 16, right: 16 })
|
|
|
|
|
|
|
+ .padding({ top: this.safeTop + 22})
|
|
|
|
|
+ .linearGradient({
|
|
|
|
|
+ colors: [ ['#B9FD2A', 0.01], ['#F5FD6D', 1] ],
|
|
|
|
|
+ angle: 150
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|