Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 70 additions & 27 deletions modules/lock/center/InputField.qml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pragma ComponentBehavior: Bound

import QtQuick
import Quickshell
import M3Shapes
import Caelestia.Config
import qs.components
import qs.services
Expand All @@ -17,7 +18,7 @@ Item {
clip: true

Connections {
function onBufferChanged(): void {
function onBufferChanged() {
if (root.pam.buffer.length > root.buffer.length) {
charList.bindImWidth();
} else if (root.pam.buffer.length === 0) {
Expand Down Expand Up @@ -62,7 +63,7 @@ Item {

readonly property int fullWidth: count * (implicitHeight + spacing) - spacing

function bindImWidth(): void {
function bindImWidth() {
imWidthBehavior.enabled = false;
implicitWidth = Qt.binding(() => fullWidth);
imWidthBehavior.enabled = true;
Expand All @@ -75,67 +76,109 @@ Item {
implicitHeight: Tokens.font.body.medium.pointSize

orientation: Qt.Horizontal
spacing: Tokens.spacing.extraSmall
spacing: Tokens.spacing.small
interactive: false

model: ScriptModel {
values: root.buffer.split("")
}

delegate: StyledRect {
id: ch
delegate: Item {
id: delegateRoot

implicitWidth: implicitHeight
implicitWidth: charList.implicitHeight
implicitHeight: charList.implicitHeight

color: Colours.palette.m3onSurface
radius: Tokens.rounding.medium / 2

opacity: 0
scale: 0
Component.onCompleted: {
opacity = 1;
scale = 1;
}
ListView.onRemove: removeAnim.start()

SequentialAnimation {
id: removeAnim

PropertyAction {
target: ch
target: delegateRoot
property: "ListView.delayRemove"
value: true
}
ParallelAnimation {
Anim {
type: Anim.DefaultEffects
target: ch
target: delegateRoot
property: "opacity"
to: 0
}
Anim {
target: ch
property: "scale"
to: 0.5
property: "implicitSize"
to: 0
}
}
PropertyAction {
target: ch
target: delegateRoot
property: "ListView.delayRemove"
value: false
}
}

Behavior on opacity {
Anim {
type: Anim.DefaultEffects
MaterialShape {
id: ch

property int initialShape: {
const shapes = [MaterialShape.Square, MaterialShape.Slanted, MaterialShape.Arch, MaterialShape.Fan, MaterialShape.Arrow, MaterialShape.SemiCircle, MaterialShape.Triangle, MaterialShape.Diamond, MaterialShape.ClamShell, MaterialShape.Pentagon, MaterialShape.Gem, MaterialShape.Sunny, MaterialShape.VerySunny, MaterialShape.Cookie4Sided, MaterialShape.Cookie6Sided, MaterialShape.Cookie7Sided, MaterialShape.Cookie9Sided, MaterialShape.Cookie12Sided, MaterialShape.Ghostish, MaterialShape.Clover4Leaf, MaterialShape.Clover8Leaf, MaterialShape.Burst, MaterialShape.SoftBurst, MaterialShape.Boom, MaterialShape.SoftBoom, MaterialShape.Flower, MaterialShape.Puffy, MaterialShape.PuffyDiamond, MaterialShape.Bun, MaterialShape.Heart];
return shapes[Math.floor(Math.random() * shapes.length)];
}
}

Behavior on scale {
Anim {
type: Anim.FastSpatial
anchors.centerIn: parent

color: Colours.palette.m3onSurface

shape: initialShape
animationDuration: 200

opacity: 0
implicitSize: 0

Component.onCompleted: {
spawnAnim.start();
}

SequentialAnimation {
id: spawnAnim

ParallelAnimation {
NumberAnimation {
target: ch
property: "implicitSize"
from: 0
to: delegateRoot.implicitHeight * 1.5
duration: 250
easing.type: Easing.OutBack
}
NumberAnimation {
target: ch
property: "opacity"
from: 0
to: 1
duration: 100
}
}

PauseAnimation {
duration: 180
}

ScriptAction {
script: ch.shape = MaterialShape.Circle
}

ParallelAnimation {
NumberAnimation {
target: ch
property: "implicitSize"
to: delegateRoot.implicitHeight
duration: 200
easing.type: Easing.InOutQuad
}
}
}
}
}
Expand Down