mirror of
https://github.com/Tencent/QMUI_Android.git
synced 2026-10-17 04:31:16 +08:00
feat: Compose tip collect page.
This commit is contained in:
@@ -14,13 +14,20 @@ object Dep {
|
||||
object QMUI {
|
||||
const val group = "com.qmuiteam"
|
||||
const val qmuiVer = "2.0.1"
|
||||
const val archVer = "2.0.1"
|
||||
const val archVer = "2.0.1_f_14"
|
||||
const val typeVer = "0.0.14"
|
||||
const val composeCoreVer = "0.0.1"
|
||||
const val composeVer = "0.0.1"
|
||||
const val photoVer = "0.0.1"
|
||||
}
|
||||
|
||||
object Coroutines {
|
||||
private const val version = "1.6.0"
|
||||
const val core = "org.jetbrains.kotlinx:kotlinx-coroutines-core:$version"
|
||||
const val android = "org.jetbrains.kotlinx:kotlinx-coroutines-android:$version"
|
||||
const val test = "org.jetbrains.kotlinx:kotlinx-coroutines-test:$version"
|
||||
}
|
||||
|
||||
object AndroidX {
|
||||
val appcompat = "androidx.appcompat:appcompat:1.4.0"
|
||||
val annotation = "androidx.annotation:annotation:1.3.0"
|
||||
@@ -38,6 +45,7 @@ object Dep {
|
||||
val material = "androidx.compose.material:material:$version"
|
||||
val compiler = "androidx.compose.compiler:compiler:$version"
|
||||
val activity = "androidx.activity:activity-compose:1.4.0"
|
||||
val constraintlayout = "androidx.constraintlayout:constraintlayout-compose:1.0.0"
|
||||
|
||||
val pager = "com.google.accompanist:accompanist-pager:0.24.0-alpha"
|
||||
}
|
||||
|
||||
@@ -76,8 +76,8 @@ dependencies {
|
||||
implementation(Dep.AndroidX.appcompat)
|
||||
implementation(Dep.AndroidX.annotation)
|
||||
implementation(Dep.MaterialDesign.material)
|
||||
|
||||
implementation(Dep.ButterKnife.butterknife)
|
||||
implementation(Dep.Compose.constraintlayout)
|
||||
kapt(Dep.ButterKnife.compiler)
|
||||
implementation(project(":lib"))
|
||||
implementation(project(":qmui"))
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
package com.qmuiteam.qmuidemo.fragment.lab
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.constraintlayout.compose.ChainStyle
|
||||
import androidx.constraintlayout.compose.ConstraintLayout
|
||||
import androidx.constraintlayout.compose.Dimension
|
||||
import com.qmuiteam.compose.core.ui.QMUITopBarBackIconItem
|
||||
import com.qmuiteam.compose.core.ui.QMUITopBarTextItem
|
||||
import com.qmuiteam.compose.core.ui.QMUITopBarWithLazyScrollState
|
||||
import com.qmuiteam.photo.activity.QMUIPhotoPickerActivity
|
||||
import com.qmuiteam.qmui.arch.annotation.LatestVisitRecord
|
||||
import com.qmuiteam.qmuidemo.R
|
||||
import com.qmuiteam.qmuidemo.activity.QDPhotoPickerActivity
|
||||
import com.qmuiteam.qmuidemo.base.ComposeBaseFragment
|
||||
import com.qmuiteam.qmuidemo.lib.annotation.Widget
|
||||
|
||||
@Widget(name = "QMUI Compose Tip", iconRes = R.mipmap.icon_grid_in_progress)
|
||||
@LatestVisitRecord
|
||||
class QDComposeTipFragment : ComposeBaseFragment() {
|
||||
@Composable
|
||||
override fun PageContent() {
|
||||
Column(modifier = Modifier.fillMaxSize()) {
|
||||
val scrollState = rememberLazyListState()
|
||||
QMUITopBarWithLazyScrollState(
|
||||
scrollState = scrollState,
|
||||
title = "QMUIPhoto",
|
||||
leftItems = arrayListOf(
|
||||
QMUITopBarBackIconItem {
|
||||
popBackStack()
|
||||
}
|
||||
),
|
||||
rightItems = arrayListOf(
|
||||
QMUITopBarTextItem("Pick a Picture") {
|
||||
val activity = activity ?: return@QMUITopBarTextItem
|
||||
val intent = QMUIPhotoPickerActivity.intentOf(activity, QDPhotoPickerActivity::class.java)
|
||||
startActivity(intent)
|
||||
}
|
||||
)
|
||||
)
|
||||
LazyColumn(
|
||||
state = scrollState,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.weight(1f)
|
||||
.background(Color.White)
|
||||
) {
|
||||
item {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(12.dp)
|
||||
) {
|
||||
Text(
|
||||
text = "在 UI 开发过程中,经常会遇到如下一个需求:\n" +
|
||||
"假设一个布局是 【头像】【人名】【推荐信息】,正常用 LinearLayout 实现, " +
|
||||
"是没有任何问题的,但是要求在人名过长,整体内容会超过容器宽度时," +
|
||||
"不要省略推荐信息,而是省略人名信息。",
|
||||
fontSize = 13.sp,
|
||||
modifier = Modifier.padding(vertical = 12.dp)
|
||||
)
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth().height(100.dp)
|
||||
) {
|
||||
ConstraintLayout(
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.fillMaxHeight()
|
||||
.background(Color.LightGray)
|
||||
) {
|
||||
val (one, two, three) = createRefs()
|
||||
createHorizontalChain(one, two, three, chainStyle = ChainStyle.Packed(0f))
|
||||
Text(
|
||||
"此处不压缩",
|
||||
color = Color.White,
|
||||
maxLines = 1,
|
||||
modifier = Modifier
|
||||
.background(Color.Red)
|
||||
.constrainAs(one) {
|
||||
top.linkTo(parent.top)
|
||||
bottom.linkTo(parent.bottom)
|
||||
start.linkTo(parent.start)
|
||||
end.linkTo(two.start)
|
||||
})
|
||||
Text(
|
||||
"此处如果内容有那么一点点过长,那就压缩省略压缩省略压缩省略",
|
||||
color = Color.White,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
modifier = Modifier
|
||||
.background(Color.Green)
|
||||
.constrainAs(two) {
|
||||
width = Dimension.preferredWrapContent
|
||||
top.linkTo(parent.top)
|
||||
bottom.linkTo(parent.bottom)
|
||||
start.linkTo(one.end)
|
||||
end.linkTo(three.start)
|
||||
})
|
||||
Text(
|
||||
"此处也不压缩",
|
||||
color = Color.White,
|
||||
maxLines = 1,
|
||||
modifier = Modifier
|
||||
.background(Color.Black)
|
||||
.constrainAs(three) {
|
||||
top.linkTo(parent.top)
|
||||
bottom.linkTo(parent.bottom)
|
||||
start.linkTo(two.end)
|
||||
end.linkTo(parent.end)
|
||||
})
|
||||
}
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxHeight()
|
||||
.width(50.dp)
|
||||
.background(Color.Blue)
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -44,6 +44,7 @@ import com.qmuiteam.qmuidemo.fragment.components.section.QDSectionLayoutFragment
|
||||
import com.qmuiteam.qmuidemo.fragment.components.viewpager.QDViewPagerFragment;
|
||||
import com.qmuiteam.qmuidemo.fragment.lab.QDAnimationListViewFragment;
|
||||
import com.qmuiteam.qmuidemo.fragment.lab.QDArchTestFragment;
|
||||
import com.qmuiteam.qmuidemo.fragment.lab.QDComposeTipFragment;
|
||||
import com.qmuiteam.qmuidemo.fragment.lab.QDContinuousNestedScrollFragment;
|
||||
import com.qmuiteam.qmuidemo.fragment.lab.QDPhotoClipFragment;
|
||||
import com.qmuiteam.qmuidemo.fragment.lab.QDPhotoFragment;
|
||||
@@ -147,6 +148,7 @@ public class QDDataManager {
|
||||
mLabNames.add(QDArchTestFragment.class);
|
||||
mLabNames.add(QDWebViewFragment.class);
|
||||
mLabNames.add(QDSchemeFragment.class);
|
||||
mLabNames.add(QDComposeTipFragment.class);
|
||||
mLabNames.add(QDPhotoFragment.class);
|
||||
mLabNames.add(QDPhotoClipFragment.class);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user