-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #197 from yourssu/develop
[Version Update] version 2.2.3 배포
- Loading branch information
Showing
59 changed files
with
625 additions
and
258 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
157 changes: 32 additions & 125 deletions
157
app/storybook/src/main/java/com/yourssu/storybook/MainActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,142 +1,49 @@ | ||
package com.yourssu.storybook | ||
|
||
import android.annotation.SuppressLint | ||
import android.content.Intent | ||
import android.net.Uri | ||
import android.os.Bundle | ||
import android.view.View | ||
import com.yourssu.design.system.foundation.Icon | ||
import com.yourssu.design.system.foundation.Typo | ||
import com.yourssu.design.system.language.* | ||
import com.yourssu.design.undercarriage.size.dpToIntPx | ||
import com.yourssu.storybook.DetailActivity.Companion.navigateToDetail | ||
import com.yourssu.storybook.atom.* | ||
import com.yourssu.storybook.component.* | ||
import com.yourssu.storybook.foundation.* | ||
import androidx.databinding.DataBindingUtil | ||
import androidx.fragment.app.Fragment | ||
import com.yourssu.design.system.component.BottomBar | ||
import com.yourssu.storybook.databinding.ActivityMainBinding | ||
import com.yourssu.storybook.transform.ActivityAnimType | ||
|
||
class MainActivity : BaseActivity() { | ||
|
||
/** vvvvvv 추가시 여기에만 선언하면 됨 vvvvvv */ | ||
|
||
private val foundationList = listOf<Pair<String, Class<*>>>( | ||
"BasicColor" to BaseColorFragment::class.java, | ||
"SemanticColor" to SemanticColorFragment::class.java, | ||
"Vibration" to VibrationFragment::class.java, | ||
"Icon" to IconFragment::class.java, | ||
"Typography" to TypographyFragment::class.java, | ||
) | ||
private val atomList = listOf<Pair<String, Class<*>>> ( | ||
"Text" to TextFragment::class.java, | ||
"ProfileImageView" to ProfileImageViewFragment::class.java, | ||
"Badge" to BadgeFragment::class.java, | ||
"BoxButton" to BoxButtonFragment::class.java, | ||
"Divider" to DividerFragment::class.java, | ||
"IconView" to IconViewFragment::class.java, | ||
"PlainButton" to PlainButtonFragment::class.java, | ||
"Checkbox" to CheckboxFragment::class.java, | ||
"Toggle" to ToggleFragment::class.java, | ||
"SimpleTextField" to SimpleTextFieldFragment::class.java, | ||
"SuffixTextField" to SuffixTextFieldFragment::class.java, | ||
"PasswordTextField" to PasswordTextFieldFragment::class.java, | ||
"SearchTextField" to SearchTextFieldFragment::class.java, | ||
"ListItem" to ListItemFragment::class.java, | ||
"ListToggleItem" to ListToggleItemFragment::class.java, | ||
) | ||
private val componentList = listOf<Pair<String, Class<*>>>( | ||
"Toast" to ToastFragment::class.java, | ||
"TopBar" to TopBarFragment::class.java, | ||
"SingleTitleTopBar" to SingleTitleTopBarFragment::class.java, | ||
"DoubleTitleTopBar" to DoubleTitleTopBarFragment::class.java, | ||
"SearchTopBar" to SearchTopBarFragment::class.java, | ||
"BottomBar" to BottomBarFragment::class.java, | ||
"TabBar" to TabBarFragment::class.java, | ||
"Tooltip" to TooltipFragment::class.java, | ||
"List" to ListFragment::class.java, | ||
) | ||
|
||
/* 위의 리스트의 합 */ | ||
private val totalItemList = listOf<Pair<String, List<Pair<String, Class<*>>>>>( | ||
"1. Foundation" to foundationList, | ||
"2. Atom" to atomList, | ||
"3. Component" to componentList | ||
) | ||
|
||
/** ^^^^^^ 추가시 여기에만 선언하면 됨 ^^^^^^^ */ | ||
|
||
lateinit var binding: ActivityMainBinding | ||
override var animationType: ActivityAnimType = ActivityAnimType.STAY | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
binding = DataBindingUtil.setContentView(this, R.layout.activity_main) | ||
binding.activity = this | ||
|
||
initView() | ||
supportFragmentManager.beginTransaction() | ||
.replace(binding.fragmentFrame.id, TabType.XML.fragment) | ||
.commit() | ||
} | ||
|
||
@SuppressLint("SetTextI18n") | ||
private fun initView() { | ||
setContentView { | ||
verticalLayout { | ||
singleTitleTopBar { | ||
title = "StoryBook" | ||
thirdIcon = Icon.ic_warningcircle_line | ||
thirdButtonListener = View.OnClickListener { | ||
bottomSheet { | ||
list { | ||
subHeader = "Setting" | ||
|
||
listItem { | ||
text = "Current Version : ${BuildConfig.VERSION_NAME}" | ||
} | ||
listItem { | ||
text = "Privacy policy" | ||
rightIcon = Icon.ic_arrow_right_line | ||
setOnClickListener { | ||
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(context.getString( | ||
R.string.link_privacy_policy))) | ||
startActivity(intent) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
scrollView { | ||
verticalLayout { | ||
totalItemList.forEach { | ||
text { | ||
text = it.first | ||
typo = Typo.SubTitle3 | ||
|
||
backgroundColor(R.color.dimNormal) | ||
setLayout( | ||
width = MATCH_PARENT, | ||
leftPaddingPx = context.dpToIntPx(16f), | ||
topPaddingPx = context.dpToIntPx(2f), | ||
bottomPaddingPx = context.dpToIntPx(2f) | ||
) | ||
} | ||
it.second.forEach { foundation -> | ||
text { | ||
text = foundation.first | ||
typo = Typo.Body1 | ||
setOnClickListener { | ||
navigateToDetail(foundation.first, foundation.second) | ||
} | ||
setLayout( | ||
width = MATCH_PARENT, | ||
leftPaddingPx = context.dpToIntPx(16f), | ||
topPaddingPx = context.dpToIntPx(16f), | ||
bottomPaddingPx = context.dpToIntPx(16f) | ||
) | ||
} | ||
divider { | ||
setLayout(leftMarginPx = context.dpToIntPx(16f)) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
val tabClickListener = object : BottomBar.TabClickListener { | ||
override fun tabClicked(primaryName: String) { | ||
binding.bottomNav.setSelectedTab(primaryName) | ||
supportFragmentManager.beginTransaction() | ||
.replace(binding.fragmentFrame.id, TabType.from(primaryName)?.fragment ?: return) | ||
.commit() | ||
} | ||
override fun tabChanged(primaryName: String) {} | ||
override fun tabLongClicked(primaryName: String) {} | ||
} | ||
|
||
val tabList = listOf( | ||
BottomBar.BottomTabInfo(TabType.XML.name, R.drawable.ic_xml, R.drawable.ic_xml), | ||
BottomBar.BottomTabInfo(TabType.COMPOSE.name, R.drawable.ic_kotlin, R.drawable.ic_kotlin), | ||
) | ||
} | ||
|
||
enum class TabType(val fragment: Fragment) { | ||
XML(MainFragment.newInstance()), | ||
COMPOSE(MainComposeFragment.newInstance()); | ||
|
||
companion object { | ||
fun from(name: String): TabType? = values().find { it.name == name } | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
app/storybook/src/main/java/com/yourssu/storybook/MainComposeFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.yourssu.storybook | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.ui.platform.ComposeView | ||
import androidx.compose.ui.platform.ViewCompositionStrategy | ||
import com.yourssu.design.system.compose.YdsTheme | ||
import com.yourssu.design.system.compose.atom.ListItem | ||
|
||
class MainComposeFragment : BaseFragment() { | ||
companion object { | ||
@JvmStatic | ||
fun newInstance() = MainComposeFragment() | ||
} | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View = ComposeView(requireContext()).apply { | ||
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed) | ||
setContent { | ||
YdsTheme { | ||
Column { | ||
ListItem(text = "Hello Jetpack Compose!", onClick = { }) | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.