Skip to content

Commit

Permalink
feat: up-navbar/up-status-bar组件支持uni-app-x
Browse files Browse the repository at this point in the history
  • Loading branch information
jry committed Aug 28, 2024
1 parent f6b0cd6 commit 7ed1f86
Show file tree
Hide file tree
Showing 10 changed files with 472 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@
{left: 0, top: 0},{left: 0, top: 0},{left: 0, top: 0},{left: 0, top: 0},
{left: 0, top: 0},{left: 0, top: 0},{left: 0, top: 0},{left: 0, top: 0},
{left: 0, top: 0},{left: 0, top: 0},{left: 0, top: 0},{left: 0, top: 0}
] as UTSJSONObject[]
] as UTSJSONObject[],
animationFrame: 0
}
},
computed: {
Expand All @@ -109,7 +110,7 @@
this.init()
},
beforeMount() {
cancelAnimationFrame(this.rotateLoader)
cancelAnimationFrame(this.animationFrame)
},
methods: {
addStyle(val: any): any {
Expand All @@ -118,16 +119,16 @@
addUnit(val: any): string {
return addUnit(val)
},
rotateLoader() {
rotateLoader(): void {
this.degree = (this.degree + 3) % 360; // 每次增加3度,循环回到0度
this.transform = `rotate(${this.degree.toString()}deg)`;
requestAnimationFrame(this.rotateLoader); // 递归调用以保持动画
this.animationFrame = requestAnimationFrame(this.rotateLoader); // 递归调用以保持动画
},
init() {
init(): void {
this.calcSpinnerTopAndLeft()
this.rotateLoader()
},
calculateSquareRadius(sideLength: number) {
calculateSquareRadius(sideLength: number): number {
// 计算正方形的对角线长度
const diagonalLength = Math.sqrt(sideLength * sideLength + sideLength * sideLength);
// 对角线长度的一半即为等效圆的半径
Expand Down Expand Up @@ -192,7 +193,7 @@
$up-loading-icon-dot-before-height:25% !default;
$up-loading-icon-dot-before-margin:0 auto !default;
$up-loading-icon-dot-before-background-color:currentColor !default;
$up-loading-icon-dot-before-border-radius:40% !default;
$up-loading-icon-dot-before-border-radius:8px !default;

.up-loading-icon {
display: flex;
Expand Down Expand Up @@ -246,10 +247,10 @@
}
}

:host {
font-size: $up-loading-icon-host-font-size;
line-height: $up-loading-icon-host-line-height;
}
// :host {
// font-size: $up-loading-icon-host-font-size;
// line-height: $up-loading-icon-host-line-height;
// }

.up-loading-icon {
&__spinner--spinner {
Expand Down Expand Up @@ -284,19 +285,19 @@

$radius: v-bind(size)px;
@for $i from 1 through 12 {
.up-loading-icon__dot:nth-of-type(#{$i}) {
transform: rotate(($i + 2) * 30deg);
opacity: 1 - 0.0625 * ($i - 1);
}
// .up-loading-icon__dot:nth-of-type(#{$i}) {
// transform: rotate(($i + 2) * 30deg);
// opacity: 1 - 0.0625 * ($i - 1);
// }
}

@keyframes up-rotate {
0% {
transform: rotate(0deg)
}
// @keyframes up-rotate {
// 0% {
// transform: rotate(0deg)
// }

to {
transform: rotate(1turn)
}
}
// to {
// transform: rotate(1turn)
// }
// }
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
backgroundColor: bgColor,
display: 'flex',
zIndex: zIndex,
...customStyle
...customStyleParse
}"
>
<view class="up-loading-page">
Expand Down Expand Up @@ -77,8 +77,13 @@ export default {
data() {
return {};
},
computed: {
customStyleParse(): UTSJSONObject {
return this.customStyle as UTSJSONObject
}
},
methods: {
addUnit(str: any) {
addUnit(str: any): string {
return addUnit(str)
}
}
Expand Down
32 changes: 32 additions & 0 deletions src/uni_modules/uview-plus/components/up-navbar/navbar.uts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* @Author : LQ,jry
* @Description :
* @version : 4.0
* @Date : 2021-08-20 16:44:21
* @LastAuthor : jry
* @lastTime : 2024-08-28 14:20:58
* @FilePath : /uview-plus/libs/config/props/navbar
*/
import color from '../../libs/config/color'

export default {
// navbar 组件
navbar: {
safeAreaInsetTop: true,
placeholder: false,
fixed: true,
border: false,
leftIcon: 'arrow-left',
leftText: '',
rightText: '',
rightIcon: '',
title: '',
bgColor: '#ffffff',
titleWidth: '400rpx',
height: '44px',
leftIconSize: 20,
leftIconColor: color['mainColor'],
autoBack: false,
titleStyle: {}
}
} as UTSJSONObject
88 changes: 88 additions & 0 deletions src/uni_modules/uview-plus/components/up-navbar/props.uts
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import { defineMixin } from '../../libs/vue'
import defProps from './navbar'
let crtProp = defProps['navbar'] as UTSJSONObject

export const propsNavbar = defineMixin({
props: {
// 是否开启顶部安全区适配
safeAreaInsetTop: {
type: Boolean,
default: crtProp['safeAreaInsetTop']
},
// 固定在顶部时,是否生成一个等高元素,以防止塌陷
placeholder: {
type: Boolean,
default: crtProp['placeholder']
},
// 是否固定在顶部
fixed: {
type: Boolean,
default: crtProp['fixed']
},
// 是否显示下边框
border: {
type: Boolean,
default: crtProp['border']
},
// 左边的图标
leftIcon: {
type: String,
default: crtProp['leftIcon']
},
// 左边的提示文字
leftText: {
type: String,
default: crtProp['leftText']
},
// 左右的提示文字
rightText: {
type: String,
default: crtProp['rightText']
},
// 右边的图标
rightIcon: {
type: String,
default: crtProp['rightIcon']
},
// 标题
title: {
type: [String, Number],
default: crtProp['title']
},
// 背景颜色
bgColor: {
type: String,
default: crtProp['bgColor']
},
// 标题的宽度
titleWidth: {
type: [String, Number],
default: crtProp['titleWidth']
},
// 导航栏高度
height: {
type: [String, Number],
default: crtProp['height']
},
// 左侧返回图标的大小
leftIconSize: {
type: [String, Number],
default: crtProp['leftIconSize']
},
// 左侧返回图标的颜色
leftIconColor: {
type: String,
default: crtProp['leftIconColor']
},
// 点击左侧区域(返回图标),是否自动返回上一页
autoBack: {
type: Boolean,
default: crtProp['autoBack']
},
// 标题的样式,对象或字符串
titleStyle: {
type: [Object],
default: crtProp['titleStyle']
}
}
})
Loading

0 comments on commit 7ed1f86

Please sign in to comment.