๐จ What I Designed
์ง์ ๊ตฌํ์ ๋ฒํผ ๋ฐ์ด์ฑ ํจ๊ณผ์ ํ ์ค์ฑ์ ๊ตฌํ๋ ๋ฒํผ ํจ๊ณผ ๋น๊ต
https://github.com/suojae/flutter_ui_lab/blob/main/lib/2025/02/10.dart
flutter_ui_lab/lib/2025/02/10.dart at main · suojae/flutter_ui_lab
Contribute to suojae/flutter_ui_lab development by creating an account on GitHub.
github.com
๐ How I Made It
BoxShadow๋ฅผ ์ด์ฉํ Shadow ํจ๊ณผ
์ด์ ๊ฒ์๊ธ์์ Bouncing ํจ๊ณผ๋ฅผ ShadowBox๋ก ๊ตฌํํ์๋ค. ํ์ง๋ง ์ด ๋ฐฉ์์ ๋ง์น ๊ทธ๋ฆผ์ ๋ง์น ํ๋ฏ์ด Material ์์คํ ๊ณผ ๋ฐ๋ก ๋ ธ๋ ๋ฐฉ์์ด์๋ค. (Material์ Z์ถ์ ํตํด ์ ์ฒด๊ฐ ์ ๊ณต) ์ค์ ์์ ฏ์ด ๋ ์๋๊ฒ ์๋ ๋ ์๋ ๋ฏํ ์ ์ฒด๊ฐ์ ์ฃผ๊ธฐ์ํด Box ์ฃผ๋ณ (via BoxDecoration) ์ ๊ทธ๋ฆผ์ ํจ๊ณผ๋ฅผ ์ฃผ์ด ๊ฐ์ ํ๋ฉด์ ์์์๋ ์ ์ฒด๊ฐ์ด ์๋๋ฏ ๋์์์ ํ๋ ๋ฐฉ์์ด์๋ค.
Why PhysicalModel Class
ํ์ง๋ง PhysiclaModel ์ elavation ๊ฐ์ ์กฐ์ ํ๊ฒ ๋๋ฉด ๋์์์ด ์๋ ์ค์ ๋ก ๋ ์๋ ์์ ฏ์ GPU๊ฐ ๊ทธ๋ ค๋ธ๋ค. Elevation ๊ฐ์ด ์ฆ๊ฐํ ์๋ก, ๋ฌผ๋ฆฌ์ ๋ ์ด์ด๊ฐ "๋ ๋๋ง ํ๋ฉด(Rendering Surface)"์์ ์๋ก ๋ ์ค๋ฅธ๋ค๊ณ ๊ณต์๋ฌธ์์์ ์ค๋ช ํ๊ณ ์๋ค. ์ฆ Physical model ์ ์ด์ ์ ํ ํ๋ฉด์์ ๋์์์ผ๋ก ์ ์ฒด๊ฐ์ ์ฃผ์๋ ๊ฒ๊ณผ ๋ค๋ฅด๊ฒ Z์ถ์ ๊ธฐ๋ฐ์ผ๋กํ ์ค์ ๋ ์๋ ์์ ฏ์ด ๋ ๋๋ง๋๋ฉฐ ์ด์ ๋ฐ๋ผ ๊ธฐ๋ณธ๊ตฌํ๋ ๊ทธ๋ฆผ์ ํจ๊ณผ๊ฐ ๋ง๋ค์ด์ง๋ ๊ฒ์ด๋ค.
๋ฌผ๋ก ๋ชจ๋ ์์ ฏ์์ PhysicalModel์ ์ธ ์ ์๋ค. Material ์์คํ ์์ AppBar, FloatingActionButton, Card, BottomAppBar ๋ฑ์ ์์ ฏ๋ค์ Elavation ์์ฑ์ ๊ฐ์ง๊ณ ์๋๋ฐ ์ด๋ฌํ ์์ ฏ์์๋ง ์ฌ์ฉํ ์ ์๋ค.
๋ฐ๋ผ์ ์์ ฏ์์ ๊ทธ๋ฆผ์๋ฅผ ํตํด ์ ์ฒด๊ฐ์ ํํํ ๋
1. ๋ณธ์ธ์ ๊ตฌ๊ธ ํ๋ฌํฐ ๊ฐ๋ฐ์๋ณด๋ค ๋ ์์ฐ์ค๋ฝ๊ฒ ์ ์ฒด๊ฐ์ ๊ตฌํํ ์์ ์ด ์๋ค. -> BoxShadow ์์ ฏ ์ฌ์ฉ
2. ์ ์ฒด๊ฐ์ ๋๋ง์ ๋ฐฉ์์ผ๋ก ์ปค์คํฐ๋ง์ด์ง ํ๊ณ ์ถ๋ค -> BoxShadow ์์ ฏ ์ฌ์ฉ
3. ์ฑ๋ฅ์ด ๋๋ฌด ์ค์ํ๋ค. UI๊ฐ ๋๋ฌด ํค๋นํด์ ์ ์ฒด๊ฐ์ ๋ฆฌ์์ค๋ฅผ ํ๋นํ๊ณ ์ถ์ง ์๋ค. -> BoxShadow ์์ ฏ ์ฌ์ฉ
3. ์ด์ธ์ ๊ฒฝ์ฐ๋ PhysicalModel ์ ์ฌ์ฉํด์ ๊ตฌ๊ธ ํ๋ฌํฐํ์ด ๊ตฌํํด์ค ์ ์ฒด๊ฐ์ ํ์ฉํ์! :)
25.01.10 ์์ - PhysicalModel ๋์ Material ์์ ฏ์ ์ฐ์
โ
Material ์์ ฏ์ Flutter์ Material Design ์์คํ
๊ณผ ์๋ฒฝํ๊ฒ ํธํ๋๋ค.
โ
Elevation ๊ฐ๋ง ์ค์ ํ๋ฉด ์๋์ผ๋ก ๊ทธ๋ฆผ์๊ฐ ์ ์ฉ๋๋ฉฐ, ์ถ๊ฐ์ ์ธ shadowColor ์ค์ ์ด ํ์ ์๋ค.
โ
Ink ํจ๊ณผ(InkWell, InkSplash)๋ฅผ ํตํด ํฐ์น ํผ๋๋ฐฑ์ ์์ฐ์ค๋ฝ๊ฒ ์ ์ฉํ ์ ์๋ค.
โ
Material 3 (useMaterial3: true)์์๋ ๋คํฌ ๋ชจ๋์์ Surface Tint๊ฐ ์๋ ์ ์ฉ๋์ด ๋ ์์ฐ์ค๋ฌ์ด ์
์ฒด๊ฐ์ ์ ๊ณตํ๋ค. (Physical model์ ์ด๋ฐ ํจ๊ณผ ์์)
==> PhysicalModel์ Material์ ์ฌ์ฉํ ์ ์๋ ๊ณณ์์ "๋ณด์กฐ์ ์ธ ์ญํ "๋ก ์ฐ์ด๋ ๊ฒ์ด ์ ์ ํ๋ค
==> Material์ด ์ ์ฉ๋ ์ ์๋ ๊ฒฝ์ฐ๋ผ๋ฉด, Material ์์ ฏ์ ์ฌ์ฉํ๋ ๊ฒ์ด ๋ ๊ฐ๊ฒฐํ๊ณ ์์ฐ์ค๋ฌ์ด UI๋ฅผ ๋ง๋ค ์ ์๋ ๋ฐฉ๋ฒ์ด๋ค.
'Daily UI' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
Custom Navigation Bar in Flutter (0) | 2025.02.09 |
---|---|
Bouncing Button in Flutter (0) | 2025.02.01 |
Glassmorphism in Flutter (0) | 2025.01.31 |
Blob Animation in Flutter (0) | 2025.01.30 |
Shadow Box (0) | 2025.01.29 |