当前位置:网站首页>Use compose to realize the effect of selecting movie seats by panning tickets
Use compose to realize the effect of selecting movie seats by panning tickets
2022-06-30 02:55:00 【Android】
Pay attention to the official account and learn more
This is a blog written last year
cause
The new year is coming , Watching movies is an essential entertainment in our new year , When watching the movie, did you ever think about how to realize the seat selection space , A good programmer , I thought about it , Today I will take you to study .
compose The series of drawing was completed two months ago , But only for api Proficiency , So today we are going to make a custom seat for imitation of the movie seats ui.
Effect view
Let's take a look at the implementation of Alipay client
We found that the main point of seat selection is the drawing of seats 、 The logic of seat selection 、 Two finger gesture zoom 、 Single finger long press and drag effect . So the key is to realize these effects
Having said that, let's release the results we have achieved in advance :
To achieve the point
Draw seat
We can draw seats by ourselves drawRoundRect api To achieve , However, in order to increase the difficulty, we use path A seat made by splicing . The goal is also to facilitate the expansion of seats into other shapes in the future
structure path Code for :
val path = Path().apply {
moveTo(boundStart.x, boundStart.y + radius)
addArc(// Draw the arc
Rect(Offset(boundStart.x + radius, boundStart.y + radius), radius),
180f,
90f,
)
lineTo(boundEnd.x - radius, boundStart.y)
arcTo(
Rect(Offset(boundEnd.x - radius, boundStart.y + radius), radius),
270f,
90f,
false
)
lineTo(boundEnd.x, boundEnd.y - radius)
arcTo(Rect(Offset(boundEnd.x - radius, boundEnd.y - radius), radius), 0f, 90f, false)
lineTo(boundStart.x + radius, boundEnd.y)
arcTo(Rect(Offset(boundStart.x + radius, boundEnd.y - radius), radius), 90f, 90f, false)
close()
}
drawpath:
drawPath(
path,
if (seat.type == 0) Color(0xfff4d9bd) else Color(0xffc3d9e9),
style = Stroke(strokeWidth)// Use Stroke Can guarantee our path It is the effect of line makeup
)
Two finger operation gesture
The use of gestures can refer to the articles I have written before , Portal
Using two finger gestures requires the following two Modifier The operator :
.graphicsLayer
.transformable(state = state)
The implementation code is as follows :
var scale by remember {
mutableStateOf(1f) }
var offset by remember {
mutableStateOf(Offset.Zero) }
val state = rememberTransformableState {
zoomChange, offsetChange, rotationChange ->
scale *= zoomChange
offset += offsetChange
}
Box(
Modifier
.fillMaxSize(),
contentAlignment = Alignment.Center
) {
The content part
....
}
Code :https://github.com/ananananzhuo-blog/MovieSeatProject
边栏推荐
- A quick look at the statistical data of 23 major cyber crimes from 2021 to 2022
- IDEA 远程调试 Remote JVM Debug
- 2022护网行动在即,关于护网的那些事儿
- FDA ESG regulation: digital certificate must be used to ensure communication security
- 在php中字符串的概念是什么
- How can redis+aop customize annotations to achieve flow restriction
- 自定义JvxeTable的按钮及备注下$set的用法
- Add a custom button to jvxetable
- [oiclass] chess piece
- 002 color classification
猜你喜欢
How to use vant to realize data paging and drop-down loading
Software testing skills, JMeter stress testing tutorial, transaction controller of logic controller (25)
Steam elements hidden in science and Technology Education
Matlab code running tutorial (how to run the downloaded code)
如何在 JupyterLab 中把 ipykernel 切换到不同的 conda 虚拟环境?
GTK interface programming (I): Environment Construction
Welfare lottery | what are the highlights of open source enterprise monitoring zabbix6.0
Ffmpeg source code
How to prevent duplicate submission under concurrent requests
Visual HTA form designer htamaker interface introduction and usage, Download | HTA VBS visual script writing
随机推荐
How to use vant to realize data paging and drop-down loading
Lua Basics
Recursion frog jumping steps problem
How to switch ipykernel to a different CONDA virtual environment in jupyterlab?
002 color classification
IDEA 远程调试 Remote JVM Debug
How to set password complexity and timeout exit function in Oracle
How can redis+aop customize annotations to achieve flow restriction
LeetCode 3. 无重复字符的最长子串
迅為恩智浦iTOP-IMX6開發平臺
如何在 JupyterLab 中把 ipykernel 切换到不同的 conda 虚拟环境?
Call collections Sort() method, compare two person objects (by age ratio first, and by name ratio for the same age), and pass lambda expression as a parameter.
Global and Chinese market of ERP software for garment and textile industries 2022-2028: Research Report on technology, participants, trends, market size and share
shell统计某个字符串最后一次出现的位置之前的所有字符串
Linear algebra Chapter 4 Summary of knowledge points of linear equations (Jeff's self perception)
2. 成功解决 BUG:Exception when publishing, ...[Failed to connect and initialize SSH connection...
unity的text首列有标点符号咋办
重磅来袭--UE5的开源数字孪生解决方案
What files does a CA digital certificate contain? How to view SSL certificate information?
JMeter obtains cookies across thread groups or JMeter thread groups share cookies