├── .gitignore
├── .idea
├── .gitignore
├── .name
├── compiler.xml
├── gradle.xml
├── inspectionProfiles
│ └── Project_Default.xml
├── misc.xml
└── vcs.xml
├── README.md
├── build.gradle
├── config.gradle
├── eight
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── zj
│ │ └── eight
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── zj
│ │ │ └── eight
│ │ │ ├── Flow.kt
│ │ │ ├── MainActivity.kt
│ │ │ ├── NavigationTest.kt
│ │ │ ├── One.kt
│ │ │ ├── OneActivity.kt
│ │ │ ├── OneViewModel.kt
│ │ │ ├── PagingTest.kt
│ │ │ └── ui
│ │ │ └── theme
│ │ │ ├── Color.kt
│ │ │ ├── Shape.kt
│ │ │ ├── Theme.kt
│ │ │ └── Type.kt
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ └── ic_launcher_background.xml
│ │ ├── layout
│ │ └── activity_one.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── values-night
│ │ └── themes.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── themes.xml
│ └── test
│ └── java
│ └── com
│ └── zj
│ └── eight
│ └── ExampleUnitTest.kt
├── five
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── zj
│ │ └── five
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── zj
│ │ │ └── five
│ │ │ ├── BottomNavigation.kt
│ │ │ ├── ComplexStickyHeaderTest.kt
│ │ │ ├── LazyColumnTest.kt
│ │ │ ├── LazyRowTest.kt
│ │ │ ├── LazyVerticalGridTest.kt
│ │ │ ├── MainActivity.kt
│ │ │ ├── ProgressTest.kt
│ │ │ ├── StickyHeaderTest.kt
│ │ │ └── ui
│ │ │ └── theme
│ │ │ ├── Color.kt
│ │ │ ├── Shape.kt
│ │ │ ├── Theme.kt
│ │ │ └── Type.kt
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable-xxxhdpi
│ │ ├── ic_nav_discover_normal.png
│ │ ├── ic_nav_my_normal.png
│ │ ├── ic_nav_news_normal.png
│ │ └── ic_nav_tweet_normal.png
│ │ ├── drawable
│ │ └── ic_launcher_background.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── values-night
│ │ └── themes.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── themes.xml
│ └── test
│ └── java
│ └── com
│ └── zj
│ └── five
│ └── ExampleUnitTest.kt
├── four
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── zj
│ │ └── four
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── zj
│ │ │ └── four
│ │ │ ├── ButtonTest.kt
│ │ │ ├── ImageTest.kt
│ │ │ ├── MainActivity.kt
│ │ │ ├── ProgressTest.kt
│ │ │ ├── TextFieldTest.kt
│ │ │ ├── TextTest.kt
│ │ │ ├── Toast.kt
│ │ │ └── ui
│ │ │ └── theme
│ │ │ ├── Color.kt
│ │ │ ├── Shape.kt
│ │ │ ├── Theme.kt
│ │ │ └── Type.kt
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ └── ic_launcher_background.xml
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── values-night
│ │ └── themes.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── themes.xml
│ └── test
│ └── java
│ └── com
│ └── zj
│ └── four
│ └── ExampleUnitTest.kt
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── nine
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── zj
│ │ └── nine
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── zj
│ │ │ └── nine
│ │ │ ├── AndroidViewBindingPage.kt
│ │ │ ├── AndroidViewPage.kt
│ │ │ ├── AndroidWebViewPage.kt
│ │ │ ├── ComposeFragment.kt
│ │ │ ├── MainActivity.kt
│ │ │ ├── ScreenAdapter.kt
│ │ │ ├── ShareWidgetActivity.kt
│ │ │ ├── WebViewPage.kt
│ │ │ └── ui
│ │ │ └── theme
│ │ │ ├── Color.kt
│ │ │ ├── Shape.kt
│ │ │ ├── Theme.kt
│ │ │ └── Type.kt
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ └── ic_launcher_background.xml
│ │ ├── layout
│ │ ├── activity_main.xml
│ │ ├── activity_share_widget.xml
│ │ ├── compose_login.xml
│ │ └── fragment_compose.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── values-night
│ │ └── themes.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── ids.xml
│ │ ├── strings.xml
│ │ └── themes.xml
│ └── test
│ └── java
│ └── com
│ └── zj
│ └── nine
│ └── ExampleUnitTest.kt
├── one
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── zj
│ │ └── one
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── zj
│ │ │ └── one
│ │ │ ├── DefaultParam.kt
│ │ │ ├── HigherFunctions.kt
│ │ │ ├── MainActivity.kt
│ │ │ └── ui
│ │ │ └── theme
│ │ │ ├── Color.kt
│ │ │ ├── Shape.kt
│ │ │ ├── Theme.kt
│ │ │ └── Type.kt
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ └── ic_launcher_background.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── values-night
│ │ └── themes.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── themes.xml
│ └── test
│ └── java
│ └── com
│ └── zj
│ └── one
│ └── ExampleUnitTest.kt
├── settings.gradle
├── seven
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── zj
│ │ └── seven
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── zj
│ │ │ └── seven
│ │ │ ├── AnimatableTest.kt
│ │ │ ├── AnimateAsState.kt
│ │ │ ├── AnimationSpec.kt
│ │ │ ├── AnimationVectorTest.kt
│ │ │ ├── BottomNavigation.kt
│ │ │ ├── EasyAnimation.kt
│ │ │ ├── GesturesTest.kt
│ │ │ ├── InfiniteTransitionTest.kt
│ │ │ ├── MainActivity.kt
│ │ │ ├── ScrollTest.kt
│ │ │ ├── TransitionTest.kt
│ │ │ ├── content
│ │ │ └── AnimatedContent.kt
│ │ │ ├── dynamic
│ │ │ ├── BatteryReceiver.kt
│ │ │ ├── BatteryScreen.kt
│ │ │ └── CanvasDropWater.kt
│ │ │ ├── spec
│ │ │ └── Spec.kt
│ │ │ ├── ui
│ │ │ └── theme
│ │ │ │ ├── Color.kt
│ │ │ │ ├── Shape.kt
│ │ │ │ ├── Theme.kt
│ │ │ │ └── Type.kt
│ │ │ └── visible
│ │ │ └── VisibleAnimation.kt
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable-xxhdpi
│ │ └── ic_head.jpeg
│ │ ├── drawable-xxxhdpi
│ │ ├── ic_nav_discover_normal.png
│ │ ├── ic_nav_my_normal.png
│ │ ├── ic_nav_news_normal.png
│ │ └── ic_nav_tweet_normal.png
│ │ ├── drawable
│ │ └── ic_launcher_background.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── values-night
│ │ └── themes.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── themes.xml
│ └── test
│ └── java
│ └── com
│ └── zj
│ └── seven
│ └── ExampleUnitTest.kt
├── six
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── zj
│ │ └── six
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── zj
│ │ │ └── six
│ │ │ ├── CustomView.kt
│ │ │ ├── CustomView1.kt
│ │ │ ├── DrawArc.kt
│ │ │ ├── DrawBlendMode.kt
│ │ │ ├── DrawCircle.kt
│ │ │ ├── DrawImage.kt
│ │ │ ├── DrawLine.kt
│ │ │ ├── DrawOval.kt
│ │ │ ├── DrawPath.kt
│ │ │ ├── DrawPoint.kt
│ │ │ ├── DrawRect.kt
│ │ │ ├── DrawRoundRect.kt
│ │ │ ├── MainActivity.kt
│ │ │ └── ui
│ │ │ └── theme
│ │ │ ├── Color.kt
│ │ │ ├── Shape.kt
│ │ │ ├── Theme.kt
│ │ │ └── Type.kt
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable-xxhdpi
│ │ └── head.jpg
│ │ ├── drawable
│ │ └── ic_launcher_background.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── values-night
│ │ └── themes.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── themes.xml
│ └── test
│ └── java
│ └── com
│ └── zj
│ └── six
│ └── ExampleUnitTest.kt
├── ten
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── zj
│ │ └── play
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── zj
│ │ │ └── play
│ │ │ ├── App.kt
│ │ │ ├── MainActivity.kt
│ │ │ ├── Play.kt
│ │ │ ├── logic
│ │ │ ├── base
│ │ │ │ ├── paging
│ │ │ │ │ ├── BasePagingSource.kt
│ │ │ │ │ ├── HomePagingSource.kt
│ │ │ │ │ ├── OfficialPagingSource.kt
│ │ │ │ │ └── ProjectPagingSource.kt
│ │ │ │ ├── repository
│ │ │ │ │ ├── BaseArticlePagingRepository.kt
│ │ │ │ │ └── BaseArticleRepository.kt
│ │ │ │ └── viewmodel
│ │ │ │ │ ├── BaseAndroidViewModel.kt
│ │ │ │ │ └── BaseArticleViewModel.kt
│ │ │ ├── model
│ │ │ │ ├── ArticleListModel.kt
│ │ │ │ ├── ArticleModel.kt
│ │ │ │ ├── BannerBean.kt
│ │ │ │ ├── BaseModel.kt
│ │ │ │ ├── ClassifyModel.kt
│ │ │ │ ├── LoginModel.kt
│ │ │ │ ├── PlayState.kt
│ │ │ │ └── Query.kt
│ │ │ ├── network
│ │ │ │ ├── PlayAndroidNetwork.kt
│ │ │ │ ├── ServiceCreator.kt
│ │ │ │ └── service
│ │ │ │ │ ├── HomePageService.kt
│ │ │ │ │ ├── LoginService.kt
│ │ │ │ │ ├── OfficialService.kt
│ │ │ │ │ └── ProjectService.kt
│ │ │ └── utils
│ │ │ │ ├── BarUtils.kt
│ │ │ │ ├── DataStoreUtils.kt
│ │ │ │ ├── HtmlUtils.kt
│ │ │ │ ├── Lerp.kt
│ │ │ │ ├── NetworkUtils.kt
│ │ │ │ └── Toast.kt
│ │ │ └── ui
│ │ │ ├── main
│ │ │ ├── HomeViewModel.kt
│ │ │ ├── MainPage.kt
│ │ │ └── NavGraph.kt
│ │ │ ├── page
│ │ │ ├── article
│ │ │ │ ├── ArticlePage.kt
│ │ │ │ └── list
│ │ │ │ │ ├── ArticleListItem.kt
│ │ │ │ │ └── ArticleListPaging.kt
│ │ │ ├── home
│ │ │ │ ├── HomePage.kt
│ │ │ │ ├── HomePageViewModel.kt
│ │ │ │ └── HomeRepository.kt
│ │ │ ├── login
│ │ │ │ ├── AccountRepository.kt
│ │ │ │ ├── LoginPage.kt
│ │ │ │ └── LoginViewModel.kt
│ │ │ ├── mine
│ │ │ │ └── ProfilePage.kt
│ │ │ ├── official
│ │ │ │ ├── OfficialRepository.kt
│ │ │ │ └── OfficialViewModel.kt
│ │ │ └── project
│ │ │ │ ├── ProjectPage.kt
│ │ │ │ ├── ProjectRepository.kt
│ │ │ │ └── ProjectViewModel.kt
│ │ │ ├── theme
│ │ │ ├── Color.kt
│ │ │ ├── Shape.kt
│ │ │ ├── Theme.kt
│ │ │ └── Type.kt
│ │ │ └── view
│ │ │ ├── ArticleTabRow.kt
│ │ │ ├── PlayAppBar.kt
│ │ │ ├── WebView.kt
│ │ │ ├── edit
│ │ │ ├── EmailState.kt
│ │ │ ├── PasswordState.kt
│ │ │ ├── SignInSignUp.kt
│ │ │ └── TextFieldState.kt
│ │ │ └── lce
│ │ │ ├── ErrorContent.kt
│ │ │ ├── LcePage.kt
│ │ │ ├── LoadingContent.kt
│ │ │ └── NoContent.kt
│ └── res
│ │ ├── anim
│ │ ├── activity_push_in.xml
│ │ ├── activity_push_out.xml
│ │ ├── center_zoom_in.xml
│ │ └── center_zoom_out.xml
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable-xxhdpi
│ │ ├── img_default.png
│ │ └── img_head.jpeg
│ │ ├── drawable-xxxhdpi
│ │ ├── ic_nav_discover_actived.png
│ │ ├── ic_nav_discover_normal.png
│ │ ├── ic_nav_my_normal.png
│ │ ├── ic_nav_my_pressed.png
│ │ ├── ic_nav_news_actived.png
│ │ ├── ic_nav_news_normal.png
│ │ ├── ic_nav_tweet_actived.png
│ │ └── ic_nav_tweet_normal.png
│ │ ├── drawable
│ │ ├── bad_loading.xml
│ │ ├── bad_network_image.xml
│ │ ├── color_progressbar.xml
│ │ ├── ic_baseline_bookmark_24.xml
│ │ ├── ic_baseline_bookmark_border_24.xml
│ │ ├── ic_baseline_visibility_24.xml
│ │ ├── ic_baseline_visibility_off_24.xml
│ │ ├── ic_launcher_background.xml
│ │ ├── ic_launcher_foreground.xml
│ │ ├── ic_text_settings.xml
│ │ ├── img_to_top_nomal.xml
│ │ ├── load_four.xml
│ │ ├── load_three.xml
│ │ ├── loading_animation.xml
│ │ └── no_content_image.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── values-night
│ │ ├── colors.xml
│ │ └── themes.xml
│ │ ├── values-zh-rCN
│ │ └── strings.xml
│ │ ├── values-zh-rTW
│ │ └── strings.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── ic_launcher_background.xml
│ │ ├── strings.xml
│ │ └── themes.xml
│ └── test
│ └── java
│ └── com
│ └── zj
│ └── play
│ └── ExampleUnitTest.kt
├── three
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── zj
│ │ └── three
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── zj
│ │ │ └── three
│ │ │ ├── CustomLayout.kt
│ │ │ ├── MainActivity.kt
│ │ │ ├── one
│ │ │ ├── Box.kt
│ │ │ ├── Column.kt
│ │ │ ├── ConstraintLayoutTest.kt
│ │ │ ├── ModifierText.kt
│ │ │ ├── Row.kt
│ │ │ └── ScaffoldTest.kt
│ │ │ └── ui
│ │ │ └── theme
│ │ │ ├── Color.kt
│ │ │ ├── Shape.kt
│ │ │ ├── Theme.kt
│ │ │ └── Type.kt
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ └── ic_launcher_background.xml
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── values-night
│ │ └── themes.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── themes.xml
│ └── test
│ └── java
│ └── com
│ └── zj
│ └── three
│ └── ExampleUnitTest.kt
└── two
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
├── androidTest
└── java
│ └── com
│ └── zj
│ └── two
│ └── ExampleInstrumentedTest.kt
├── main
├── AndroidManifest.xml
├── java
│ └── com
│ │ └── zj
│ │ └── two
│ │ ├── Effect.kt
│ │ ├── MainActivity.kt
│ │ ├── Restructuring.kt
│ │ └── ui
│ │ └── theme
│ │ ├── Color.kt
│ │ ├── Shape.kt
│ │ ├── Theme.kt
│ │ └── Type.kt
└── res
│ ├── drawable-v24
│ └── ic_launcher_foreground.xml
│ ├── drawable
│ └── ic_launcher_background.xml
│ ├── mipmap-anydpi-v26
│ ├── ic_launcher.xml
│ └── ic_launcher_round.xml
│ ├── mipmap-hdpi
│ ├── ic_launcher.webp
│ └── ic_launcher_round.webp
│ ├── mipmap-mdpi
│ ├── ic_launcher.webp
│ └── ic_launcher_round.webp
│ ├── mipmap-xhdpi
│ ├── ic_launcher.webp
│ └── ic_launcher_round.webp
│ ├── mipmap-xxhdpi
│ ├── ic_launcher.webp
│ └── ic_launcher_round.webp
│ ├── mipmap-xxxhdpi
│ ├── ic_launcher.webp
│ └── ic_launcher_round.webp
│ ├── values-night
│ └── themes.xml
│ └── values
│ ├── colors.xml
│ ├── strings.xml
│ └── themes.xml
└── test
└── java
└── com
└── zj
└── two
└── ExampleUnitTest.kt
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 | .cxx
15 | local.properties
16 |
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | Compose
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
27 |
28 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ComposeBookSource
2 |
3 | 《Jetpack Compose:Android全新UI编程》全书源代码
4 | 本项目会跟随 `Compose` 官方版本进行升级,如有需要可以 fork。
5 | 如果大家想系统地学习 `Compose` 的话,可以购买我的新书[《Jetpack Compose:Android全新UI编程》](https://juejin.cn/post/7027020266312056840)进行阅读,里面有完整的 Compose 框架供大家学习。
6 |
7 |
8 |

9 |
10 |
11 | [京东购买地址](https://item.jd.com/10039809078875.html)
12 |
13 | [当当购买地址](http://product.dangdang.com/593507948.html)
14 |
15 | ## 实战项目
16 | 本书第十章中的实战项目在这里只是简单的基础版本,如果想继续学习完整版本的实战项目的话可以访问以下链接:
17 |
18 | - 玩安卓(compose或main分支):[https://github.com/zhujiang521/PlayAndroid](https://github.com/zhujiang521/PlayAndroid)
19 | - 玩天气:[https://github.com/zhujiang521/PlayWeather](https://github.com/zhujiang521/PlayWeather)
20 |
21 | ## 微信公众号
22 |
23 | 大家可以直接搜索:江江安卓 进行关注。
24 |
25 | ## 我的博客
26 |
27 | 大家也可以关注我的博客,定期会有文章进行更新。
28 |
29 | - [CSDN](https://zhujiang.blog.csdn.net/)
30 | - [掘金](https://juejin.cn/user/3913917127985240/posts)
31 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 | apply from: "config.gradle"
3 |
4 | buildscript {
5 | ext {
6 | compose_version = '1.3.0-beta02'
7 | compose_compiler_version = '1.3.1'
8 | kotlin_version = '1.7.10'
9 | }
10 | repositories {
11 | google()
12 | mavenCentral()
13 | }
14 | dependencies {
15 | classpath "com.android.tools.build:gradle:7.2.2"
16 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
17 |
18 | // NOTE: Do not place your application dependencies here; they belong
19 | // in the individual module build.gradle files
20 | }
21 | }
22 |
23 | task clean(type: Delete) {
24 | delete rootProject.buildDir
25 | }
--------------------------------------------------------------------------------
/config.gradle:
--------------------------------------------------------------------------------
1 | ext {
2 | cfgs = [
3 | compileSdkVersion: 33,
4 | minSdkVersion : 24,
5 | targetSdkVersion : 33,
6 | versionCode : 1,
7 | versionName : "1.0",
8 | ]
9 |
10 | des = [
11 | kotlinVersion : "org.jetbrains.kotlin:kotlin-stdlib:1.7.0",
12 | coreKtx : 'androidx.core:core-ktx:1.8.0',
13 | appcompat : 'androidx.appcompat:appcompat:1.5.1',
14 | material : 'com.google.android.material:material:1.6.1',
15 | lifecycleRuntime: 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1',
16 | activityCompose : 'androidx.activity:activity-compose:1.5.1',
17 | junit : 'junit:junit:4.13.2',
18 | extJunit : 'androidx.test.ext:junit:1.1.3',
19 | espressoCore : 'androidx.test.espresso:espresso-core:3.4.0',
20 | ]
21 |
22 | }
--------------------------------------------------------------------------------
/eight/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/eight/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/eight/src/androidTest/java/com/zj/eight/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.zj.eight
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("com.zj.eight", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/eight/src/main/java/com/zj/eight/Flow.kt:
--------------------------------------------------------------------------------
1 | package com.zj.eight
2 |
3 | import androidx.compose.foundation.layout.width
4 | import androidx.compose.material.Text
5 | import androidx.compose.runtime.Composable
6 | import androidx.compose.runtime.collectAsState
7 | import androidx.compose.ui.Modifier
8 | import androidx.compose.ui.text.style.TextAlign
9 | import androidx.compose.ui.tooling.preview.Preview
10 | import androidx.compose.ui.unit.dp
11 | import androidx.compose.ui.unit.sp
12 | import kotlinx.coroutines.delay
13 | import kotlinx.coroutines.flow.Flow
14 | import kotlinx.coroutines.flow.flow
15 |
16 | @Composable
17 | fun FlowTest() {
18 |
19 | fun flowTest(): Flow = flow {
20 | for (i in 1..10) {
21 | delay(1000)
22 | emit(i)
23 | }
24 | }
25 | // val ss = Completable()
26 | //.subscribeAsState()
27 |
28 | val flowCount = flowTest().collectAsState(0)
29 | Text(
30 | flowCount.value.toString(),
31 | modifier = Modifier.width(100.dp),
32 | fontSize = 30.sp,
33 | textAlign = TextAlign.Center
34 | )
35 | }
36 |
37 |
38 | @Preview(showBackground = true)
39 | @Composable
40 | fun FlowTestPreview() {
41 | FlowTest()
42 | }
--------------------------------------------------------------------------------
/eight/src/main/java/com/zj/eight/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.zj.eight
2 |
3 | import android.os.Bundle
4 | import androidx.activity.ComponentActivity
5 | import androidx.activity.compose.setContent
6 | import androidx.compose.material.MaterialTheme
7 | import androidx.compose.material.Surface
8 | import androidx.compose.material.Text
9 | import androidx.compose.runtime.Composable
10 | import androidx.compose.ui.tooling.preview.Preview
11 | import com.zj.eight.ui.theme.EightTheme
12 |
13 | class MainActivity : ComponentActivity() {
14 | override fun onCreate(savedInstanceState: Bundle?) {
15 | super.onCreate(savedInstanceState)
16 | setContent {
17 | EightTheme {
18 | // A surface container using the 'background' color from the theme
19 | // Surface(color = MaterialTheme.colors.background) {
20 | // Greeting("Android")
21 | // One()
22 | // FlowTest()
23 | NavigationTest()
24 | // }
25 | }
26 | }
27 | }
28 | }
29 |
30 | @Composable
31 | fun Greeting(name: String) {
32 | Text(text = "Hello $name!")
33 | }
34 |
35 | @Preview(showBackground = true)
36 | @Composable
37 | fun DefaultPreview() {
38 | EightTheme {
39 | Greeting("Android")
40 | }
41 | }
--------------------------------------------------------------------------------
/eight/src/main/java/com/zj/eight/OneActivity.kt:
--------------------------------------------------------------------------------
1 | package com.zj.eight
2 |
3 | import androidx.appcompat.app.AppCompatActivity
4 | import android.os.Bundle
5 | import androidx.activity.viewModels
6 | import com.zj.eight.databinding.ActivityOneBinding
7 |
8 | class OneActivity : AppCompatActivity() {
9 |
10 | private lateinit var binding: ActivityOneBinding
11 | private val viewModel by viewModels()
12 |
13 | override fun onCreate(savedInstanceState: Bundle?) {
14 | super.onCreate(savedInstanceState)
15 | binding = ActivityOneBinding.inflate(layoutInflater)
16 | setContentView(binding.root)
17 | initView()
18 | }
19 |
20 | private fun initView() {
21 | viewModel.count.observe(this) {
22 | binding.oneTvCount.text = it.toString()
23 | }
24 | binding.oneBtnAdd.setOnClickListener {
25 | val count = viewModel.count.value ?: 0
26 | viewModel.onCountChanged(count + 2)
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/eight/src/main/java/com/zj/eight/OneViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.zj.eight
2 |
3 | import androidx.hilt.lifecycle.ViewModelInject
4 | import androidx.lifecycle.LiveData
5 | import androidx.lifecycle.MutableLiveData
6 | import androidx.lifecycle.ViewModel
7 | import androidx.lifecycle.ViewModelProvider
8 | import dagger.hilt.android.HiltAndroidApp
9 | import javax.inject.Inject
10 |
11 | class OneViewModel(defaultCount: Int) : ViewModel() {
12 |
13 | private val _count = MutableLiveData(defaultCount)
14 |
15 | val count: LiveData
16 | get() = _count
17 |
18 | fun onCountChanged(count: Int) {
19 | _count.postValue(count)
20 | }
21 |
22 | }
23 |
24 | @HiltAndroidApp
25 | class TwoViewModel @Inject constructor(defaultCount: Int) : ViewModel() {
26 |
27 | private val _count = MutableLiveData(defaultCount)
28 |
29 | val count: LiveData
30 | get() = _count
31 |
32 | fun onCountChanged(count: Int) {
33 | _count.postValue(count)
34 | }
35 |
36 | }
37 |
38 | class OneViewModelFactory(private val defaultCount: Int) : ViewModelProvider.Factory {
39 |
40 | override fun create(modelClass: Class): T {
41 | return OneViewModel(defaultCount) as T
42 | }
43 |
44 | }
--------------------------------------------------------------------------------
/eight/src/main/java/com/zj/eight/ui/theme/Color.kt:
--------------------------------------------------------------------------------
1 | package com.zj.eight.ui.theme
2 |
3 | import androidx.compose.ui.graphics.Color
4 |
5 | val Purple200 = Color(0xFFBB86FC)
6 | val Purple500 = Color(0xFF6200EE)
7 | val Purple700 = Color(0xFF3700B3)
8 | val Teal200 = Color(0xFF03DAC5)
--------------------------------------------------------------------------------
/eight/src/main/java/com/zj/eight/ui/theme/Shape.kt:
--------------------------------------------------------------------------------
1 | package com.zj.eight.ui.theme
2 |
3 | import androidx.compose.foundation.shape.RoundedCornerShape
4 | import androidx.compose.material.Shapes
5 | import androidx.compose.ui.unit.dp
6 |
7 | val Shapes = Shapes(
8 | small = RoundedCornerShape(4.dp),
9 | medium = RoundedCornerShape(4.dp),
10 | large = RoundedCornerShape(0.dp)
11 | )
--------------------------------------------------------------------------------
/eight/src/main/java/com/zj/eight/ui/theme/Theme.kt:
--------------------------------------------------------------------------------
1 | package com.zj.eight.ui.theme
2 |
3 | import androidx.compose.foundation.isSystemInDarkTheme
4 | import androidx.compose.material.MaterialTheme
5 | import androidx.compose.material.darkColors
6 | import androidx.compose.material.lightColors
7 | import androidx.compose.runtime.Composable
8 |
9 | private val DarkColorPalette = darkColors(
10 | primary = Purple200,
11 | primaryVariant = Purple700,
12 | secondary = Teal200
13 | )
14 |
15 | private val LightColorPalette = lightColors(
16 | primary = Purple500,
17 | primaryVariant = Purple700,
18 | secondary = Teal200
19 |
20 | /* Other default colors to override
21 | background = Color.White,
22 | surface = Color.White,
23 | onPrimary = Color.White,
24 | onSecondary = Color.Black,
25 | onBackground = Color.Black,
26 | onSurface = Color.Black,
27 | */
28 | )
29 |
30 | @Composable
31 | fun EightTheme(darkTheme: Boolean = isSystemInDarkTheme(), content: @Composable() () -> Unit) {
32 | val colors = if (darkTheme) {
33 | DarkColorPalette
34 | } else {
35 | LightColorPalette
36 | }
37 |
38 | MaterialTheme(
39 | colors = colors,
40 | typography = Typography,
41 | shapes = Shapes,
42 | content = content
43 | )
44 | }
--------------------------------------------------------------------------------
/eight/src/main/java/com/zj/eight/ui/theme/Type.kt:
--------------------------------------------------------------------------------
1 | package com.zj.eight.ui.theme
2 |
3 | import androidx.compose.material.Typography
4 | import androidx.compose.ui.text.TextStyle
5 | import androidx.compose.ui.text.font.FontFamily
6 | import androidx.compose.ui.text.font.FontWeight
7 | import androidx.compose.ui.unit.sp
8 |
9 | // Set of Material typography styles to start with
10 | val Typography = Typography(
11 | body1 = TextStyle(
12 | fontFamily = FontFamily.Default,
13 | fontWeight = FontWeight.Normal,
14 | fontSize = 16.sp
15 | )
16 | /* Other default text styles to override
17 | button = TextStyle(
18 | fontFamily = FontFamily.Default,
19 | fontWeight = FontWeight.W500,
20 | fontSize = 14.sp
21 | ),
22 | caption = TextStyle(
23 | fontFamily = FontFamily.Default,
24 | fontWeight = FontWeight.Normal,
25 | fontSize = 12.sp
26 | )
27 | */
28 | )
--------------------------------------------------------------------------------
/eight/src/main/res/layout/activity_one.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
17 |
18 |
24 |
25 |
--------------------------------------------------------------------------------
/eight/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/eight/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/eight/src/main/res/mipmap-hdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/eight/src/main/res/mipmap-hdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/eight/src/main/res/mipmap-hdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/eight/src/main/res/mipmap-hdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/eight/src/main/res/mipmap-mdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/eight/src/main/res/mipmap-mdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/eight/src/main/res/mipmap-mdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/eight/src/main/res/mipmap-mdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/eight/src/main/res/mipmap-xhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/eight/src/main/res/mipmap-xhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/eight/src/main/res/mipmap-xhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/eight/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/eight/src/main/res/mipmap-xxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/eight/src/main/res/mipmap-xxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/eight/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/eight/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/eight/src/main/res/mipmap-xxxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/eight/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/eight/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/eight/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/eight/src/main/res/values-night/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/eight/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFBB86FC
4 | #FF6200EE
5 | #FF3700B3
6 | #FF03DAC5
7 | #FF018786
8 | #FF000000
9 | #FFFFFFFF
10 |
--------------------------------------------------------------------------------
/eight/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Eight
3 |
--------------------------------------------------------------------------------
/eight/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
17 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/eight/src/test/java/com/zj/eight/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.zj.eight
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------
/five/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/five/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/five/src/androidTest/java/com/zj/five/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.zj.five
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("com.zj.five", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/five/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
14 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/five/src/main/java/com/zj/five/LazyRowTest.kt:
--------------------------------------------------------------------------------
1 | package com.zj.five
2 |
3 | import androidx.compose.foundation.layout.width
4 | import androidx.compose.foundation.lazy.LazyColumn
5 | import androidx.compose.foundation.lazy.LazyRow
6 | import androidx.compose.foundation.lazy.items
7 | import androidx.compose.material.Text
8 | import androidx.compose.runtime.Composable
9 | import androidx.compose.ui.Modifier
10 | import androidx.compose.ui.tooling.preview.Preview
11 | import androidx.compose.ui.unit.dp
12 |
13 | @Composable
14 | fun LazyRowTest() {
15 | // val dataList = arrayListOf()
16 | // for (index in 0..10) {
17 | // dataList.add(index)
18 | // }
19 | // LazyRow {
20 | // items(dataList) { data ->
21 | // Text("$data", modifier = Modifier.width(20.dp))
22 | // }
23 | // }
24 |
25 |
26 | val dataList = arrayListOf()
27 | for (index in 0..100) {
28 | dataList.add(index)
29 | }
30 | LazyRow {
31 | items(
32 | items = dataList,
33 | key = { index ->
34 | index
35 | }
36 | ) { data ->
37 | Text("Zhujiang:$data")
38 | }
39 | }
40 |
41 | }
42 |
43 | @Preview(showBackground = true, widthDp = 200, heightDp = 50)
44 | @Composable
45 | fun LazyRowTestPreview() {
46 | LazyRowTest()
47 | }
--------------------------------------------------------------------------------
/five/src/main/java/com/zj/five/ProgressTest.kt:
--------------------------------------------------------------------------------
1 | package com.zj.five
2 |
3 | import androidx.compose.foundation.layout.size
4 | import androidx.compose.material.CircularProgressIndicator
5 | import androidx.compose.material.LinearProgressIndicator
6 | import androidx.compose.material.ProgressIndicatorDefaults
7 | import androidx.compose.runtime.Composable
8 | import androidx.compose.ui.Modifier
9 | import androidx.compose.ui.tooling.preview.Preview
10 | import androidx.compose.ui.unit.dp
11 |
12 | @Composable
13 | fun ProgressTest(){
14 | //LinearProgressIndicator()
15 | CircularProgressIndicator(modifier = Modifier.size(50.dp))
16 | }
17 |
18 | @Preview(showBackground = true, widthDp = 200, heightDp = 200)
19 | @Composable
20 | fun ProgressTestPreview() {
21 | ProgressTest()
22 | }
--------------------------------------------------------------------------------
/five/src/main/java/com/zj/five/ui/theme/Color.kt:
--------------------------------------------------------------------------------
1 | package com.zj.five.ui.theme
2 |
3 | import androidx.compose.ui.graphics.Color
4 |
5 | val Purple200 = Color(0xFFBB86FC)
6 | val Purple500 = Color(0xFF6200EE)
7 | val Purple700 = Color(0xFF3700B3)
8 | val Teal200 = Color(0xFF03DAC5)
--------------------------------------------------------------------------------
/five/src/main/java/com/zj/five/ui/theme/Shape.kt:
--------------------------------------------------------------------------------
1 | package com.zj.five.ui.theme
2 |
3 | import androidx.compose.foundation.shape.RoundedCornerShape
4 | import androidx.compose.material.Shapes
5 | import androidx.compose.ui.unit.dp
6 |
7 | val Shapes = Shapes(
8 | small = RoundedCornerShape(4.dp),
9 | medium = RoundedCornerShape(4.dp),
10 | large = RoundedCornerShape(0.dp)
11 | )
--------------------------------------------------------------------------------
/five/src/main/java/com/zj/five/ui/theme/Theme.kt:
--------------------------------------------------------------------------------
1 | package com.zj.five.ui.theme
2 |
3 | import androidx.compose.foundation.isSystemInDarkTheme
4 | import androidx.compose.material.MaterialTheme
5 | import androidx.compose.material.darkColors
6 | import androidx.compose.material.lightColors
7 | import androidx.compose.runtime.Composable
8 |
9 | private val DarkColorPalette = darkColors(
10 | primary = Purple200,
11 | primaryVariant = Purple700,
12 | secondary = Teal200
13 | )
14 |
15 | private val LightColorPalette = lightColors(
16 | primary = Purple500,
17 | primaryVariant = Purple700,
18 | secondary = Teal200
19 |
20 | /* Other default colors to override
21 | background = Color.White,
22 | surface = Color.White,
23 | onPrimary = Color.White,
24 | onSecondary = Color.Black,
25 | onBackground = Color.Black,
26 | onSurface = Color.Black,
27 | */
28 | )
29 |
30 | @Composable
31 | fun FiveTheme(darkTheme: Boolean = isSystemInDarkTheme(), content: @Composable() () -> Unit) {
32 | val colors = if (darkTheme) {
33 | DarkColorPalette
34 | } else {
35 | LightColorPalette
36 | }
37 |
38 | MaterialTheme(
39 | colors = colors,
40 | typography = Typography,
41 | shapes = Shapes,
42 | content = content
43 | )
44 | }
--------------------------------------------------------------------------------
/five/src/main/java/com/zj/five/ui/theme/Type.kt:
--------------------------------------------------------------------------------
1 | package com.zj.five.ui.theme
2 |
3 | import androidx.compose.material.Typography
4 | import androidx.compose.ui.text.TextStyle
5 | import androidx.compose.ui.text.font.FontFamily
6 | import androidx.compose.ui.text.font.FontWeight
7 | import androidx.compose.ui.unit.sp
8 |
9 | // Set of Material typography styles to start with
10 | val Typography = Typography(
11 | body1 = TextStyle(
12 | fontFamily = FontFamily.Default,
13 | fontWeight = FontWeight.Normal,
14 | fontSize = 16.sp
15 | )
16 | /* Other default text styles to override
17 | button = TextStyle(
18 | fontFamily = FontFamily.Default,
19 | fontWeight = FontWeight.W500,
20 | fontSize = 14.sp
21 | ),
22 | caption = TextStyle(
23 | fontFamily = FontFamily.Default,
24 | fontWeight = FontWeight.Normal,
25 | fontSize = 12.sp
26 | )
27 | */
28 | )
--------------------------------------------------------------------------------
/five/src/main/res/drawable-xxxhdpi/ic_nav_discover_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/five/src/main/res/drawable-xxxhdpi/ic_nav_discover_normal.png
--------------------------------------------------------------------------------
/five/src/main/res/drawable-xxxhdpi/ic_nav_my_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/five/src/main/res/drawable-xxxhdpi/ic_nav_my_normal.png
--------------------------------------------------------------------------------
/five/src/main/res/drawable-xxxhdpi/ic_nav_news_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/five/src/main/res/drawable-xxxhdpi/ic_nav_news_normal.png
--------------------------------------------------------------------------------
/five/src/main/res/drawable-xxxhdpi/ic_nav_tweet_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/five/src/main/res/drawable-xxxhdpi/ic_nav_tweet_normal.png
--------------------------------------------------------------------------------
/five/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/five/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/five/src/main/res/mipmap-hdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/five/src/main/res/mipmap-hdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/five/src/main/res/mipmap-hdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/five/src/main/res/mipmap-hdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/five/src/main/res/mipmap-mdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/five/src/main/res/mipmap-mdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/five/src/main/res/mipmap-mdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/five/src/main/res/mipmap-mdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/five/src/main/res/mipmap-xhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/five/src/main/res/mipmap-xhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/five/src/main/res/mipmap-xhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/five/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/five/src/main/res/mipmap-xxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/five/src/main/res/mipmap-xxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/five/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/five/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/five/src/main/res/mipmap-xxxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/five/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/five/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/five/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/five/src/main/res/values-night/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/five/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFBB86FC
4 | #FF6200EE
5 | #FF3700B3
6 | #FF03DAC5
7 | #FF018786
8 | #FF000000
9 | #FFFFFFFF
10 |
--------------------------------------------------------------------------------
/five/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Five
3 |
--------------------------------------------------------------------------------
/five/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
17 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/five/src/test/java/com/zj/five/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.zj.five
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------
/four/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/four/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/four/src/androidTest/java/com/zj/four/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.zj.four
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("com.zj.four", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/four/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
14 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/four/src/main/java/com/zj/four/Toast.kt:
--------------------------------------------------------------------------------
1 | package com.zj.four
2 |
3 | import android.content.Context
4 | import android.widget.Toast
5 |
6 | // 普通Toast
7 | fun showToast(context: Context, content: String) {
8 | Toast.makeText(context, content, Toast.LENGTH_SHORT).show()
9 | }
10 |
11 | // 长Toast
12 | fun showLongToast(context: Context, content: String) {
13 | Toast.makeText(context, content, Toast.LENGTH_LONG).show()
14 | }
--------------------------------------------------------------------------------
/four/src/main/java/com/zj/four/ui/theme/Color.kt:
--------------------------------------------------------------------------------
1 | package com.zj.four.ui.theme
2 |
3 | import androidx.compose.ui.graphics.Color
4 |
5 | val Purple200 = Color(0xFFBB86FC)
6 | val Purple500 = Color(0xFF6200EE)
7 | val Purple700 = Color(0xFF3700B3)
8 | val Teal200 = Color(0xFF03DAC5)
--------------------------------------------------------------------------------
/four/src/main/java/com/zj/four/ui/theme/Shape.kt:
--------------------------------------------------------------------------------
1 | package com.zj.four.ui.theme
2 |
3 | import androidx.compose.foundation.shape.RoundedCornerShape
4 | import androidx.compose.material.Shapes
5 | import androidx.compose.ui.unit.dp
6 |
7 | val Shapes = Shapes(
8 | small = RoundedCornerShape(4.dp),
9 | medium = RoundedCornerShape(4.dp),
10 | large = RoundedCornerShape(0.dp)
11 | )
--------------------------------------------------------------------------------
/four/src/main/java/com/zj/four/ui/theme/Theme.kt:
--------------------------------------------------------------------------------
1 | package com.zj.four.ui.theme
2 |
3 | import androidx.compose.foundation.isSystemInDarkTheme
4 | import androidx.compose.material.MaterialTheme
5 | import androidx.compose.material.darkColors
6 | import androidx.compose.material.lightColors
7 | import androidx.compose.runtime.Composable
8 |
9 | private val DarkColorPalette = darkColors(
10 | primary = Purple200,
11 | primaryVariant = Purple700,
12 | secondary = Teal200
13 | )
14 |
15 | private val LightColorPalette = lightColors(
16 | primary = Purple500,
17 | primaryVariant = Purple700,
18 | secondary = Teal200
19 |
20 | /* Other default colors to override
21 | background = Color.White,
22 | surface = Color.White,
23 | onPrimary = Color.White,
24 | onSecondary = Color.Black,
25 | onBackground = Color.Black,
26 | onSurface = Color.Black,
27 | */
28 | )
29 |
30 | @Composable
31 | fun FourTheme(darkTheme: Boolean = isSystemInDarkTheme(), content: @Composable() () -> Unit) {
32 | val colors = if (darkTheme) {
33 | DarkColorPalette
34 | } else {
35 | LightColorPalette
36 | }
37 | MaterialTheme.colors
38 | MaterialTheme(
39 | colors = colors,
40 | typography = Typography,
41 | shapes = Shapes,
42 | content = content
43 | )
44 | }
--------------------------------------------------------------------------------
/four/src/main/java/com/zj/four/ui/theme/Type.kt:
--------------------------------------------------------------------------------
1 | package com.zj.four.ui.theme
2 |
3 | import androidx.compose.material.Typography
4 | import androidx.compose.ui.text.TextStyle
5 | import androidx.compose.ui.text.font.FontFamily
6 | import androidx.compose.ui.text.font.FontWeight
7 | import androidx.compose.ui.unit.sp
8 |
9 | // Set of Material typography styles to start with
10 | val Typography = Typography(
11 | body1 = TextStyle(
12 | fontFamily = FontFamily.Default,
13 | fontWeight = FontWeight.Normal,
14 | fontSize = 16.sp
15 | ),
16 | button = TextStyle(
17 | fontFamily = FontFamily.Default,
18 | fontWeight = FontWeight.W500,
19 | fontSize = 14.sp
20 | ),
21 | caption = TextStyle(
22 | fontFamily = FontFamily.Default,
23 | fontWeight = FontWeight.Normal,
24 | fontSize = 12.sp
25 | )
26 | )
--------------------------------------------------------------------------------
/four/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
--------------------------------------------------------------------------------
/four/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/four/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/four/src/main/res/mipmap-hdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/four/src/main/res/mipmap-hdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/four/src/main/res/mipmap-hdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/four/src/main/res/mipmap-hdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/four/src/main/res/mipmap-mdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/four/src/main/res/mipmap-mdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/four/src/main/res/mipmap-mdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/four/src/main/res/mipmap-mdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/four/src/main/res/mipmap-xhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/four/src/main/res/mipmap-xhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/four/src/main/res/mipmap-xhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/four/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/four/src/main/res/mipmap-xxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/four/src/main/res/mipmap-xxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/four/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/four/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/four/src/main/res/mipmap-xxxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/four/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/four/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/four/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/four/src/main/res/values-night/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/four/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFBB86FC
4 | #FF6200EE
5 | #FF3700B3
6 | #FF03DAC5
7 | #FF018786
8 | #FF000000
9 | #FFFFFFFF
10 |
--------------------------------------------------------------------------------
/four/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Four
3 | Zhujiang
4 |
--------------------------------------------------------------------------------
/four/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
17 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/four/src/test/java/com/zj/four/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.zj.four
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app"s APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
20 | # Kotlin code style for this project: "official" or "obsolete":
21 | kotlin.code.style=official
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Sep 16 22:23:24 CST 2022
2 | distributionBase=GRADLE_USER_HOME
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
4 | distributionPath=wrapper/dists
5 | zipStorePath=wrapper/dists
6 | zipStoreBase=GRADLE_USER_HOME
7 |
--------------------------------------------------------------------------------
/nine/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/nine/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/nine/src/androidTest/java/com/zj/nine/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.zj.nine
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("com.zj.nine", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/nine/src/main/java/com/zj/nine/AndroidViewPage.kt:
--------------------------------------------------------------------------------
1 | package com.zj.nine
2 |
3 | import android.widget.CalendarView
4 | import android.widget.Toast
5 | import androidx.compose.foundation.layout.fillMaxWidth
6 | import androidx.compose.material.Text
7 | import androidx.compose.runtime.Composable
8 | import androidx.compose.ui.Modifier
9 | import androidx.compose.ui.platform.LocalContext
10 | import androidx.compose.ui.tooling.preview.Preview
11 | import androidx.compose.ui.viewinterop.AndroidView
12 |
13 | @Composable
14 | fun AndroidViewPage() {
15 | AndroidView(
16 | factory = {
17 | CalendarView(it)
18 | },
19 | modifier = Modifier.fillMaxWidth(),
20 | update = {
21 | it.setOnDateChangeListener { view, year, month, day ->
22 | Toast.makeText(view.context, "${year}年${month}月${day}日", Toast.LENGTH_LONG).show()
23 | }
24 | }
25 | )
26 | }
27 |
28 | @Preview
29 | @Composable
30 | fun AndroidViewPagePreview() {
31 | AndroidViewPage()
32 | }
--------------------------------------------------------------------------------
/nine/src/main/java/com/zj/nine/AndroidWebViewPage.kt:
--------------------------------------------------------------------------------
1 | package com.zj.nine
2 |
3 | import android.content.Context
4 | import android.util.AttributeSet
5 | import androidx.compose.runtime.Composable
6 | import androidx.compose.ui.platform.AbstractComposeView
7 | import com.zj.nine.ui.theme.NineTheme
8 |
9 | class AndroidWebViewPage @JvmOverloads constructor(
10 | context: Context,
11 | attrs: AttributeSet? = null,
12 | defStyle: Int = 0
13 | ) : AbstractComposeView(context, attrs, defStyle) {
14 |
15 | @Composable
16 | override fun Content() {
17 | // NineTheme {
18 | WebViewPage()
19 | // }
20 | }
21 |
22 | }
--------------------------------------------------------------------------------
/nine/src/main/java/com/zj/nine/ShareWidgetActivity.kt:
--------------------------------------------------------------------------------
1 | package com.zj.nine
2 |
3 | import android.os.Bundle
4 | import androidx.activity.ComponentActivity
5 | import com.zj.nine.databinding.ActivityShareWidgetBinding
6 |
7 | class ShareWidgetActivity : ComponentActivity() {
8 |
9 | private lateinit var shareWidgetBinding: ActivityShareWidgetBinding
10 |
11 | override fun onCreate(savedInstanceState: Bundle?) {
12 | super.onCreate(savedInstanceState)
13 | shareWidgetBinding = ActivityShareWidgetBinding.inflate(layoutInflater)
14 | setContentView(shareWidgetBinding.root)
15 | initView()
16 | }
17 |
18 | private fun initView() {
19 | shareWidgetBinding.apply {
20 | shareComposeView.setContent {
21 | WebViewPage()
22 | }
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/nine/src/main/java/com/zj/nine/ui/theme/Color.kt:
--------------------------------------------------------------------------------
1 | package com.zj.nine.ui.theme
2 |
3 | import androidx.compose.ui.graphics.Color
4 |
5 | val Purple200 = Color(0xFFBB86FC)
6 | val Purple500 = Color(0xFF6200EE)
7 | val Purple700 = Color(0xFF3700B3)
8 | val Teal200 = Color(0xFF03DAC5)
--------------------------------------------------------------------------------
/nine/src/main/java/com/zj/nine/ui/theme/Shape.kt:
--------------------------------------------------------------------------------
1 | package com.zj.nine.ui.theme
2 |
3 | import androidx.compose.foundation.shape.RoundedCornerShape
4 | import androidx.compose.material.Shapes
5 | import androidx.compose.ui.unit.dp
6 |
7 | val Shapes = Shapes(
8 | small = RoundedCornerShape(4.dp),
9 | medium = RoundedCornerShape(4.dp),
10 | large = RoundedCornerShape(0.dp)
11 | )
--------------------------------------------------------------------------------
/nine/src/main/java/com/zj/nine/ui/theme/Theme.kt:
--------------------------------------------------------------------------------
1 | package com.zj.nine.ui.theme
2 |
3 | import androidx.compose.foundation.isSystemInDarkTheme
4 | import androidx.compose.material.MaterialTheme
5 | import androidx.compose.material.darkColors
6 | import androidx.compose.material.lightColors
7 | import androidx.compose.runtime.Composable
8 |
9 | private val DarkColorPalette = darkColors(
10 | primary = Purple200,
11 | primaryVariant = Purple700,
12 | secondary = Teal200
13 | )
14 |
15 | private val LightColorPalette = lightColors(
16 | primary = Purple500,
17 | primaryVariant = Purple700,
18 | secondary = Teal200
19 |
20 | /* Other default colors to override
21 | background = Color.White,
22 | surface = Color.White,
23 | onPrimary = Color.White,
24 | onSecondary = Color.Black,
25 | onBackground = Color.Black,
26 | onSurface = Color.Black,
27 | */
28 | )
29 |
30 | @Composable
31 | fun NineTheme(darkTheme: Boolean = isSystemInDarkTheme(), content: @Composable() () -> Unit) {
32 | val colors = if (darkTheme) {
33 | DarkColorPalette
34 | } else {
35 | LightColorPalette
36 | }
37 |
38 | MaterialTheme(
39 | colors = colors,
40 | typography = Typography,
41 | shapes = Shapes,
42 | content = content
43 | )
44 | }
--------------------------------------------------------------------------------
/nine/src/main/java/com/zj/nine/ui/theme/Type.kt:
--------------------------------------------------------------------------------
1 | package com.zj.nine.ui.theme
2 |
3 | import androidx.compose.material.Typography
4 | import androidx.compose.ui.text.TextStyle
5 | import androidx.compose.ui.text.font.FontFamily
6 | import androidx.compose.ui.text.font.FontWeight
7 | import androidx.compose.ui.unit.sp
8 |
9 | // Set of Material typography styles to start with
10 | val Typography = Typography(
11 | body1 = TextStyle(
12 | fontFamily = FontFamily.Default,
13 | fontWeight = FontWeight.Normal,
14 | fontSize = 16.sp
15 | )
16 | /* Other default text styles to override
17 | button = TextStyle(
18 | fontFamily = FontFamily.Default,
19 | fontWeight = FontWeight.W500,
20 | fontSize = 14.sp
21 | ),
22 | caption = TextStyle(
23 | fontFamily = FontFamily.Default,
24 | fontWeight = FontWeight.Normal,
25 | fontSize = 12.sp
26 | )
27 | */
28 | )
--------------------------------------------------------------------------------
/nine/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
15 |
16 |
21 |
22 |
--------------------------------------------------------------------------------
/nine/src/main/res/layout/activity_share_widget.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
20 |
21 |
--------------------------------------------------------------------------------
/nine/src/main/res/layout/compose_login.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
20 |
21 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/nine/src/main/res/layout/fragment_compose.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
13 |
14 |
--------------------------------------------------------------------------------
/nine/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/nine/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/nine/src/main/res/mipmap-hdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/nine/src/main/res/mipmap-hdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/nine/src/main/res/mipmap-hdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/nine/src/main/res/mipmap-hdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/nine/src/main/res/mipmap-mdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/nine/src/main/res/mipmap-mdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/nine/src/main/res/mipmap-mdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/nine/src/main/res/mipmap-mdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/nine/src/main/res/mipmap-xhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/nine/src/main/res/mipmap-xhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/nine/src/main/res/mipmap-xhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/nine/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/nine/src/main/res/mipmap-xxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/nine/src/main/res/mipmap-xxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/nine/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/nine/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/nine/src/main/res/mipmap-xxxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/nine/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/nine/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/nine/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/nine/src/main/res/values-night/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/nine/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFBB86FC
4 | #FF6200EE
5 | #FF3700B3
6 | #FF03DAC5
7 | #FF018786
8 | #FF000000
9 | #FFFFFFFF
10 |
--------------------------------------------------------------------------------
/nine/src/main/res/values/ids.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/nine/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Nine
3 |
4 | Hello blank fragment
5 |
--------------------------------------------------------------------------------
/nine/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
17 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/nine/src/test/java/com/zj/nine/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.zj.nine
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------
/one/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/one/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/one/src/androidTest/java/com/zj/one/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.zj.one
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("com.zj.one", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/one/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/one/src/main/java/com/zj/one/DefaultParam.kt:
--------------------------------------------------------------------------------
1 | package com.zj.one
2 |
3 | import android.util.Log
4 |
5 | class DefaultParam {
6 | companion object {
7 | private const val TAG = "DefaultParam"
8 | }
9 |
10 | fun test() {
11 | test1(0)
12 | Test(b = "")
13 | }
14 |
15 | fun test1(a: Int, b: String = "") {
16 | Log.e(TAG, "test1: a:$a b:$b")
17 | }
18 |
19 | fun testData(){
20 | val test = Test(a = 10, b = "Zhujiang")
21 | val (a, b) = test
22 | Log.e(TAG, "testData: a=$a")
23 | Log.e(TAG, "testData: b=$b")
24 | }
25 |
26 | }
27 |
28 | data class Test(val a: Int = 0, val b: String)
--------------------------------------------------------------------------------
/one/src/main/java/com/zj/one/HigherFunctions.kt:
--------------------------------------------------------------------------------
1 | package com.zj.one
2 |
3 | import android.util.Log
4 |
5 | class HigherFunctions {
6 |
7 | companion object {
8 | private const val TAG = "HigherFunctions"
9 | }
10 |
11 | fun test() {
12 | high({
13 | Log.e(TAG, "test: string: $it")
14 | }, "test")
15 | }
16 |
17 | fun high(one: (String) -> Unit, string: String) {
18 | // 或者使用one.invoke()进行调用
19 | one(string)
20 | }
21 |
22 | fun test2() {
23 | high2 {
24 | Log.e(TAG, "test")
25 | }
26 | }
27 |
28 | fun high2(two: () -> Unit) {
29 | two()
30 | }
31 |
32 | }
--------------------------------------------------------------------------------
/one/src/main/java/com/zj/one/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.zj.one
2 |
3 | import android.os.Bundle
4 | import androidx.activity.ComponentActivity
5 | import androidx.activity.compose.setContent
6 | import androidx.compose.material.MaterialTheme
7 | import androidx.compose.material.Surface
8 | import androidx.compose.material.Text
9 | import androidx.compose.runtime.Composable
10 | import androidx.compose.ui.tooling.preview.Preview
11 | import com.zj.one.ui.theme.OneTheme
12 |
13 | class MainActivity : ComponentActivity() {
14 | override fun onCreate(savedInstanceState: Bundle?) {
15 | super.onCreate(savedInstanceState)
16 | setContent {
17 | OneTheme {
18 | // A surface container using the 'background' color from the theme
19 | Surface(color = MaterialTheme.colors.background) {
20 | Greeting("Android")
21 | }
22 | }
23 | }
24 | }
25 | }
26 |
27 | @Composable
28 | fun Greeting(name: String) {
29 | Text(text = "Hello $name!")
30 | }
31 |
32 | @Preview(showBackground = true)
33 | @Composable
34 | fun DefaultPreview() {
35 | OneTheme {
36 | Greeting("Android")
37 | }
38 | }
--------------------------------------------------------------------------------
/one/src/main/java/com/zj/one/ui/theme/Color.kt:
--------------------------------------------------------------------------------
1 | package com.zj.one.ui.theme
2 |
3 | import androidx.compose.ui.graphics.Color
4 |
5 | val Purple200 = Color(0xFFBB86FC)
6 | val Purple500 = Color(0xFF6200EE)
7 | val Purple700 = Color(0xFF3700B3)
8 | val Teal200 = Color(0xFF03DAC5)
--------------------------------------------------------------------------------
/one/src/main/java/com/zj/one/ui/theme/Shape.kt:
--------------------------------------------------------------------------------
1 | package com.zj.one.ui.theme
2 |
3 | import androidx.compose.foundation.shape.RoundedCornerShape
4 | import androidx.compose.material.Shapes
5 | import androidx.compose.ui.unit.dp
6 |
7 | val Shapes = Shapes(
8 | small = RoundedCornerShape(4.dp),
9 | medium = RoundedCornerShape(4.dp),
10 | large = RoundedCornerShape(0.dp)
11 | )
--------------------------------------------------------------------------------
/one/src/main/java/com/zj/one/ui/theme/Theme.kt:
--------------------------------------------------------------------------------
1 | package com.zj.one.ui.theme
2 |
3 | import androidx.compose.foundation.isSystemInDarkTheme
4 | import androidx.compose.material.MaterialTheme
5 | import androidx.compose.material.darkColors
6 | import androidx.compose.material.lightColors
7 | import androidx.compose.runtime.Composable
8 |
9 | private val DarkColorPalette = darkColors(
10 | primary = Purple200,
11 | primaryVariant = Purple700,
12 | secondary = Teal200
13 | )
14 |
15 | private val LightColorPalette = lightColors(
16 | primary = Purple500,
17 | primaryVariant = Purple700,
18 | secondary = Teal200
19 |
20 | /* Other default colors to override
21 | background = Color.White,
22 | surface = Color.White,
23 | onPrimary = Color.White,
24 | onSecondary = Color.Black,
25 | onBackground = Color.Black,
26 | onSurface = Color.Black,
27 | */
28 | )
29 |
30 | @Composable
31 | fun OneTheme(darkTheme: Boolean = isSystemInDarkTheme(), content: @Composable() () -> Unit) {
32 | val colors = if (darkTheme) {
33 | DarkColorPalette
34 | } else {
35 | LightColorPalette
36 | }
37 |
38 | MaterialTheme(
39 | colors = colors,
40 | typography = Typography,
41 | shapes = Shapes,
42 | content = content
43 | )
44 | }
--------------------------------------------------------------------------------
/one/src/main/java/com/zj/one/ui/theme/Type.kt:
--------------------------------------------------------------------------------
1 | package com.zj.one.ui.theme
2 |
3 | import androidx.compose.material.Typography
4 | import androidx.compose.ui.text.TextStyle
5 | import androidx.compose.ui.text.font.FontFamily
6 | import androidx.compose.ui.text.font.FontWeight
7 | import androidx.compose.ui.unit.sp
8 |
9 | // Set of Material typography styles to start with
10 | val Typography = Typography(
11 | body1 = TextStyle(
12 | fontFamily = FontFamily.Default,
13 | fontWeight = FontWeight.Normal,
14 | fontSize = 16.sp
15 | )
16 | /* Other default text styles to override
17 | button = TextStyle(
18 | fontFamily = FontFamily.Default,
19 | fontWeight = FontWeight.W500,
20 | fontSize = 14.sp
21 | ),
22 | caption = TextStyle(
23 | fontFamily = FontFamily.Default,
24 | fontWeight = FontWeight.Normal,
25 | fontSize = 12.sp
26 | )
27 | */
28 | )
--------------------------------------------------------------------------------
/one/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/one/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/one/src/main/res/mipmap-hdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/one/src/main/res/mipmap-hdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/one/src/main/res/mipmap-hdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/one/src/main/res/mipmap-hdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/one/src/main/res/mipmap-mdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/one/src/main/res/mipmap-mdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/one/src/main/res/mipmap-mdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/one/src/main/res/mipmap-mdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/one/src/main/res/mipmap-xhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/one/src/main/res/mipmap-xhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/one/src/main/res/mipmap-xhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/one/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/one/src/main/res/mipmap-xxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/one/src/main/res/mipmap-xxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/one/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/one/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/one/src/main/res/mipmap-xxxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/one/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/one/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/one/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/one/src/main/res/values-night/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/one/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFBB86FC
4 | #FF6200EE
5 | #FF3700B3
6 | #FF03DAC5
7 | #FF018786
8 | #FF000000
9 | #FFFFFFFF
10 |
--------------------------------------------------------------------------------
/one/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | One
3 |
--------------------------------------------------------------------------------
/one/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
17 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/one/src/test/java/com/zj/one/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.zj.one
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | dependencyResolutionManagement {
2 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
3 | repositories {
4 | google()
5 | mavenCentral()
6 | maven { url 'https://jitpack.io' }
7 | // jcenter() // Warning: this repository is going to shut down soon
8 | }
9 | }
10 | rootProject.name = "Compose"
11 | include ':one'
12 | include ':two'
13 | include ':three'
14 | include ':four'
15 | include ':five'
16 | include ':six'
17 | include ':seven'
18 | include ':eight'
19 | include ':nine'
20 | include ':ten'
21 |
--------------------------------------------------------------------------------
/seven/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/seven/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/seven/src/androidTest/java/com/zj/seven/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.zj.seven
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("com.zj.seven", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/seven/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
14 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/seven/src/main/java/com/zj/seven/content/AnimatedContent.kt:
--------------------------------------------------------------------------------
1 | @file:OptIn(ExperimentalAnimationApi::class)
2 |
3 | package com.zj.seven.content
4 |
5 | import androidx.compose.animation.AnimatedContent
6 | import androidx.compose.animation.ExperimentalAnimationApi
7 | import androidx.compose.foundation.layout.Row
8 | import androidx.compose.material.Button
9 | import androidx.compose.material.Text
10 | import androidx.compose.runtime.*
11 |
12 | @Composable
13 | fun AnimatedContents() {
14 |
15 | Row {
16 | var count by remember { mutableStateOf(0) }
17 | Button(onClick = { count++ }) {
18 | Text("Add")
19 | }
20 | AnimatedContent(targetState = count) { targetCount ->
21 | Text(text = "Count: $targetCount")
22 | }
23 | }
24 |
25 | }
--------------------------------------------------------------------------------
/seven/src/main/java/com/zj/seven/ui/theme/Color.kt:
--------------------------------------------------------------------------------
1 | package com.zj.seven.ui.theme
2 |
3 | import android.text.style.BackgroundColorSpan
4 | import androidx.compose.ui.graphics.Color
5 |
6 | val Purple200 = Color(0xFFBB86FC)
7 | val Purple500 = Color(0xFF6200EE)
8 | val Purple700 = Color(0xFF3700B3)
9 | val Teal200 = Color(0xFF03DAC5)
10 |
11 | val BackgroundColor = Color(0xFFF7F7F7)
--------------------------------------------------------------------------------
/seven/src/main/java/com/zj/seven/ui/theme/Shape.kt:
--------------------------------------------------------------------------------
1 | package com.zj.seven.ui.theme
2 |
3 | import androidx.compose.foundation.shape.RoundedCornerShape
4 | import androidx.compose.material.Shapes
5 | import androidx.compose.ui.unit.dp
6 |
7 | val Shapes = Shapes(
8 | small = RoundedCornerShape(4.dp),
9 | medium = RoundedCornerShape(4.dp),
10 | large = RoundedCornerShape(0.dp)
11 | )
--------------------------------------------------------------------------------
/seven/src/main/java/com/zj/seven/ui/theme/Theme.kt:
--------------------------------------------------------------------------------
1 | package com.zj.seven.ui.theme
2 |
3 | import androidx.compose.foundation.isSystemInDarkTheme
4 | import androidx.compose.material.MaterialTheme
5 | import androidx.compose.material.darkColors
6 | import androidx.compose.material.lightColors
7 | import androidx.compose.runtime.Composable
8 |
9 | private val DarkColorPalette = darkColors(
10 | primary = Purple200,
11 | primaryVariant = Purple700,
12 | secondary = Teal200
13 | )
14 |
15 | private val LightColorPalette = lightColors(
16 | primary = Purple500,
17 | primaryVariant = Purple700,
18 | secondary = Teal200
19 |
20 | /* Other default colors to override
21 | background = Color.White,
22 | surface = Color.White,
23 | onPrimary = Color.White,
24 | onSecondary = Color.Black,
25 | onBackground = Color.Black,
26 | onSurface = Color.Black,
27 | */
28 | )
29 |
30 | @Composable
31 | fun SevenTheme(darkTheme: Boolean = isSystemInDarkTheme(), content: @Composable() () -> Unit) {
32 | val colors = if (darkTheme) {
33 | DarkColorPalette
34 | } else {
35 | LightColorPalette
36 | }
37 |
38 | MaterialTheme(
39 | colors = colors,
40 | typography = Typography,
41 | shapes = Shapes,
42 | content = content
43 | )
44 | }
--------------------------------------------------------------------------------
/seven/src/main/java/com/zj/seven/ui/theme/Type.kt:
--------------------------------------------------------------------------------
1 | package com.zj.seven.ui.theme
2 |
3 | import androidx.compose.material.Typography
4 | import androidx.compose.ui.text.TextStyle
5 | import androidx.compose.ui.text.font.FontFamily
6 | import androidx.compose.ui.text.font.FontWeight
7 | import androidx.compose.ui.unit.sp
8 |
9 | // Set of Material typography styles to start with
10 | val Typography = Typography(
11 | body1 = TextStyle(
12 | fontFamily = FontFamily.Default,
13 | fontWeight = FontWeight.Normal,
14 | fontSize = 16.sp
15 | )
16 | /* Other default text styles to override
17 | button = TextStyle(
18 | fontFamily = FontFamily.Default,
19 | fontWeight = FontWeight.W500,
20 | fontSize = 14.sp
21 | ),
22 | caption = TextStyle(
23 | fontFamily = FontFamily.Default,
24 | fontWeight = FontWeight.Normal,
25 | fontSize = 12.sp
26 | )
27 | */
28 | )
--------------------------------------------------------------------------------
/seven/src/main/res/drawable-xxhdpi/ic_head.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/seven/src/main/res/drawable-xxhdpi/ic_head.jpeg
--------------------------------------------------------------------------------
/seven/src/main/res/drawable-xxxhdpi/ic_nav_discover_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/seven/src/main/res/drawable-xxxhdpi/ic_nav_discover_normal.png
--------------------------------------------------------------------------------
/seven/src/main/res/drawable-xxxhdpi/ic_nav_my_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/seven/src/main/res/drawable-xxxhdpi/ic_nav_my_normal.png
--------------------------------------------------------------------------------
/seven/src/main/res/drawable-xxxhdpi/ic_nav_news_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/seven/src/main/res/drawable-xxxhdpi/ic_nav_news_normal.png
--------------------------------------------------------------------------------
/seven/src/main/res/drawable-xxxhdpi/ic_nav_tweet_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/seven/src/main/res/drawable-xxxhdpi/ic_nav_tweet_normal.png
--------------------------------------------------------------------------------
/seven/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/seven/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/seven/src/main/res/mipmap-hdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/seven/src/main/res/mipmap-hdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/seven/src/main/res/mipmap-hdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/seven/src/main/res/mipmap-hdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/seven/src/main/res/mipmap-mdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/seven/src/main/res/mipmap-mdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/seven/src/main/res/mipmap-mdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/seven/src/main/res/mipmap-mdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/seven/src/main/res/mipmap-xhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/seven/src/main/res/mipmap-xhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/seven/src/main/res/mipmap-xhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/seven/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/seven/src/main/res/mipmap-xxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/seven/src/main/res/mipmap-xxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/seven/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/seven/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/seven/src/main/res/mipmap-xxxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/seven/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/seven/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/seven/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/seven/src/main/res/values-night/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/seven/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFBB86FC
4 | #FF6200EE
5 | #FF3700B3
6 | #FF03DAC5
7 | #FF018786
8 | #FF000000
9 | #FFFFFFFF
10 |
--------------------------------------------------------------------------------
/seven/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Seven
3 |
--------------------------------------------------------------------------------
/seven/src/test/java/com/zj/seven/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.zj.seven
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------
/six/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/six/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/six/src/androidTest/java/com/zj/six/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.zj.six
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("com.zj.six", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/six/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/six/src/main/java/com/zj/six/CustomView.kt:
--------------------------------------------------------------------------------
1 | package com.zj.six
2 |
3 | import androidx.compose.foundation.Canvas
4 | import androidx.compose.foundation.layout.fillMaxSize
5 | import androidx.compose.runtime.Composable
6 | import androidx.compose.ui.Modifier
7 | import androidx.compose.ui.geometry.Offset
8 | import androidx.compose.ui.graphics.Brush
9 | import androidx.compose.ui.graphics.Color
10 | import androidx.compose.ui.tooling.preview.Preview
11 |
12 | @Composable
13 | fun CustomViewTest() {
14 | Canvas(modifier = Modifier.fillMaxSize()) {
15 | drawLine(
16 | brush = Brush.linearGradient(
17 | colors = arrayListOf(
18 | Color.Red,
19 | Color.Green,
20 | Color.Blue
21 | ),
22 | ),
23 | start = Offset.Zero,
24 | end = Offset(800f, 2500f),
25 | strokeWidth = 30f
26 | )
27 | }
28 |
29 | }
30 |
31 | @Preview(showBackground = true)
32 | @Composable
33 | fun CustomViewTestPreview() {
34 | CustomViewTest()
35 | }
--------------------------------------------------------------------------------
/six/src/main/java/com/zj/six/CustomView1.kt:
--------------------------------------------------------------------------------
1 | package com.zj.six
2 |
3 | import android.content.Context
4 | import android.graphics.Canvas
5 | import android.util.AttributeSet
6 | import android.view.View
7 |
8 | class CustomView @JvmOverloads constructor(
9 | context: Context,
10 | attrs: AttributeSet? = null,
11 | defStyleAttr: Int = 0
12 | ) : View(context, attrs, defStyleAttr) {
13 |
14 | override fun onDraw(canvas: Canvas?) {
15 | super.onDraw(canvas)
16 | // 进行绘制
17 | }
18 |
19 | }
--------------------------------------------------------------------------------
/six/src/main/java/com/zj/six/DrawBlendMode.kt:
--------------------------------------------------------------------------------
1 | package com.zj.six
2 |
3 | import androidx.compose.foundation.Canvas
4 | import androidx.compose.foundation.layout.size
5 | import androidx.compose.runtime.Composable
6 | import androidx.compose.ui.Modifier
7 | import androidx.compose.ui.geometry.Offset
8 | import androidx.compose.ui.geometry.Size
9 | import androidx.compose.ui.graphics.BlendMode
10 | import androidx.compose.ui.graphics.Color
11 | import androidx.compose.ui.graphics.drawscope.Stroke
12 | import androidx.compose.ui.tooling.preview.Preview
13 | import androidx.compose.ui.unit.dp
14 |
15 | @Composable
16 | fun DrawBlendModeTest() {
17 |
18 | Canvas(modifier = Modifier.size(360.dp)) {
19 | drawCircle(
20 | color = Color.Yellow,
21 | radius = 175f,
22 | center = Offset(350f, 350f),
23 | blendMode = BlendMode.Clear
24 | )
25 | drawRect(
26 | color = Color.Blue,
27 | topLeft = Offset(300f, 300f),
28 | size = Size(350f, 350f),
29 | blendMode = BlendMode.Clear
30 | )
31 | }
32 |
33 | }
34 |
35 | @Preview(showBackground = true)
36 | @Composable
37 | fun DrawBlendModeTestPreview() {
38 | DrawBlendModeTest()
39 | }
--------------------------------------------------------------------------------
/six/src/main/java/com/zj/six/DrawLine.kt:
--------------------------------------------------------------------------------
1 | package com.zj.six
2 |
3 | import androidx.compose.foundation.Canvas
4 | import androidx.compose.foundation.layout.size
5 | import androidx.compose.runtime.Composable
6 | import androidx.compose.ui.Modifier
7 | import androidx.compose.ui.geometry.Offset
8 | import androidx.compose.ui.graphics.Color
9 | import androidx.compose.ui.graphics.StrokeCap
10 | import androidx.compose.ui.tooling.preview.Preview
11 | import androidx.compose.ui.unit.dp
12 |
13 | @Composable
14 | fun DrawLineTest() {
15 |
16 | val start = Offset(100f, 100f)
17 | val end = Offset(900f, 900f)
18 |
19 | Canvas(modifier = Modifier.size(360.dp)) {
20 | drawLine(
21 | color = Color.Red,
22 | start = start,
23 | end = end,
24 | strokeWidth = 30f,
25 | cap = StrokeCap.Round,
26 | )
27 | }
28 |
29 | }
30 |
31 | @Preview(showBackground = true)
32 | @Composable
33 | fun DrawLineTestPreview() {
34 | DrawLineTest()
35 | }
--------------------------------------------------------------------------------
/six/src/main/java/com/zj/six/DrawOval.kt:
--------------------------------------------------------------------------------
1 | package com.zj.six
2 |
3 | import androidx.compose.foundation.Canvas
4 | import androidx.compose.foundation.layout.size
5 | import androidx.compose.runtime.Composable
6 | import androidx.compose.ui.Modifier
7 | import androidx.compose.ui.geometry.Offset
8 | import androidx.compose.ui.geometry.Size
9 | import androidx.compose.ui.graphics.Color
10 | import androidx.compose.ui.tooling.preview.Preview
11 | import androidx.compose.ui.unit.dp
12 |
13 | @Composable
14 | fun DrawOvalTest() {
15 |
16 | val topLeft = Offset(100f, 100f)
17 | val ovalSize = Size(600f, 800f)
18 |
19 | // Canvas(modifier = Modifier.size(360.dp)) {
20 | // drawOval(
21 | // color = Color.Red,
22 | // topLeft = topLeft,
23 | // size = ovalSize
24 | // )
25 | // }
26 |
27 | Canvas(modifier = Modifier.size(360.dp)) {
28 | drawRect(
29 | color = Color.Blue,
30 | topLeft = topLeft,
31 | size = ovalSize
32 | )
33 | drawOval(
34 | color = Color.Red,
35 | topLeft = topLeft,
36 | size = ovalSize
37 | )
38 | }
39 |
40 | }
41 |
42 | @Preview(showBackground = true)
43 | @Composable
44 | fun DrawOvalTestPreview() {
45 | DrawOvalTest()
46 | }
--------------------------------------------------------------------------------
/six/src/main/java/com/zj/six/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.zj.six
2 |
3 | import android.os.Bundle
4 | import androidx.activity.ComponentActivity
5 | import androidx.activity.compose.setContent
6 | import androidx.compose.material.MaterialTheme
7 | import androidx.compose.material.Surface
8 | import androidx.compose.material.Text
9 | import androidx.compose.runtime.Composable
10 | import androidx.compose.ui.tooling.preview.Preview
11 | import com.zj.six.ui.theme.SixTheme
12 |
13 | class MainActivity : ComponentActivity() {
14 | override fun onCreate(savedInstanceState: Bundle?) {
15 | super.onCreate(savedInstanceState)
16 | setContent {
17 | SixTheme {
18 | // A surface container using the 'background' color from the theme
19 | Surface(color = MaterialTheme.colors.background) {
20 | // Greeting("Android")
21 | // CustomViewTest()
22 | DrawImageTest()
23 | }
24 | }
25 | }
26 | }
27 | }
28 |
29 | @Composable
30 | fun Greeting(name: String) {
31 | Text(text = "Hello $name!")
32 | }
33 |
34 | @Preview(showBackground = true)
35 | @Composable
36 | fun DefaultPreview() {
37 | SixTheme {
38 | Greeting("Android")
39 | }
40 | }
--------------------------------------------------------------------------------
/six/src/main/java/com/zj/six/ui/theme/Color.kt:
--------------------------------------------------------------------------------
1 | package com.zj.six.ui.theme
2 |
3 | import androidx.compose.ui.graphics.Color
4 |
5 | val Purple200 = Color(0xFFBB86FC)
6 | val Purple500 = Color(0xFF6200EE)
7 | val Purple700 = Color(0xFF3700B3)
8 | val Teal200 = Color(0xFF03DAC5)
--------------------------------------------------------------------------------
/six/src/main/java/com/zj/six/ui/theme/Shape.kt:
--------------------------------------------------------------------------------
1 | package com.zj.six.ui.theme
2 |
3 | import androidx.compose.foundation.shape.RoundedCornerShape
4 | import androidx.compose.material.Shapes
5 | import androidx.compose.ui.unit.dp
6 |
7 | val Shapes = Shapes(
8 | small = RoundedCornerShape(4.dp),
9 | medium = RoundedCornerShape(4.dp),
10 | large = RoundedCornerShape(0.dp)
11 | )
--------------------------------------------------------------------------------
/six/src/main/java/com/zj/six/ui/theme/Theme.kt:
--------------------------------------------------------------------------------
1 | package com.zj.six.ui.theme
2 |
3 | import androidx.compose.foundation.isSystemInDarkTheme
4 | import androidx.compose.material.MaterialTheme
5 | import androidx.compose.material.darkColors
6 | import androidx.compose.material.lightColors
7 | import androidx.compose.runtime.Composable
8 |
9 | private val DarkColorPalette = darkColors(
10 | primary = Purple200,
11 | primaryVariant = Purple700,
12 | secondary = Teal200
13 | )
14 |
15 | private val LightColorPalette = lightColors(
16 | primary = Purple500,
17 | primaryVariant = Purple700,
18 | secondary = Teal200
19 |
20 | /* Other default colors to override
21 | background = Color.White,
22 | surface = Color.White,
23 | onPrimary = Color.White,
24 | onSecondary = Color.Black,
25 | onBackground = Color.Black,
26 | onSurface = Color.Black,
27 | */
28 | )
29 |
30 | @Composable
31 | fun SixTheme(darkTheme: Boolean = isSystemInDarkTheme(), content: @Composable() () -> Unit) {
32 | val colors = if (darkTheme) {
33 | DarkColorPalette
34 | } else {
35 | LightColorPalette
36 | }
37 |
38 | MaterialTheme(
39 | colors = colors,
40 | typography = Typography,
41 | shapes = Shapes,
42 | content = content
43 | )
44 | }
--------------------------------------------------------------------------------
/six/src/main/java/com/zj/six/ui/theme/Type.kt:
--------------------------------------------------------------------------------
1 | package com.zj.six.ui.theme
2 |
3 | import androidx.compose.material.Typography
4 | import androidx.compose.ui.text.TextStyle
5 | import androidx.compose.ui.text.font.FontFamily
6 | import androidx.compose.ui.text.font.FontWeight
7 | import androidx.compose.ui.unit.sp
8 |
9 | // Set of Material typography styles to start with
10 | val Typography = Typography(
11 | body1 = TextStyle(
12 | fontFamily = FontFamily.Default,
13 | fontWeight = FontWeight.Normal,
14 | fontSize = 16.sp
15 | )
16 | /* Other default text styles to override
17 | button = TextStyle(
18 | fontFamily = FontFamily.Default,
19 | fontWeight = FontWeight.W500,
20 | fontSize = 14.sp
21 | ),
22 | caption = TextStyle(
23 | fontFamily = FontFamily.Default,
24 | fontWeight = FontWeight.Normal,
25 | fontSize = 12.sp
26 | )
27 | */
28 | )
--------------------------------------------------------------------------------
/six/src/main/res/drawable-xxhdpi/head.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/six/src/main/res/drawable-xxhdpi/head.jpg
--------------------------------------------------------------------------------
/six/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/six/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/six/src/main/res/mipmap-hdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/six/src/main/res/mipmap-hdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/six/src/main/res/mipmap-hdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/six/src/main/res/mipmap-hdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/six/src/main/res/mipmap-mdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/six/src/main/res/mipmap-mdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/six/src/main/res/mipmap-mdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/six/src/main/res/mipmap-mdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/six/src/main/res/mipmap-xhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/six/src/main/res/mipmap-xhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/six/src/main/res/mipmap-xhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/six/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/six/src/main/res/mipmap-xxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/six/src/main/res/mipmap-xxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/six/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/six/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/six/src/main/res/mipmap-xxxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/six/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/six/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/six/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/six/src/main/res/values-night/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/six/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFBB86FC
4 | #FF6200EE
5 | #FF3700B3
6 | #FF03DAC5
7 | #FF018786
8 | #FF000000
9 | #FFFFFFFF
10 |
--------------------------------------------------------------------------------
/six/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Six
3 |
--------------------------------------------------------------------------------
/six/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
17 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/six/src/test/java/com/zj/six/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.zj.six
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------
/ten/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/ten/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/ten/src/androidTest/java/com/zj/play/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.zj.play
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("com.zj.play", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/ten/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
16 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/ten/src/main/java/com/zj/play/App.kt:
--------------------------------------------------------------------------------
1 | package com.zj.play
2 |
3 | import android.app.Application
4 | import com.zj.play.logic.utils.DataStoreUtils
5 |
6 |
7 | /**
8 | * Application
9 | *
10 | * @author jiang zhu on 2019/10/21
11 | */
12 | class App : Application() {
13 |
14 | private var dataStore = DataStoreUtils
15 |
16 | override fun onCreate() {
17 | super.onCreate()
18 | DataStoreUtils.init(applicationContext)
19 | Play.initialize(dataStore)
20 | }
21 |
22 | }
--------------------------------------------------------------------------------
/ten/src/main/java/com/zj/play/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.zj.play
2 |
3 | import android.os.Bundle
4 | import androidx.activity.ComponentActivity
5 | import androidx.activity.compose.setContent
6 | import com.google.accompanist.insets.ProvideWindowInsets
7 | import com.zj.play.logic.utils.setAndroidNativeLightStatusBar
8 | import com.zj.play.logic.utils.transparentStatusBar
9 | import com.zj.play.ui.main.NavGraph
10 | import com.zj.play.ui.theme.PlayAndroidTheme
11 |
12 | class MainActivity : ComponentActivity() {
13 |
14 | override fun onCreate(savedInstanceState: Bundle?) {
15 | super.onCreate(savedInstanceState)
16 | transparentStatusBar()
17 | setAndroidNativeLightStatusBar()
18 | setContent {
19 | PlayAndroidTheme {
20 | ProvideWindowInsets {
21 | NavGraph()
22 | }
23 | }
24 | }
25 | }
26 |
27 | }
--------------------------------------------------------------------------------
/ten/src/main/java/com/zj/play/Play.kt:
--------------------------------------------------------------------------------
1 | package com.zj.play
2 |
3 | import com.zj.play.logic.utils.DataStoreUtils
4 |
5 | /**
6 | * 全局的API接口。
7 | *
8 | */
9 | object Play {
10 | private const val USERNAME = "username"
11 | private const val NICE_NAME = "nickname"
12 | private const val IS_LOGIN = "isLogin"
13 | private var dataStore = DataStoreUtils
14 |
15 | /**
16 | * 初始化接口。这里会进行应用程序的初始化操作,一定要在代码执行的最开始调用。
17 | *
18 | */
19 | fun initialize(dataStoreUtils: DataStoreUtils) {
20 | dataStore = dataStoreUtils
21 | }
22 |
23 | /**
24 | * 判断用户是否已登录。
25 | *
26 | * @return 已登录返回true,未登录返回false。
27 | */
28 | var isLogin: Boolean
29 | get() = dataStore.readBooleanData(IS_LOGIN)
30 | set(b) {
31 | dataStore.saveSyncBooleanData(IS_LOGIN, b)
32 | }
33 |
34 | /**
35 | * 注销用户登录。
36 | */
37 | fun logout() {
38 | dataStore.clearSync()
39 | }
40 |
41 | fun setUserInfo(nickname: String, username: String) {
42 | dataStore.saveSyncStringData(NICE_NAME, nickname)
43 | dataStore.saveSyncStringData(USERNAME, username)
44 | }
45 |
46 | val nickName: String
47 | get() = dataStore.readStringData(NICE_NAME)
48 | val username: String
49 | get() = dataStore.readStringData(USERNAME)
50 | }
--------------------------------------------------------------------------------
/ten/src/main/java/com/zj/play/logic/base/paging/HomePagingSource.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.zj.play.logic.base.paging
18 |
19 | import com.zj.play.logic.model.ArticleModel
20 | import com.zj.play.logic.network.PlayAndroidNetwork
21 |
22 | class HomePagingSource : BasePagingSource() {
23 |
24 | override suspend fun getArticleList(page: Int): List {
25 | val apiResponse = PlayAndroidNetwork.getArticle(page)
26 | return apiResponse.data.datas
27 | }
28 | }
--------------------------------------------------------------------------------
/ten/src/main/java/com/zj/play/logic/base/paging/OfficialPagingSource.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.zj.play.logic.base.paging
18 |
19 | import com.zj.play.logic.model.ArticleModel
20 | import com.zj.play.logic.network.PlayAndroidNetwork
21 |
22 | class OfficialPagingSource(
23 | private val cid: Int
24 | ) : BasePagingSource() {
25 |
26 | override suspend fun getArticleList(page: Int): List {
27 | val apiResponse = PlayAndroidNetwork.getWxArticle(page, cid)
28 | return apiResponse.data.datas
29 | }
30 | }
--------------------------------------------------------------------------------
/ten/src/main/java/com/zj/play/logic/base/paging/ProjectPagingSource.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.zj.play.logic.base.paging
18 |
19 | import com.zj.play.logic.model.ArticleModel
20 | import com.zj.play.logic.network.PlayAndroidNetwork
21 |
22 | class ProjectPagingSource(private val cid: Int) : BasePagingSource() {
23 |
24 | override suspend fun getArticleList(page: Int): List {
25 | val apiResponse = PlayAndroidNetwork.getProject(page, cid)
26 | return apiResponse.data.datas
27 | }
28 | }
--------------------------------------------------------------------------------
/ten/src/main/java/com/zj/play/logic/base/repository/BaseArticlePagingRepository.kt:
--------------------------------------------------------------------------------
1 | package com.zj.play.logic.base.repository
2 |
3 | import androidx.paging.PagingData
4 | import com.zj.play.logic.model.ArticleModel
5 | import com.zj.play.logic.model.Query
6 | import kotlinx.coroutines.flow.Flow
7 |
8 | /**
9 | * 版权:Zhujiang 个人版权
10 | *
11 | * @author zhujiang
12 | * 创建日期:2021/3/24
13 | * 描述:PlayAndroid
14 | *
15 | */
16 |
17 | abstract class BaseArticlePagingRepository {
18 | companion object {
19 | const val PAGE_SIZE = 15
20 | }
21 |
22 | abstract fun getPagingData(query: Query): Flow>
23 | }
--------------------------------------------------------------------------------
/ten/src/main/java/com/zj/play/logic/base/viewmodel/BaseAndroidViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.zj.play.logic.base.viewmodel
2 |
3 | import android.app.Application
4 | import androidx.lifecycle.LiveData
5 | import androidx.lifecycle.MutableLiveData
6 | import androidx.lifecycle.viewModelScope
7 | import com.zj.play.logic.model.ClassifyModel
8 | import com.zj.play.logic.model.PlayState
9 | import kotlinx.coroutines.Dispatchers
10 | import kotlinx.coroutines.launch
11 |
12 | /**
13 | * 版权:Zhujiang 个人版权
14 | *
15 | * @author zhujiang
16 | * 创建日期:2021/05/18
17 | * 描述:PlayAndroid
18 | *
19 | */
20 |
21 | abstract class BaseViewModel(application: Application) : BaseArticleViewModel(application) {
22 |
23 | protected val mutableTreeLiveData = MutableLiveData>>()
24 |
25 | val treeLiveData: LiveData>>
26 | get() = mutableTreeLiveData
27 |
28 | abstract suspend fun getData()
29 |
30 | fun getDataList() {
31 | viewModelScope.launch(Dispatchers.IO) {
32 | getData()
33 | }
34 | }
35 |
36 | private val _position = MutableLiveData(0)
37 | val position: LiveData = _position
38 |
39 | fun onPositionChanged(position: Int) {
40 | _position.value = position
41 | }
42 |
43 | }
--------------------------------------------------------------------------------
/ten/src/main/java/com/zj/play/logic/model/ArticleListModel.kt:
--------------------------------------------------------------------------------
1 | package com.zj.play.logic.model
2 |
3 | data class ArticleListModel(
4 | val curPage: Int,
5 | val datas: List,
6 | val offset: Int,
7 | val over: Boolean,
8 | val pageCount: Int,
9 | val size: Int,
10 | val total: Int
11 | )
--------------------------------------------------------------------------------
/ten/src/main/java/com/zj/play/logic/model/ArticleModel.kt:
--------------------------------------------------------------------------------
1 | package com.zj.play.logic.model
2 |
3 |
4 | /**
5 | * 版权:Zhujiang 个人版权
6 | *
7 | * @author zhujiangz
8 | * 创建日期:2021/5/15
9 | * 描述:PlayAndroid
10 | *
11 | */
12 |
13 | data class ArticleModel(
14 | val uid: Int = 0,
15 | val apkLink: String = "",
16 | val audit: Int = 0,
17 | val author: String = "",
18 | val canEdit: Boolean = true,
19 | val chapterId: Int = 0,
20 | val chapterName: String = "",
21 | var collect: Boolean = false,
22 | val courseId: Int = 0,
23 | var desc: String = "",
24 | val descMd: String = "",
25 | val envelopePic: String = "",
26 | val fresh: Boolean = false,
27 | val id: Int = 0,
28 | val link: String = "",
29 | val niceDate: String = "",
30 | val niceShareDate: String = "",
31 | val origin: String = "",
32 | val prefix: String = "",
33 | val projectLink: String = "",
34 | val publishTime: Long = 0L,
35 | val selfVisible: Int = 0,
36 | val shareDate: Long = 0L,
37 | val shareUser: String = "",
38 | val superChapterId: Int = 0,
39 | val superChapterName: String = "",
40 | var title: String = "",
41 | val type: Int = 0,
42 | val userId: Int = 0,
43 | val visible: Int = 0,
44 | val zan: Int = 0,
45 | var localType: Int = 0
46 | )
47 |
--------------------------------------------------------------------------------
/ten/src/main/java/com/zj/play/logic/model/BannerBean.kt:
--------------------------------------------------------------------------------
1 | package com.zj.play.logic.model
2 |
3 | import com.zj.banner.model.BaseBannerBean
4 |
5 | /**
6 | * 版权:Zhujiang 个人版权
7 | *
8 | * @author zhujiang
9 | * 创建日期:2021/5/15
10 | * 描述:PlayAndroid
11 | *
12 | */
13 |
14 | data class BannerBean(
15 | val uid: Int = 0,
16 | val desc: String,
17 | val id: Int,
18 | val imagePath: String,
19 | val isVisible: Int,
20 | val order: Int,
21 | val title: String,
22 | val type: Int,
23 | val url: String,
24 | var filePath: String = "",
25 | override var data: String?
26 | ) : BaseBannerBean()
--------------------------------------------------------------------------------
/ten/src/main/java/com/zj/play/logic/model/BaseModel.kt:
--------------------------------------------------------------------------------
1 | package com.zj.play.logic.model
2 |
3 | /**
4 | * 版权:Zhujiang 个人版权
5 | *
6 | * @author zhujiang
7 | * 创建日期:2021/5/15
8 | * 描述:PlayAndroid
9 | *
10 | */
11 |
12 | data class BaseModel(
13 | val `data`: T,
14 | val errorCode: Int,
15 | val errorMsg: String
16 | )
--------------------------------------------------------------------------------
/ten/src/main/java/com/zj/play/logic/model/ClassifyModel.kt:
--------------------------------------------------------------------------------
1 | package com.zj.play.logic.model
2 |
3 | /**
4 | * 版权:Zhujiang 个人版权
5 | *
6 | * @author zhujiang
7 | * 创建日期:2021/9/9
8 | * 描述:PlayAndroid
9 | *
10 | */
11 | data class ClassifyModel(
12 | val uid: Int,
13 | val courseId: Int,
14 | val id: Int,
15 | val name: String,
16 | val order: Int,
17 | val parentChapterId: Int,
18 | val userControlSetTop: Boolean,
19 | val visible: Int
20 | )
--------------------------------------------------------------------------------
/ten/src/main/java/com/zj/play/logic/model/LoginModel.kt:
--------------------------------------------------------------------------------
1 | package com.zj.play.logic.model
2 |
3 | data class LoginModel(
4 | val admin: Boolean,
5 | val chapterTops: List,
6 | val collectIds: List,
7 | val email: String,
8 | val icon: String,
9 | val id: Int,
10 | val nickname: String,
11 | val password: String,
12 | val publicName: String,
13 | val token: String,
14 | val type: Int,
15 | val username: String
16 | )
--------------------------------------------------------------------------------
/ten/src/main/java/com/zj/play/logic/model/PlayState.kt:
--------------------------------------------------------------------------------
1 | package com.zj.play.logic.model
2 |
3 |
4 | sealed class PlayState {
5 | fun isLoading() = this is PlayLoading
6 | fun isSuccessful() = this is PlaySuccess
7 |
8 | override fun toString(): String {
9 | return when (this) {
10 | is PlaySuccess<*> -> "Success[data=$data]"
11 | is PlayError -> "Error[exception=${error}]"
12 | PlayLoading -> "Loading"
13 | }
14 | }
15 | }
16 |
17 | data class PlaySuccess(val data: T) : PlayState()
18 | data class PlayError(val error: Throwable) : PlayState()
19 | object PlayLoading : PlayState()
20 |
21 | /**
22 | * [PlayState.data] if [Result] is of query [PlayState]
23 | */
24 | fun PlayState?.successOr(fallback: T): T {
25 | if (this == null) return fallback
26 | return (this as? PlaySuccess)?.data ?: fallback
27 | }
28 |
29 | val PlayState.data: T?
30 | get() = (this as? PlaySuccess)?.data
31 |
--------------------------------------------------------------------------------
/ten/src/main/java/com/zj/play/logic/model/Query.kt:
--------------------------------------------------------------------------------
1 | package com.zj.play.logic.model
2 |
3 | /**
4 | * 版权:Zhujiang 个人版权
5 | *
6 | * @author zhujiang
7 | * 创建日期:2021/11/2
8 | * 描述:PlayAndroid
9 | *
10 | */
11 |
12 | data class Query(
13 | var cid: Int = -1,
14 | var k: String = ""
15 | )
--------------------------------------------------------------------------------
/ten/src/main/java/com/zj/play/logic/network/service/HomePageService.kt:
--------------------------------------------------------------------------------
1 | package com.zj.play.logic.network.service
2 |
3 |
4 | import com.zj.play.logic.model.ArticleListModel
5 | import com.zj.play.logic.model.ArticleModel
6 | import com.zj.play.logic.model.BannerBean
7 | import com.zj.play.logic.model.BaseModel
8 | import retrofit2.http.GET
9 | import retrofit2.http.POST
10 | import retrofit2.http.Path
11 | import retrofit2.http.Query
12 |
13 | /**
14 | * 版权:Zhujiang 个人版权
15 | * @author zhujiang
16 | * 版本:1.5
17 | * 创建日期:2021/5/16
18 | * 描述:SunnyWeather
19 | *
20 | */
21 | interface HomePageService {
22 |
23 | @GET("banner/json")
24 | suspend fun getBanner(): BaseModel>
25 |
26 | @GET("article/list/{a}/json")
27 | suspend fun getArticle(@Path("a") a: Int): BaseModel
28 |
29 | }
--------------------------------------------------------------------------------
/ten/src/main/java/com/zj/play/logic/network/service/LoginService.kt:
--------------------------------------------------------------------------------
1 | package com.zj.play.logic.network.service
2 |
3 | import com.zj.play.logic.model.BaseModel
4 | import com.zj.play.logic.model.LoginModel
5 | import retrofit2.http.GET
6 | import retrofit2.http.POST
7 | import retrofit2.http.Query
8 |
9 | /**
10 | * 版权:Zhujiang 个人版权
11 | * @author zhujiang
12 | * 版本:1.5
13 | * 创建日期:2021/5/19
14 | * 描述:PlayAndroid
15 | *
16 | */
17 | interface LoginService {
18 |
19 | @POST("user/login")
20 | suspend fun getLogin(
21 | @Query("username") username: String,
22 | @Query("password") password: String
23 | ): BaseModel
24 |
25 | @POST("user/register")
26 | suspend fun getRegister(
27 | @Query("username") username: String,
28 | @Query("password") password: String,
29 | @Query("repassword") repassword: String
30 | ): BaseModel
31 |
32 | @GET("user/logout/json")
33 | suspend fun getLogout(): BaseModel
34 |
35 | }
--------------------------------------------------------------------------------
/ten/src/main/java/com/zj/play/logic/network/service/OfficialService.kt:
--------------------------------------------------------------------------------
1 | package com.zj.play.logic.network.service
2 |
3 |
4 | import com.zj.play.logic.model.ArticleListModel
5 | import com.zj.play.logic.model.BaseModel
6 | import com.zj.play.logic.model.ClassifyModel
7 | import retrofit2.http.GET
8 | import retrofit2.http.Path
9 |
10 | /**
11 | * 版权:Zhujiang 个人版权
12 | * @author zhujiang
13 | * 版本:1.5
14 | * 创建日期:2021/5/19
15 | * 描述:PlayAndroid
16 | *
17 | */
18 | interface OfficialService {
19 |
20 | @GET("wxarticle/chapters/json")
21 | suspend fun getWxArticleTree(): BaseModel>
22 |
23 | @GET("wxarticle/list/{cid}/{page}/json")
24 | suspend fun getWxArticle(@Path("page") page: Int, @Path("cid") cid: Int): BaseModel
25 |
26 | }
--------------------------------------------------------------------------------
/ten/src/main/java/com/zj/play/logic/network/service/ProjectService.kt:
--------------------------------------------------------------------------------
1 | package com.zj.play.logic.network.service
2 |
3 | import com.zj.play.logic.model.ArticleListModel
4 | import com.zj.play.logic.model.BaseModel
5 | import com.zj.play.logic.model.ClassifyModel
6 | import retrofit2.http.GET
7 | import retrofit2.http.Path
8 | import retrofit2.http.Query
9 |
10 | /**
11 | * 版权:Zhujiang 个人版权
12 | * @author zhujiang
13 | * 版本:1.5
14 | * 创建日期:2021/5/18
15 | * 描述:PlayAndroid
16 | *
17 | */
18 | interface ProjectService {
19 |
20 | @GET("project/tree/json")
21 | suspend fun getProjectTree(): BaseModel>
22 |
23 | @GET("project/list/{page}/json")
24 | suspend fun getProject(
25 | @Path("page") page: Int,
26 | @Query("cid") cid: Int
27 | ): BaseModel
28 |
29 | }
--------------------------------------------------------------------------------
/ten/src/main/java/com/zj/play/logic/utils/HtmlUtils.kt:
--------------------------------------------------------------------------------
1 | package com.zj.play.logic.utils
2 |
3 | import android.os.Build
4 | import android.text.Html
5 |
6 | /**
7 | * 版权:Zhujiang 个人版权
8 | *
9 | * @author zhujiang
10 | * 创建日期:21/5/16
11 | * 描述:PlayAndroid
12 | *
13 | */
14 |
15 | /**
16 | * 将Html文本转为普通字符串
17 | */
18 | fun getHtmlText(text: String): String {
19 | return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
20 | Html.fromHtml(text, Html.FROM_HTML_MODE_LEGACY).toString()
21 | } else {
22 | text
23 | }
24 | }
--------------------------------------------------------------------------------
/ten/src/main/java/com/zj/play/logic/utils/Toast.kt:
--------------------------------------------------------------------------------
1 | package com.zj.play.logic.utils
2 |
3 | import android.content.Context
4 | import android.widget.Toast
5 | import androidx.annotation.StringRes
6 |
7 | /**
8 | * 版权:Zhujiang 个人版权
9 | * @author zhujiang
10 | * 版本:1.5
11 | * 创建日期:2021/5/15
12 | * 描述:PlayAndroid
13 | *
14 | */
15 |
16 | fun showToast(context: Context?, msg: String) {
17 | Toast.makeText(context, msg, Toast.LENGTH_SHORT).show()
18 | }
19 |
20 | fun showToast(context: Context?, @StringRes msgId: Int) {
21 | Toast.makeText(context, msgId, Toast.LENGTH_SHORT).show()
22 | }
23 |
24 | fun showLongToast(context: Context?, msg: String) {
25 | Toast.makeText(context, msg, Toast.LENGTH_LONG).show()
26 | }
27 |
28 | fun showLongToast(context: Context?, @StringRes msgId: Int) {
29 | Toast.makeText(context, msgId, Toast.LENGTH_LONG).show()
30 | }
--------------------------------------------------------------------------------
/ten/src/main/java/com/zj/play/ui/main/HomeViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.zj.play.ui.main
2 |
3 | import androidx.lifecycle.LiveData
4 | import androidx.lifecycle.MutableLiveData
5 | import androidx.lifecycle.ViewModel
6 |
7 | /**
8 | * 版权:Zhujiang 个人版权
9 | * @author zhujiang
10 | * 版本:1.5
11 | * 创建日期:2021/5/17
12 | * 描述:PlayAndroid
13 | *
14 | */
15 | class HomeViewModel : ViewModel(){
16 |
17 | private val _position = MutableLiveData(CourseTabs.HOME_PAGE)
18 | val position: LiveData = _position
19 |
20 | fun onPositionChanged(position: CourseTabs) {
21 | _position.value = position
22 | }
23 |
24 | }
--------------------------------------------------------------------------------
/ten/src/main/java/com/zj/play/ui/page/login/AccountRepository.kt:
--------------------------------------------------------------------------------
1 | package com.zj.play.ui.page.login
2 |
3 | import com.zj.play.logic.network.PlayAndroidNetwork
4 |
5 | /**
6 | * 版权:Zhujiang 个人版权
7 | * @author zhujiang
8 | * 版本:1.5
9 | * 创建日期:2021/5/17
10 | * 描述:PlayAndroid
11 | *
12 | */
13 |
14 | class AccountRepository {
15 |
16 | suspend fun getLogin(username: String, password: String) =
17 | PlayAndroidNetwork.getLogin(username, password)
18 |
19 | suspend fun getRegister(username: String, password: String, repassword: String) =
20 | PlayAndroidNetwork.getRegister(username, password, repassword)
21 |
22 | suspend fun getLogout() = PlayAndroidNetwork.getLogout()
23 |
24 | }
--------------------------------------------------------------------------------
/ten/src/main/java/com/zj/play/ui/page/official/OfficialRepository.kt:
--------------------------------------------------------------------------------
1 | package com.zj.play.ui.page.official
2 |
3 | import android.app.Application
4 | import androidx.paging.ExperimentalPagingApi
5 | import androidx.paging.Pager
6 | import androidx.paging.PagingConfig
7 | import com.zj.play.logic.base.paging.OfficialPagingSource
8 | import com.zj.play.logic.base.repository.BaseArticleRepository
9 | import com.zj.play.logic.model.BaseModel
10 | import com.zj.play.logic.model.ClassifyModel
11 | import com.zj.play.logic.model.Query
12 | import com.zj.play.logic.network.PlayAndroidNetwork
13 |
14 | /**
15 | * 版权:Zhujiang 个人版权
16 | *
17 | * @author zhujiang
18 | * 创建日期:2021/9/10
19 | * 描述:PlayAndroid
20 | *
21 | */
22 | class OfficialRepository(application: Application) : BaseArticleRepository(application) {
23 |
24 | override suspend fun getArticleTree(): BaseModel> {
25 | return PlayAndroidNetwork.getWxArticleTree()
26 | }
27 |
28 | override fun getPagingData(query: Query) = Pager(
29 | PagingConfig(
30 | pageSize = PAGE_SIZE,
31 | enablePlaceholders = false
32 | )
33 | ) {
34 | OfficialPagingSource(query.cid)
35 | }.flow
36 |
37 | }
--------------------------------------------------------------------------------
/ten/src/main/java/com/zj/play/ui/page/official/OfficialViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.zj.play.ui.page.official
2 |
3 | import android.app.Application
4 | import com.zj.play.logic.base.repository.BaseArticlePagingRepository
5 | import com.zj.play.logic.base.viewmodel.BaseViewModel
6 |
7 | /**
8 | * 版权:Zhujiang 个人版权
9 | * @author zhujiang
10 | * 版本:1.5
11 | * 创建日期:2021/5/17
12 | * 描述:PlayAndroid
13 | *
14 | */
15 | class OfficialViewModel(application: Application) : BaseViewModel(application) {
16 |
17 | override val repositoryArticle: BaseArticlePagingRepository
18 | get() = OfficialRepository(getApplication())
19 |
20 | override suspend fun getData() {
21 | (repositoryArticle as OfficialRepository).getTree(mutableTreeLiveData)
22 | }
23 |
24 | }
--------------------------------------------------------------------------------
/ten/src/main/java/com/zj/play/ui/page/project/ProjectRepository.kt:
--------------------------------------------------------------------------------
1 | package com.zj.play.ui.page.project
2 |
3 | import android.app.Application
4 | import androidx.paging.ExperimentalPagingApi
5 | import androidx.paging.Pager
6 | import androidx.paging.PagingConfig
7 | import com.zj.play.logic.base.paging.ProjectPagingSource
8 | import com.zj.play.logic.base.repository.BaseArticleRepository
9 | import com.zj.play.logic.model.BaseModel
10 | import com.zj.play.logic.model.ClassifyModel
11 | import com.zj.play.logic.model.Query
12 | import com.zj.play.logic.network.PlayAndroidNetwork
13 |
14 | /**
15 | * 版权:Zhujiang 个人版权
16 | *
17 | * @author zhujiang
18 | * 创建日期:2021/9/10
19 | * 描述:PlayAndroid
20 | *
21 | */
22 |
23 | class ProjectRepository constructor(val application: Application) :
24 | BaseArticleRepository(application = application) {
25 |
26 | override suspend fun getArticleTree(): BaseModel> {
27 | return PlayAndroidNetwork.getProjectTree()
28 | }
29 |
30 | override fun getPagingData(query: Query) = Pager(
31 | PagingConfig(
32 | pageSize = PAGE_SIZE,
33 | enablePlaceholders = false
34 | )
35 | ) {
36 | ProjectPagingSource(query.cid)
37 | }.flow
38 |
39 | }
--------------------------------------------------------------------------------
/ten/src/main/java/com/zj/play/ui/page/project/ProjectViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.zj.play.ui.page.project
2 |
3 | import android.app.Application
4 | import com.zj.play.logic.base.repository.BaseArticlePagingRepository
5 | import com.zj.play.logic.base.viewmodel.BaseViewModel
6 |
7 | /**
8 | * 版权:Zhujiang 个人版权
9 | * @author zhujiang
10 | * 版本:1.5
11 | * 创建日期:2021/5/17
12 | * 描述:PlayAndroid
13 | *
14 | */
15 | class ProjectViewModel(application: Application) : BaseViewModel(application) {
16 |
17 | override val repositoryArticle: BaseArticlePagingRepository
18 | get() = ProjectRepository(getApplication())
19 |
20 | override suspend fun getData() {
21 | (repositoryArticle as ProjectRepository).getTree(mutableTreeLiveData)
22 | }
23 |
24 | }
--------------------------------------------------------------------------------
/ten/src/main/java/com/zj/play/ui/theme/Color.kt:
--------------------------------------------------------------------------------
1 | package com.zj.play.ui.theme
2 |
3 | import androidx.compose.ui.graphics.Color
4 |
5 | val purple200 = Color(0xFFBB86FC)
6 | val purple500 = Color(0xFF6200EE)
7 | val purple700 = Color(0xFF3700B3)
8 | val teal200 = Color(0xFF03DAC5)
9 |
10 | val pink100 = Color(0xFFFFF1F1)
11 | val pink900 = Color(0xFF3f2c2c)
12 | val gray = Color(0xFF232323)
13 | val white = Color.White
14 | val whit850 = Color.White.copy(alpha = .85f)
15 | val whit150 = Color.White.copy(alpha = .15f)
16 | val green900 = Color(0xFF2d3b2d)
17 | val green300 = Color(0xFFb8c9b8)
--------------------------------------------------------------------------------
/ten/src/main/java/com/zj/play/ui/theme/Shape.kt:
--------------------------------------------------------------------------------
1 | package com.zj.play.ui.theme
2 |
3 | import androidx.compose.foundation.shape.RoundedCornerShape
4 | import androidx.compose.material.Shapes
5 | import androidx.compose.ui.unit.dp
6 |
7 | val Shapes = Shapes(
8 | small = RoundedCornerShape(4.dp),
9 | medium = RoundedCornerShape(4.dp),
10 | large = RoundedCornerShape(0.dp)
11 | )
--------------------------------------------------------------------------------
/ten/src/main/java/com/zj/play/ui/view/edit/EmailState.kt:
--------------------------------------------------------------------------------
1 | package com.zj.play.ui.view.edit
2 |
3 | import java.util.regex.Pattern
4 |
5 | private const val EMAIL_VALIDATION_REGEX = "^[A-Za-z0-9]{6,}"
6 |
7 | class EmailState :
8 | TextFieldState(validator = ::isEmailValid, errorFor = ::emailValidationError)
9 |
10 | /**
11 | * Returns an error to be displayed or null if no error was found
12 | */
13 | private fun emailValidationError(email: String): String {
14 | return "error: $email"
15 | }
16 |
17 | private fun isEmailValid(email: String): Boolean {
18 | return Pattern.matches(EMAIL_VALIDATION_REGEX, email)
19 | }
20 |
--------------------------------------------------------------------------------
/ten/src/main/java/com/zj/play/ui/view/edit/PasswordState.kt:
--------------------------------------------------------------------------------
1 | package com.zj.play.ui.view.edit
2 |
3 | import java.util.regex.Pattern
4 |
5 | private const val PASSWORD_VALIDATION_REGEX = "^[A-Za-z0-9]{6,}"
6 |
7 | class PasswordState :
8 | TextFieldState(validator = ::isPasswordValid, errorFor = ::passwordValidationError)
9 |
10 | private fun isPasswordValid(password: String): Boolean {
11 | return Pattern.matches(PASSWORD_VALIDATION_REGEX, password)
12 | }
13 |
14 | @Suppress("UNUSED_PARAMETER")
15 | private fun passwordValidationError(password: String): String {
16 | return "error"
17 | }
--------------------------------------------------------------------------------
/ten/src/main/java/com/zj/play/ui/view/edit/TextFieldState.kt:
--------------------------------------------------------------------------------
1 | package com.zj.play.ui.view.edit
2 |
3 | import androidx.compose.runtime.getValue
4 | import androidx.compose.runtime.mutableStateOf
5 | import androidx.compose.runtime.setValue
6 |
7 | open class TextFieldState(
8 | private val validator: (String) -> Boolean = { true },
9 | private val errorFor: (String) -> String = { "" }
10 | ) {
11 | var text: String by mutableStateOf("")
12 | var isFocusedDirty: Boolean by mutableStateOf(false)
13 | var isFocused: Boolean by mutableStateOf(false)
14 | private var displayErrors: Boolean by mutableStateOf(false)
15 |
16 | open val isValid: Boolean
17 | get() = validator(text)
18 |
19 | fun onFocusChange(focused: Boolean) {
20 | isFocused = focused
21 | if (focused) isFocusedDirty = true
22 | }
23 |
24 | fun enableShowErrors() {
25 | if (isFocusedDirty) {
26 | displayErrors = true
27 | }
28 | }
29 |
30 | fun showErrors() = !isValid && displayErrors
31 |
32 | open fun getError(): String? {
33 | return if (showErrors()) {
34 | errorFor(text)
35 | } else {
36 | null
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/ten/src/main/java/com/zj/play/ui/view/lce/LcePage.kt:
--------------------------------------------------------------------------------
1 | package com.zj.play.ui.view.lce
2 |
3 | import androidx.compose.runtime.Composable
4 | import com.zj.play.logic.model.*
5 |
6 |
7 | @Composable
8 | fun LcePage(
9 | playState: PlayState,
10 | onErrorClick: () -> Unit,
11 | content: @Composable (data: T) -> Unit
12 | ) {
13 | when (playState) {
14 | is PlayLoading -> {
15 | LoadingContent()
16 | }
17 | is PlayError -> {
18 | ErrorContent(onErrorClick = onErrorClick)
19 | }
20 | is PlaySuccess -> {
21 | content(playState.data)
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/ten/src/main/java/com/zj/play/ui/view/lce/NoContent.kt:
--------------------------------------------------------------------------------
1 | package com.zj.play.ui.view.lce
2 |
3 | import androidx.compose.foundation.Image
4 | import androidx.compose.foundation.layout.Arrangement
5 | import androidx.compose.foundation.layout.Column
6 | import androidx.compose.foundation.layout.fillMaxSize
7 | import androidx.compose.foundation.layout.padding
8 | import androidx.compose.material.Text
9 | import androidx.compose.runtime.Composable
10 | import androidx.compose.ui.Alignment
11 | import androidx.compose.ui.Modifier
12 | import androidx.compose.ui.res.painterResource
13 | import androidx.compose.ui.unit.dp
14 | import com.zj.play.R
15 |
16 | @Composable
17 | fun NoContent(tip: String = "当前无内容") {
18 | Column(
19 | modifier = Modifier.fillMaxSize(), verticalArrangement = Arrangement.Center,
20 | horizontalAlignment = Alignment.CenterHorizontally
21 | ) {
22 | Image(
23 | modifier = Modifier.padding(vertical = 50.dp),
24 | painter = painterResource(id = R.drawable.no_content_image),
25 | contentDescription = "网络加载失败"
26 | )
27 | Text(text = tip, modifier = Modifier.padding(10.dp))
28 | }
29 | }
--------------------------------------------------------------------------------
/ten/src/main/res/anim/activity_push_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
--------------------------------------------------------------------------------
/ten/src/main/res/anim/activity_push_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
--------------------------------------------------------------------------------
/ten/src/main/res/anim/center_zoom_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 |
13 |
17 |
18 |
--------------------------------------------------------------------------------
/ten/src/main/res/anim/center_zoom_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 |
13 |
17 |
18 |
--------------------------------------------------------------------------------
/ten/src/main/res/drawable-xxhdpi/img_default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/ten/src/main/res/drawable-xxhdpi/img_default.png
--------------------------------------------------------------------------------
/ten/src/main/res/drawable-xxhdpi/img_head.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/ten/src/main/res/drawable-xxhdpi/img_head.jpeg
--------------------------------------------------------------------------------
/ten/src/main/res/drawable-xxxhdpi/ic_nav_discover_actived.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/ten/src/main/res/drawable-xxxhdpi/ic_nav_discover_actived.png
--------------------------------------------------------------------------------
/ten/src/main/res/drawable-xxxhdpi/ic_nav_discover_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/ten/src/main/res/drawable-xxxhdpi/ic_nav_discover_normal.png
--------------------------------------------------------------------------------
/ten/src/main/res/drawable-xxxhdpi/ic_nav_my_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/ten/src/main/res/drawable-xxxhdpi/ic_nav_my_normal.png
--------------------------------------------------------------------------------
/ten/src/main/res/drawable-xxxhdpi/ic_nav_my_pressed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/ten/src/main/res/drawable-xxxhdpi/ic_nav_my_pressed.png
--------------------------------------------------------------------------------
/ten/src/main/res/drawable-xxxhdpi/ic_nav_news_actived.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/ten/src/main/res/drawable-xxxhdpi/ic_nav_news_actived.png
--------------------------------------------------------------------------------
/ten/src/main/res/drawable-xxxhdpi/ic_nav_news_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/ten/src/main/res/drawable-xxxhdpi/ic_nav_news_normal.png
--------------------------------------------------------------------------------
/ten/src/main/res/drawable-xxxhdpi/ic_nav_tweet_actived.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/ten/src/main/res/drawable-xxxhdpi/ic_nav_tweet_actived.png
--------------------------------------------------------------------------------
/ten/src/main/res/drawable-xxxhdpi/ic_nav_tweet_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/ten/src/main/res/drawable-xxxhdpi/ic_nav_tweet_normal.png
--------------------------------------------------------------------------------
/ten/src/main/res/drawable/color_progressbar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | -
6 |
7 |
8 |
14 |
15 |
16 |
17 |
18 | -
19 |
20 |
21 |
22 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/ten/src/main/res/drawable/ic_baseline_bookmark_24.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ten/src/main/res/drawable/ic_baseline_bookmark_border_24.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ten/src/main/res/drawable/ic_baseline_visibility_24.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ten/src/main/res/drawable/ic_baseline_visibility_off_24.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ten/src/main/res/drawable/img_to_top_nomal.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/ten/src/main/res/drawable/loading_animation.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
7 |
10 |
13 |
16 |
--------------------------------------------------------------------------------
/ten/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/ten/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/ten/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/ten/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/ten/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/ten/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/ten/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/ten/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/ten/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/ten/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/ten/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/ten/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/ten/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/ten/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/ten/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/ten/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/ten/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/ten/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/ten/src/main/res/values-night/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | #000000
5 | #151515
6 | #000000
7 |
8 |
--------------------------------------------------------------------------------
/ten/src/main/res/values-night/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/ten/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFBB86FC
4 | #FF6200EE
5 | #FF3700B3
6 | #FF03DAC5
7 | #FF018786
8 | #FF000000
9 | #FFFFFFFF
10 |
11 | #FFFFFF
12 | #F8F8F8
13 | #FFFFFF
14 |
15 |
--------------------------------------------------------------------------------
/ten/src/main/res/values/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #171825
4 |
--------------------------------------------------------------------------------
/ten/src/test/java/com/zj/play/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.zj.play
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------
/three/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/three/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/three/src/androidTest/java/com/zj/three/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.zj.three
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("com.zj.three", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/three/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/three/src/main/java/com/zj/three/CustomLayout.kt:
--------------------------------------------------------------------------------
1 | package com.zj.three
2 |
3 | import androidx.compose.runtime.Composable
4 | import androidx.compose.ui.tooling.preview.Preview
5 |
6 | @Composable
7 | fun CustomLayout() {
8 |
9 | }
10 |
11 | @Preview(showBackground = true)
12 | @Composable
13 | fun CustomLayoutPreview() {
14 | CustomLayout()
15 | }
--------------------------------------------------------------------------------
/three/src/main/java/com/zj/three/one/Row.kt:
--------------------------------------------------------------------------------
1 | package com.zj.three.one
2 |
3 | import androidx.compose.foundation.layout.Arrangement
4 | import androidx.compose.foundation.layout.Row
5 | import androidx.compose.foundation.layout.fillMaxSize
6 | import androidx.compose.material.Text
7 | import androidx.compose.runtime.Composable
8 | import androidx.compose.ui.Alignment
9 | import androidx.compose.ui.Modifier
10 | import androidx.compose.ui.unit.sp
11 |
12 | @Composable
13 | fun RowTest() {
14 | Row(
15 | modifier = Modifier.fillMaxSize(),
16 | horizontalArrangement = Arrangement.Center,
17 | verticalAlignment = Alignment.CenterVertically,
18 | ) {
19 | Text("1",fontSize = 40.sp)
20 | Text("2",fontSize = 40.sp)
21 | Text("3",fontSize = 40.sp)
22 | }
23 | }
--------------------------------------------------------------------------------
/three/src/main/java/com/zj/three/ui/theme/Color.kt:
--------------------------------------------------------------------------------
1 | package com.zj.three.ui.theme
2 |
3 | import androidx.compose.ui.graphics.Color
4 |
5 | val Purple200 = Color(0xFFBB86FC)
6 | val Purple500 = Color(0xFF6200EE)
7 | val Purple700 = Color(0xFF3700B3)
8 | val Teal200 = Color(0xFF03DAC5)
--------------------------------------------------------------------------------
/three/src/main/java/com/zj/three/ui/theme/Shape.kt:
--------------------------------------------------------------------------------
1 | package com.zj.three.ui.theme
2 |
3 | import androidx.compose.foundation.shape.RoundedCornerShape
4 | import androidx.compose.material.Shapes
5 | import androidx.compose.ui.unit.dp
6 |
7 | val Shapes = Shapes(
8 | small = RoundedCornerShape(4.dp),
9 | medium = RoundedCornerShape(8.dp),
10 | large = RoundedCornerShape(0.dp)
11 | )
--------------------------------------------------------------------------------
/three/src/main/java/com/zj/three/ui/theme/Theme.kt:
--------------------------------------------------------------------------------
1 | package com.zj.three.ui.theme
2 |
3 | import androidx.compose.foundation.isSystemInDarkTheme
4 | import androidx.compose.material.MaterialTheme
5 | import androidx.compose.material.darkColors
6 | import androidx.compose.material.lightColors
7 | import androidx.compose.runtime.Composable
8 |
9 | private val DarkColorPalette = darkColors(
10 | primary = Purple200,
11 | primaryVariant = Purple700,
12 | secondary = Teal200
13 | )
14 |
15 | private val LightColorPalette = lightColors(
16 | primary = Purple500,
17 | primaryVariant = Purple700,
18 | secondary = Teal200
19 |
20 | /* Other default colors to override
21 | background = Color.White,
22 | surface = Color.White,
23 | onPrimary = Color.White,
24 | onSecondary = Color.Black,
25 | onBackground = Color.Black,
26 | onSurface = Color.Black,
27 | */
28 | )
29 |
30 | @Composable
31 | fun ThreeTheme(darkTheme: Boolean = isSystemInDarkTheme(), content: @Composable() () -> Unit) {
32 | val colors = if (darkTheme) {
33 | DarkColorPalette
34 | } else {
35 | LightColorPalette
36 | }
37 |
38 | MaterialTheme(
39 | colors = colors,
40 | typography = Typography,
41 | shapes = Shapes,
42 | content = content
43 | )
44 | }
--------------------------------------------------------------------------------
/three/src/main/java/com/zj/three/ui/theme/Type.kt:
--------------------------------------------------------------------------------
1 | package com.zj.three.ui.theme
2 |
3 | import androidx.compose.material.Typography
4 | import androidx.compose.ui.text.TextStyle
5 | import androidx.compose.ui.text.font.FontFamily
6 | import androidx.compose.ui.text.font.FontWeight
7 | import androidx.compose.ui.unit.sp
8 |
9 | // Set of Material typography styles to start with
10 | val Typography = Typography(
11 | body1 = TextStyle(
12 | fontFamily = FontFamily.Default,
13 | fontWeight = FontWeight.Normal,
14 | fontSize = 16.sp
15 | )
16 | /* Other default text styles to override
17 | button = TextStyle(
18 | fontFamily = FontFamily.Default,
19 | fontWeight = FontWeight.W500,
20 | fontSize = 14.sp
21 | ),
22 | caption = TextStyle(
23 | fontFamily = FontFamily.Default,
24 | fontWeight = FontWeight.Normal,
25 | fontSize = 12.sp
26 | )
27 | */
28 | )
--------------------------------------------------------------------------------
/three/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
17 |
18 |
22 |
23 |
--------------------------------------------------------------------------------
/three/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/three/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/three/src/main/res/mipmap-hdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/three/src/main/res/mipmap-hdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/three/src/main/res/mipmap-hdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/three/src/main/res/mipmap-hdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/three/src/main/res/mipmap-mdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/three/src/main/res/mipmap-mdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/three/src/main/res/mipmap-mdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/three/src/main/res/mipmap-mdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/three/src/main/res/mipmap-xhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/three/src/main/res/mipmap-xhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/three/src/main/res/mipmap-xhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/three/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/three/src/main/res/mipmap-xxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/three/src/main/res/mipmap-xxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/three/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/three/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/three/src/main/res/mipmap-xxxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/three/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/three/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/three/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/three/src/main/res/values-night/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/three/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFBB86FC
4 | #FF6200EE
5 | #FF3700B3
6 | #FF03DAC5
7 | #FF018786
8 | #FF000000
9 | #FFFFFFFF
10 |
--------------------------------------------------------------------------------
/three/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Three
3 |
--------------------------------------------------------------------------------
/three/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
17 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/three/src/test/java/com/zj/three/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.zj.three
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------
/two/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/two/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/two/src/androidTest/java/com/zj/two/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.zj.two
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("com.zj.two", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/two/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/two/src/main/java/com/zj/two/Restructuring.kt:
--------------------------------------------------------------------------------
1 | package com.zj.two
2 |
3 | import androidx.compose.foundation.clickable
4 | import androidx.compose.foundation.layout.Column
5 | import androidx.compose.foundation.layout.fillMaxSize
6 | import androidx.compose.foundation.lazy.LazyColumn
7 | import androidx.compose.foundation.lazy.items
8 | import androidx.compose.material.Divider
9 | import androidx.compose.material.MaterialTheme
10 | import androidx.compose.material.Text
11 | import androidx.compose.runtime.Composable
12 | import androidx.compose.ui.Modifier
13 |
14 | @Composable
15 | fun NamePicker(
16 | header: String,
17 | names: List,
18 | onNameClicked: (String) -> Unit
19 | ) {
20 | Column {
21 | Text(header, style = MaterialTheme.typography.h5)
22 | Divider()
23 | LazyColumn(modifier = Modifier.fillMaxSize()) {
24 | items(names) { name ->
25 | NamePickerItem(name, onNameClicked)
26 | }
27 | }
28 | }
29 | }
30 |
31 | @Composable
32 | private fun NamePickerItem(name: String, onClicked: (String) -> Unit) {
33 | Text(name, Modifier.clickable(onClick = { onClicked(name) }))
34 | }
--------------------------------------------------------------------------------
/two/src/main/java/com/zj/two/ui/theme/Color.kt:
--------------------------------------------------------------------------------
1 | package com.zj.two.ui.theme
2 |
3 | import androidx.compose.ui.graphics.Color
4 |
5 | val Purple200 = Color(0xFFBB86FC)
6 | val Purple500 = Color(0xFF6200EE)
7 | val Purple700 = Color(0xFF3700B3)
8 | val Teal200 = Color(0xFF03DAC5)
--------------------------------------------------------------------------------
/two/src/main/java/com/zj/two/ui/theme/Shape.kt:
--------------------------------------------------------------------------------
1 | package com.zj.two.ui.theme
2 |
3 | import androidx.compose.foundation.shape.RoundedCornerShape
4 | import androidx.compose.material.Shapes
5 | import androidx.compose.ui.unit.dp
6 |
7 | val Shapes = Shapes(
8 | small = RoundedCornerShape(4.dp),
9 | medium = RoundedCornerShape(4.dp),
10 | large = RoundedCornerShape(0.dp)
11 | )
--------------------------------------------------------------------------------
/two/src/main/java/com/zj/two/ui/theme/Theme.kt:
--------------------------------------------------------------------------------
1 | package com.zj.two.ui.theme
2 |
3 | import androidx.compose.foundation.isSystemInDarkTheme
4 | import androidx.compose.material.MaterialTheme
5 | import androidx.compose.material.darkColors
6 | import androidx.compose.material.lightColors
7 | import androidx.compose.runtime.Composable
8 |
9 | private val DarkColorPalette = darkColors(
10 | primary = Purple200,
11 | primaryVariant = Purple700,
12 | secondary = Teal200
13 | )
14 |
15 | private val LightColorPalette = lightColors(
16 | primary = Purple500,
17 | primaryVariant = Purple700,
18 | secondary = Teal200
19 |
20 | /* Other default colors to override
21 | background = Color.White,
22 | surface = Color.White,
23 | onPrimary = Color.White,
24 | onSecondary = Color.Black,
25 | onBackground = Color.Black,
26 | onSurface = Color.Black,
27 | */
28 | )
29 |
30 | @Composable
31 | fun TwoTheme(darkTheme: Boolean = isSystemInDarkTheme(), content: @Composable() () -> Unit) {
32 | val colors = if (darkTheme) {
33 | DarkColorPalette
34 | } else {
35 | LightColorPalette
36 | }
37 |
38 | MaterialTheme(
39 | colors = colors,
40 | typography = Typography,
41 | shapes = Shapes,
42 | content = content
43 | )
44 | }
--------------------------------------------------------------------------------
/two/src/main/java/com/zj/two/ui/theme/Type.kt:
--------------------------------------------------------------------------------
1 | package com.zj.two.ui.theme
2 |
3 | import androidx.compose.material.Typography
4 | import androidx.compose.ui.text.TextStyle
5 | import androidx.compose.ui.text.font.FontFamily
6 | import androidx.compose.ui.text.font.FontWeight
7 | import androidx.compose.ui.unit.sp
8 |
9 | // Set of Material typography styles to start with
10 | val Typography = Typography(
11 | body1 = TextStyle(
12 | fontFamily = FontFamily.Default,
13 | fontWeight = FontWeight.Normal,
14 | fontSize = 16.sp
15 | )
16 | /* Other default text styles to override
17 | button = TextStyle(
18 | fontFamily = FontFamily.Default,
19 | fontWeight = FontWeight.W500,
20 | fontSize = 14.sp
21 | ),
22 | caption = TextStyle(
23 | fontFamily = FontFamily.Default,
24 | fontWeight = FontWeight.Normal,
25 | fontSize = 12.sp
26 | )
27 | */
28 | )
--------------------------------------------------------------------------------
/two/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/two/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/two/src/main/res/mipmap-hdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/two/src/main/res/mipmap-hdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/two/src/main/res/mipmap-hdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/two/src/main/res/mipmap-hdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/two/src/main/res/mipmap-mdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/two/src/main/res/mipmap-mdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/two/src/main/res/mipmap-mdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/two/src/main/res/mipmap-mdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/two/src/main/res/mipmap-xhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/two/src/main/res/mipmap-xhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/two/src/main/res/mipmap-xhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/two/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/two/src/main/res/mipmap-xxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/two/src/main/res/mipmap-xxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/two/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/two/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/two/src/main/res/mipmap-xxxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/two/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/two/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhujiang521/ComposeBookSource/13d2345c3007a5cb023f7cdb533ae9ab39b6f3d6/two/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/two/src/main/res/values-night/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/two/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFBB86FC
4 | #FF6200EE
5 | #FF3700B3
6 | #FF03DAC5
7 | #FF018786
8 | #FF000000
9 | #FFFFFFFF
10 |
--------------------------------------------------------------------------------
/two/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Two
3 |
--------------------------------------------------------------------------------
/two/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
17 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/two/src/test/java/com/zj/two/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.zj.two
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------