This file contains hidden or 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
| #!/bin/bash | |
| # Claude Code status line | |
| # Displays: model · context bar · lines changed · rate limits | |
| # | |
| # Output example: | |
| # sonnet-4.6 │ ctx ████░░░░░░ 42% │ +13 -7 │ 5h:42% (↺ 2h30m) │ 7d:45% | |
| # | |
| # Color thresholds (applies to ctx%, 5h%, 7d%): | |
| # < 60% → green | |
| # 60-84% → yellow |
This file contains hidden or 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
| @Composable | |
| fun ScreenContent(uiState: UiState) { | |
| Contentment { | |
| when (uiState) { | |
| is Loading -> indicator { CircularProgressIndicator() } | |
| is Loaded -> content { LoadedContent(uiState) } | |
| // multiple content's are possible too | |
| is Failed -> content { FailedContent(uiState) } | |
| } | |
| } |
This file contains hidden or 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
| @Composable | |
| private fun FabContainer( | |
| modifier: Modifier = Modifier, | |
| ) { | |
| var containerState by remember { mutableStateOf(ContainerState.Fab) } | |
| val transition = updateTransition(targetState = containerState) | |
| val backgroundColor by transition.animateColor { state -> | |
| when (state) { | |
| ContainerState.Fab -> Colors.fabContainerColor | |
| ContainerState.Fullscreen -> Colors.surface |
This file contains hidden or 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
| @Composable | |
| private fun FabContent( | |
| modifier: Modifier = Modifier, | |
| ) { | |
| var containerState by remember { mutableStateOf(ContainerState.Fab) } | |
| AnimatedContent( | |
| modifier = modifier, | |
| targetState = containerState, | |
| label = "container transform", | |
| ) { state -> |
This file contains hidden or 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
| Box( | |
| modifier = Modifier | |
| .fillMaxSize() | |
| ) { | |
| var containerState by remember { mutableStateOf(ContainerState.Fab) } | |
| HotTakesContent() | |
| when (containerState) { | |
| ContainerState.Fab -> Fab( | |
| modifier = Modifier | |
| .align(Aligment.BottomEnd) |
This file contains hidden or 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
| override fun onBindViewHolder( | |
| holder: FragmentViewHolder, | |
| position: Int, | |
| payloads: MutableList<Any> | |
| ) { | |
| if (payloads.isNotEmpty()) { | |
| val tag = "f" + holder.itemId | |
| val fragment = activity.supportFragmentManager.findFragmentByTag(tag) | |
| // safe check, but fragment should not be null here | |
| if (fragment != null) { |
This file contains hidden or 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
| class PagerDiffUtil(private val oldList: List<PagerItem>, private val newList: List<PagerItem>) : DiffUtil.Callback() { | |
| enum class PayloadKey { | |
| VALUE | |
| } | |
| override fun getOldListSize() = oldList.size | |
| override fun getNewListSize() = newList.size |
This file contains hidden or 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
| class PagerAdapter(private val activity: FragmentActivity) : FragmentStateAdapter(activity) { | |
| private val items: ArrayList<PagerItem> = arrayListOf() | |
| override fun createFragment(position: Int): Fragment = | |
| PagerFragment.newInstance(items[position]) | |
| override fun getItemCount() = items.size | |
| override fun getItemId(position: Int): Long { |
This file contains hidden or 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
| class MainActivity : AppCompatActivity(R.layout.activity_main) { | |
| private lateinit var pagerAdapter: PagerAdapter | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| pagerAdapter = PagerAdapter(this) | |
| viewPager.adapter = pagerAdapter | |
| pagerAdapter.setItems(generatePagerItems()) |
This file contains hidden or 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
| class PagerAdapter(private val activity: FragmentActivity) : FragmentStateAdapter(activity) { | |
| private val items: ArrayList<PagerItem> = arrayListOf() | |
| override fun createFragment(position: Int): Fragment = | |
| PagerFragment.newInstance(items[position]) | |
| override fun getItemCount() = items.size | |
| fun setItems(newItems: List<PagerItem>) { |
NewerOlder