Skip to content

Instantly share code, notes, and snippets.

View chachako's full-sized avatar
🌙
Good night

chachako

🌙
Good night
  • Everywhere
  • 18:06 (UTC +08:00)
View GitHub Profile
@unixzii
unixzii / ContentView.swift
Last active March 30, 2024 08:36
GPU particle system using Metal.
import SwiftUI
struct SmashableView: NSViewRepresentable {
typealias NSViewType = _SmashableNSView
let text: String
class _SmashableNSView: NSView {
@unixzii
unixzii / WeatherView.swift
Created November 7, 2023 13:21
A demo of implementing iOS Weather card in SwiftUI.
import SwiftUI
struct HeaderView: View {
var body: some View {
HStack {
Image(systemName: "info.circle.fill")
.resizable()
.frame(width: 12, height: 12)
Text("Section Header")
.font(.system(size: 13))
@JolandaVerhoef
JolandaVerhoef / Compose-PhotoGrid.kt
Created June 30, 2023 12:14
Photogrid with multi-select and zoomable images
/*
* Copyright 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@SKaplanOfficial
SKaplanOfficial / FloatingRaycastWindow.tsx
Created April 6, 2023 21:51
Raycast command that uses AppleScriptObjC to create a floating window.
import { closeMainWindow } from "@raycast/api"
import { runAppleScript } from "run-applescript"
const displayWindow = async () => {
console.log(await runAppleScript(`use framework "Foundation"
use scripting additions
set theWindow to missing value
-- Can only display windows on the main thread
my performSelectorOnMainThread:"showWindow" withObject:(missing value) waitUntilDone:true
@lewangdev
lewangdev / default.custom.yaml
Last active April 14, 2025 15:12
雾凇拼音自定义配置,MacOS-like & Wechat-like Dark/Light Color Scheme For Rime
patch:
# 菜单
menu:
page_size: 8 # 候选词个数
# alternative_select_labels: [ ①, ②, ③, ④, ⑤, ⑥, ⑦, ⑧, ⑨, ⑩ ] # 修改候选项标签
# alternative_select_keys: ASDFGHJKL # 如编码字符占用数字键,则需另设选字键
# ascii_mode、inline、no_inline、vim_mode 等等设定,可参考 /Library/Input Methods/Squirrel.app/Contents/SharedSupport/squirrel.yaml
# 中西文切换
#
# 【good_old_caps_lock】 CapsLock 切换到大写或切换中英。
@programmerAbc
programmerAbc / WaveSlider.kt
Created February 1, 2023 10:04
compose wave slider
@Composable
fun WaveSlider() {
var progress by remember { mutableStateOf(0f) }
var phase by remember { mutableStateOf(0.0) }
LaunchedEffect(true) {
try {
while (true) {
delay(30)
if (phase >= 10.0) {
phase = 0.0
import android.graphics.Matrix
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.animation.core.LinearEasing
import androidx.compose.animation.core.RepeatMode
import androidx.compose.animation.core.animateFloat
import androidx.compose.animation.core.infiniteRepeatable
import androidx.compose.animation.core.rememberInfiniteTransition
import androidx.compose.animation.core.tween
fun Modifier.saturate(saturation: Float): Modifier =
drawWithCache {
// Cache the paint object so it can be reused between draw calls.
val contentPaint = Paint().apply {
colorFilter = ColorFilter.saturate(saturation)
}
onDrawWithContent {
drawIntoCanvas {
it.saveLayer(Rect(Offset.Zero, size), contentPaint)
@mxalbert1996
mxalbert1996 / Scrollbar.kt
Last active April 15, 2025 09:09
Modifiers to draw scrollbars in Jetpack Compose
/*
* MIT License
*
* Copyright (c) 2022 Albert Chang
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@bloooi
bloooi / SegmentedControl.kt
Created December 4, 2021 12:28
iOS-style segmented control in Compose with Color Custom
package com.example.util.composable
import android.annotation.SuppressLint
import androidx.compose.animation.core.animateDpAsState
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.awaitFirstDown
import androidx.compose.foundation.gestures.forEachGesture
import androidx.compose.foundation.gestures.horizontalDrag