Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] 버튼 디자인 시스템 구축 (모듈화) #169

Merged
merged 18 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from 14 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
1 change: 1 addition & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ android {
dependencies {
implementation(project(":data"))
implementation(project(":domain"))
implementation(project(":jj_design"))
implementation("androidx.appcompat:appcompat:1.5.0")
implementation("com.google.android.material:material:1.4.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
android:theme="@style/Theme.JJBAKSAAOS"
android:usesCleartextTraffic="true"
tools:targetApi="33">
<activity
android:name=".ui.DesignComponentSampleActivity"
android:exported="false" />
<activity
android:name=".ui.follower.FollowerProfileActivity"
android:exported="false" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package com.jjbaksa.jjbaksa.ui

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.android.jj_design.utils.button.Add
import com.android.jj_design.utils.button.Confirm
import com.android.jj_design.utils.button.Delete
import com.android.jj_design.utils.button.Follow
import com.android.jj_design.utils.button.Following
import com.android.jj_design.utils.button.Minus
import com.android.jj_design.utils.button.Position
import com.android.jj_design.utils.button.Requested
import com.jjbaksa.jjbaksa.databinding.ActivityDesignComponentSampleBinding
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch

class DesignComponentSampleActivity : AppCompatActivity() {
private lateinit var binding: ActivityDesignComponentSampleBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityDesignComponentSampleBinding.inflate(layoutInflater)
setContentView(binding.root)

initJjButton()
initJjChipButton()
initJjTrendButton()
initJjMapButton()
}

private fun initJjButton() {
CoroutineScope(Dispatchers.Main).launch {
while (this.isActive) {
binding.jjButton.setErrorBackground()
binding.jjButton.text = "오류 버튼"
delay(2000)
binding.jjButton.isEnabled = true
binding.jjButton.text = "활성화 버튼"
delay(2000)
binding.jjButton.isEnabled = false
binding.jjButton.text = "비활성화 버튼"
delay(2000)
}
}
}

private fun initJjChipButton() {
CoroutineScope(Dispatchers.Main).launch {
while (isActive) {
binding.jjChipButton.setChipItemType(Delete)
delay(2000)
binding.jjChipButton.setChipItemType(Confirm)
delay(2000)
binding.jjChipButton.setChipItemType(Requested)
delay(2000)
binding.jjChipButton.setChipItemType(Follow)
delay(2000)
binding.jjChipButton.setChipItemType(Following)
delay(2000)
}
}
}

private fun initJjTrendButton() {
CoroutineScope(Dispatchers.Main).launch {
while (isActive) {
binding.jjTrendButton.isEnabled = true
binding.jjTrendButton.text = "#성수동 맛집"
delay(2000)
binding.jjTrendButton.isEnabled = false
binding.jjTrendButton.text = "#카페 마이야르"
delay(2000)
}
}
}

private fun initJjMapButton() {
CoroutineScope(Dispatchers.Main).launch {
while (isActive) {
binding.jjMapButton.setJjMapType(Add)
delay(2000)
binding.jjMapButton.setJjMapType(Minus)
delay(2000)
binding.jjMapButton.setJjMapType(Position)
delay(2000)
}
}
}
}
55 changes: 55 additions & 0 deletions app/src/main/res/layout/activity_design_component_sample.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".ui.DesignComponentSampleActivity">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="Button Design Component"
android:textColor="@color/black"
android:background="@color/color_C4C4C4"/>

<com.android.jj_design.button.JjButton
android:id="@+id/jj_button"
android:layout_marginTop="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:jjText="1234"
app:jjTextColor="@color/color_white"/>
<com.android.jj_design.button.JjIconButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
app:jjIconText="리뷰하기"
app:jjIconTextColor="@color/color_666666"
app:jjIconDrawableStart="@drawable/icon_pencil"/>
<com.android.jj_design.button.JjChipButton
android:id="@+id/jj_chip_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
app:jjChipType="Confirm"/>
<com.android.jj_design.button.JjTrendButton
android:id="@+id/jj_trend_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"/>

<com.android.jj_design.button.JjPlusButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"/>

<com.android.jj_design.button.JjMapButton
android:id="@+id/jj_map_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
app:jjMapType="Add"/>
</LinearLayout>
1 change: 1 addition & 0 deletions jj_design/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
126 changes: 126 additions & 0 deletions jj_design/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# JJUPBAK Design System
## Getting Started
- [Button](#button)
- [JjButton](#jjbutton)
- [JjIconButton](#jjiconbutton)
- [JjChipButton](#jjchipbutton)
- [JjPlusButton](#jjplusbutton)
- [JjTrendButton](#jjtrendbutton)
- [JjMapButton](#jjmapbutton)

## Button
! Button Design Component example

![alt text](images/button_test.gif)
### JjButton
<img width = 200px height = 300px src="images/jjbutton.png">

- XML Code
```kotlin
<com.android.jj_design.button.JjButton
android:id="@+id/jj_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:jjText="1234"
app:jjTextColor="@color/color_white"/>
```
- Programmatically Code
- Enabled Button
![alt text](images/jjbutton_enabled.png)
```kotlin
binding.jjButton.isEnabled = true
```
- Disabled Button
![alt text](images/jjbutton_disabled.png)
```kotlin
binding.jjButton.isEnabled = true
```
- Error Button
![alt text](images/jjbutton_error.png)
```kotlin
binding.jjButton.setErrorBackground()
```

### JjIconButton
![alt text](images/jjiconbutton.png)

- XML Code
```kotlin
<com.android.jj_design.button.JjIconButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:jjIconText="리뷰하기"
app:jjIconTextColor="@color/color_666666"
app:jjIconDrawableStart="@drawable/icon_pencil"/>
```

### JjChipButton
![alt text](images/jjchipbutton.png)

- XML Code
```kotlin
<com.android.jj_design.button.JjChipButton
android:id="@+id/jj_chip_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:jjChipType="Confirm"/>
// Delete, Confirm, Requested, Follow, Following
```

- Programmatically Code (use jjChipType)
```kotlin
binding.jjChipButton.setChipItemType(Confirm)
```

### JjPlusButton
![alt text](images/jjplusbutton.png)

- XML Code
```kotlin
<com.android.jj_design.button.JjPlusButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
```

### JjTrendButton

- XML Code
```kotlin
<com.android.jj_design.button.JjTrendButton
android:id="@+id/jj_trend_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
```

- Programmatically Code
- Enabled Trend Button
![alt text](images/jjtrendbutton_enabled.png)
```kotlin
binding.jjTrendButton.isEnabled = true
```

- Disabled Trend Button
![alt text](images/jjtrendbutton_disabled.png)
```kotlin
binding.jjTrendButton.isEnabled = false
```


### JjMapButton
![alt text](images/jjmapbutton.png)

- XML Code
```kotlin
<com.android.jj_design.button.JjMapButton
android:id="@+id/jj_map_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
app:jjMapType="Add"/>
// Add, Minus, Position
```

- Programmatically Code
```kotlin
binding.jjMapButton.setJjMapType(Add) // Minus, Position
```
44 changes: 44 additions & 0 deletions jj_design/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
plugins {
id("com.android.library")
id("org.jetbrains.kotlin.android")
}

android {
namespace = "com.android.jj_design"
compileSdk = 33

defaultConfig {
minSdk = 24

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
}

buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
}

dependencies {

implementation("androidx.core:core-ktx:1.8.0")
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("com.google.android.material:material:1.8.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
}
Empty file added jj_design/consumer-rules.pro
Empty file.
Binary file added jj_design/images/button_test.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added jj_design/images/jjbutton.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added jj_design/images/jjbutton_disabled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added jj_design/images/jjbutton_enabled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added jj_design/images/jjbutton_error.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added jj_design/images/jjchipbutton.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added jj_design/images/jjiconbutton.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added jj_design/images/jjmapbutton.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added jj_design/images/jjplusbutton.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added jj_design/images/jjtrendbutton_disabled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added jj_design/images/jjtrendbutton_enabled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions jj_design/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Loading
Loading