├── app ├── .gitignore ├── debug.keystore ├── src │ └── main │ │ ├── res │ │ ├── values │ │ │ ├── strings.xml │ │ │ ├── ic_launcher_background.xml │ │ │ ├── colors.xml │ │ │ └── themes.xml │ │ ├── drawable-hdpi │ │ │ ├── ic_launcher.webp │ │ │ ├── ic_launcher_round.webp │ │ │ └── ic_launcher_foreground.webp │ │ ├── drawable-xxhdpi │ │ │ ├── android_q.webp │ │ │ ├── ic_launcher.webp │ │ │ ├── ic_launcher_round.webp │ │ │ └── ic_launcher_foreground.webp │ │ ├── drawable-xhdpi │ │ │ ├── ic_launcher.webp │ │ │ ├── ic_launcher_round.webp │ │ │ └── ic_launcher_foreground.webp │ │ ├── drawable-xxxhdpi │ │ │ ├── ic_launcher.webp │ │ │ ├── ic_launcher_round.webp │ │ │ └── ic_launcher_foreground.webp │ │ ├── drawable-anydpi-v26 │ │ │ ├── ic_launcher.xml │ │ │ └── ic_launcher_round.xml │ │ ├── drawable │ │ │ ├── ic_tab_my_fill.xml │ │ │ ├── ic_back.xml │ │ │ ├── ic_tab_home_fill.xml │ │ │ ├── ic_like_fill.xml │ │ │ ├── ic_arrow_right.xml │ │ │ ├── ic_close.xml │ │ │ ├── ic_tab_my.xml │ │ │ ├── ic_tab_home.xml │ │ │ ├── ic_search.xml │ │ │ ├── ic_like.xml │ │ │ ├── ic_share.xml │ │ │ ├── ic_tab_discover_fill.xml │ │ │ ├── ic_tab_wechat_fill.xml │ │ │ ├── ic_tab_discover.xml │ │ │ ├── ic_tab_wechat.xml │ │ │ └── ic_launcher_background.xml │ │ ├── values-night │ │ │ └── themes.xml │ │ └── drawable-v24 │ │ │ └── ic_launcher_foreground.xml │ │ ├── ic_launcher-playstore.png │ │ ├── java │ │ └── top │ │ │ └── wangchenyan │ │ │ └── wancompose │ │ │ ├── ui │ │ │ ├── wechat │ │ │ │ ├── model │ │ │ │ │ └── WeChatData.kt │ │ │ │ ├── viewmodel │ │ │ │ │ ├── WeChatViewModel.kt │ │ │ │ │ └── WeChatTabViewModel.kt │ │ │ │ └── WeChat.kt │ │ │ ├── search │ │ │ │ ├── model │ │ │ │ │ └── SearchData.kt │ │ │ │ ├── viewmodel │ │ │ │ │ ├── SearchViewModel.kt │ │ │ │ │ └── SearchResultViewModel.kt │ │ │ │ ├── SearchResult.kt │ │ │ │ └── Search.kt │ │ │ ├── web │ │ │ │ ├── viewmodel │ │ │ │ │ └── WebViewModel.kt │ │ │ │ └── Web.kt │ │ │ ├── home │ │ │ │ ├── model │ │ │ │ │ ├── HomeData.kt │ │ │ │ │ └── ArticleData.kt │ │ │ │ ├── viewmodel │ │ │ │ │ └── HomeViewModel.kt │ │ │ │ └── Home.kt │ │ │ ├── MainActivity.kt │ │ │ ├── mine │ │ │ │ ├── viewmodel │ │ │ │ │ ├── MineViewModel.kt │ │ │ │ │ ├── LoginViewModel.kt │ │ │ │ │ ├── RegisterViewModel.kt │ │ │ │ │ └── CollectViewModel.kt │ │ │ │ ├── CollectList.kt │ │ │ │ ├── Login.kt │ │ │ │ ├── Register.kt │ │ │ │ └── Mine.kt │ │ │ ├── Main.kt │ │ │ └── square │ │ │ │ ├── Square.kt │ │ │ │ └── viewmodel │ │ │ │ └── SquareViewModel.kt │ │ │ ├── storage │ │ │ ├── AppPreferences.kt │ │ │ ├── HistoryPreferences.kt │ │ │ └── PreferencesDataStore.kt │ │ │ ├── theme │ │ │ ├── Color.kt │ │ │ ├── Type.kt │ │ │ └── Theme.kt │ │ │ ├── auth │ │ │ ├── UserData.kt │ │ │ └── AuthManager.kt │ │ │ ├── WanApplication.kt │ │ │ ├── Navigation.kt │ │ │ ├── widget │ │ │ ├── PageLoading.kt │ │ │ ├── TitleLayout.kt │ │ │ ├── BottomTab.kt │ │ │ └── Banner.kt │ │ │ └── api │ │ │ └── Api.kt │ │ └── AndroidManifest.xml ├── proguard-rules.pro └── build.gradle.kts ├── art ├── qrcode.png ├── screenshot01.jpg └── screenshot02.jpg ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── settings.gradle.kts ├── README.md ├── gradle.properties ├── gradlew.bat ├── gradlew └── LICENSE /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /art/qrcode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangchenyan/wan-compose/HEAD/art/qrcode.png -------------------------------------------------------------------------------- /app/debug.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangchenyan/wan-compose/HEAD/app/debug.keystore -------------------------------------------------------------------------------- /art/screenshot01.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangchenyan/wan-compose/HEAD/art/screenshot01.jpg -------------------------------------------------------------------------------- /art/screenshot02.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangchenyan/wan-compose/HEAD/art/screenshot02.jpg -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 玩Compose 3 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangchenyan/wan-compose/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/ic_launcher-playstore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangchenyan/wan-compose/HEAD/app/src/main/ic_launcher-playstore.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangchenyan/wan-compose/HEAD/app/src/main/res/drawable-hdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/android_q.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangchenyan/wan-compose/HEAD/app/src/main/res/drawable-xxhdpi/android_q.webp -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangchenyan/wan-compose/HEAD/app/src/main/res/drawable-xhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangchenyan/wan-compose/HEAD/app/src/main/res/drawable-xxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangchenyan/wan-compose/HEAD/app/src/main/res/drawable-xxxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangchenyan/wan-compose/HEAD/app/src/main/res/drawable-hdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangchenyan/wan-compose/HEAD/app/src/main/res/drawable-xhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea 5 | .DS_Store 6 | /build 7 | /captures 8 | .externalNativeBuild 9 | .cxx 10 | local.properties 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangchenyan/wan-compose/HEAD/app/src/main/res/drawable-xxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangchenyan/wan-compose/HEAD/app/src/main/res/drawable-xxxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_launcher_foreground.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangchenyan/wan-compose/HEAD/app/src/main/res/drawable-hdpi/ic_launcher_foreground.webp -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_launcher_foreground.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangchenyan/wan-compose/HEAD/app/src/main/res/drawable-xhdpi/ic_launcher_foreground.webp -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_launcher_foreground.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangchenyan/wan-compose/HEAD/app/src/main/res/drawable-xxhdpi/ic_launcher_foreground.webp -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_launcher_foreground.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangchenyan/wan-compose/HEAD/app/src/main/res/drawable-xxxhdpi/ic_launcher_foreground.webp -------------------------------------------------------------------------------- /app/src/main/res/values/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFFFFF 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Mar 30 20:56:37 CST 2021 2 | distributionBase=GRADLE_USER_HOME 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /app/src/main/java/top/wangchenyan/wancompose/ui/wechat/model/WeChatData.kt: -------------------------------------------------------------------------------- 1 | package top.wangchenyan.wancompose.ui.wechat.model 2 | 3 | import com.google.gson.annotations.SerializedName 4 | 5 | data class WeChatAuthor( 6 | @SerializedName("id") val id: Long = 0, 7 | @SerializedName("name") val name: String = "" 8 | ) -------------------------------------------------------------------------------- /app/src/main/res/drawable-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/java/top/wangchenyan/wancompose/ui/search/model/SearchData.kt: -------------------------------------------------------------------------------- 1 | package top.wangchenyan.wancompose.ui.search.model 2 | 3 | import com.google.gson.annotations.SerializedName 4 | 5 | data class HotKey( 6 | @SerializedName("id") val id: Long = 0, 7 | @SerializedName("link") val link: String = "", 8 | @SerializedName("name") val name: String = "" 9 | ) -------------------------------------------------------------------------------- /app/src/main/java/top/wangchenyan/wancompose/ui/web/viewmodel/WebViewModel.kt: -------------------------------------------------------------------------------- 1 | package top.wangchenyan.wancompose.ui.web.viewmodel 2 | 3 | import androidx.compose.runtime.getValue 4 | import androidx.compose.runtime.mutableStateOf 5 | import androidx.compose.runtime.setValue 6 | import androidx.lifecycle.ViewModel 7 | 8 | class WebViewModel : ViewModel() { 9 | var title by mutableStateOf("加载中...") 10 | var progress by mutableStateOf(0) 11 | } -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | google() 4 | mavenCentral() 5 | gradlePluginPortal() 6 | } 7 | } 8 | dependencyResolutionManagement { 9 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) 10 | repositories { 11 | google() 12 | mavenCentral() 13 | maven("https://maven.aliyun.com/repository/public/") 14 | maven("https://jitpack.io") 15 | } 16 | } 17 | 18 | rootProject.name = "wan-compose" 19 | include(":app") 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # wan-compose 2 | 3 | Jetpack Compose 版本的「玩 Android」 4 | 5 | ## 环境 6 | - AndroidStudio: Arctic Fox | 2020.3.1 7 | 8 | ## 功能 9 | - 登录、注册 10 | - 等级、排名、积分、收藏 11 | - 首页、搜索 12 | - 广场 13 | - 公众号 14 | 15 | ## 下载体验 16 | ![](https://raw.githubusercontent.com/wangchenyan/wan-compose/master/art/qrcode.png) 17 | 18 | https://github.com/wangchenyan/wan-compose/releases 19 | 20 | ## 截图 21 | ![](https://raw.githubusercontent.com/wangchenyan/wan-compose/master/art/screenshot01.jpg) 22 | 23 | ![](https://raw.githubusercontent.com/wangchenyan/wan-compose/master/art/screenshot02.jpg) 24 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFBB86FC 4 | #FF6200EE 5 | #FF3700B3 6 | #FF03DAC5 7 | #FF018786 8 | #FF000000 9 | #FFFFFFFF 10 | #FF43A047 11 | #FFFAFAFA 12 | #FFFAFAFA 13 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_tab_my_fill.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_back.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 11 | -------------------------------------------------------------------------------- /app/src/main/java/top/wangchenyan/wancompose/storage/AppPreferences.kt: -------------------------------------------------------------------------------- 1 | package top.wangchenyan.wancompose.storage 2 | 3 | import androidx.datastore.preferences.core.stringPreferencesKey 4 | import top.wangchenyan.common.CommonApp 5 | import top.wangchenyan.wancompose.auth.User 6 | 7 | object AppPreferences { 8 | private val KEY_USER = stringPreferencesKey("user") 9 | 10 | private val dataStore by lazy { 11 | PreferencesDataStore(CommonApp.app, CommonApp.app.packageName + ".app") 12 | } 13 | 14 | suspend fun getUser(): User? { 15 | return dataStore.getModel(KEY_USER) 16 | } 17 | 18 | suspend fun setUser(user: User?) { 19 | dataStore.putModel(KEY_USER, user) 20 | } 21 | } -------------------------------------------------------------------------------- /app/src/main/java/top/wangchenyan/wancompose/ui/home/model/HomeData.kt: -------------------------------------------------------------------------------- 1 | package top.wangchenyan.wancompose.ui.home.model 2 | 3 | import com.google.gson.annotations.SerializedName 4 | 5 | 6 | /** 7 | * Created by wcy on 2021/4/1. 8 | */ 9 | 10 | data class HomeBannerData( 11 | @SerializedName("id") val id: Long = 0, 12 | @SerializedName("desc") val desc: String = "", 13 | @SerializedName("imagePath") val imagePath: String = "", 14 | @SerializedName("isVisible") val isVisible: Int = 0, 15 | @SerializedName("order") val order: Int = 0, 16 | @SerializedName("title") val title: String = "", 17 | @SerializedName("type") val type: Int = 0, 18 | @SerializedName("url") val url: String = "" 19 | ) 20 | -------------------------------------------------------------------------------- /app/src/main/java/top/wangchenyan/wancompose/ui/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package top.wangchenyan.wancompose.ui 2 | 3 | import android.os.Bundle 4 | import androidx.activity.ComponentActivity 5 | import androidx.activity.compose.setContent 6 | import com.google.accompanist.pager.ExperimentalPagerApi 7 | import top.wangchenyan.wancompose.ComposeNavigation 8 | import top.wangchenyan.wancompose.theme.WanandroidTheme 9 | 10 | class MainActivity : ComponentActivity() { 11 | @ExperimentalPagerApi 12 | override fun onCreate(savedInstanceState: Bundle?) { 13 | super.onCreate(savedInstanceState) 14 | setContent { 15 | WanandroidTheme { 16 | ComposeNavigation() 17 | } 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_tab_home_fill.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_like_fill.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 11 | -------------------------------------------------------------------------------- /app/src/main/java/top/wangchenyan/wancompose/theme/Color.kt: -------------------------------------------------------------------------------- 1 | package top.wangchenyan.wancompose.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 | object Colors { 11 | val white = Color.White 12 | val green = Color(0xFF4CAF50) 13 | val red = Color(0xFFF44336) 14 | val blue = Color(0xFF2196F3) 15 | val main = green 16 | val background = Color(0xFFF4F4F4) 17 | val unselect = Color(0xFF424242) 18 | val titleBar = Color(0xFFFAFAFA) 19 | val bottomBar = Color(0xFFFAFAFA) 20 | const val text_h1_int = 0xFF212121 21 | val text_h1 = Color(text_h1_int) 22 | val text_h2 = Color(0xFF757575) 23 | } -------------------------------------------------------------------------------- /app/src/main/java/top/wangchenyan/wancompose/auth/UserData.kt: -------------------------------------------------------------------------------- 1 | package top.wangchenyan.wancompose.auth 2 | 3 | import com.google.gson.annotations.SerializedName 4 | 5 | data class User( 6 | @SerializedName("id") val id: Long = 0, 7 | @SerializedName("username") val username: String = "", 8 | @SerializedName("nickname") val nickname: String = "", 9 | @SerializedName("chapterTops") val chapterTops: List = listOf(), 10 | @SerializedName("coinCount") var coinCount: Int = 0, 11 | @SerializedName("collectIds") val collectIds: List = listOf(), 12 | @SerializedName("email") val email: String = "", 13 | @SerializedName("icon") val icon: String = "", 14 | @SerializedName("level") var level: String = "", 15 | @SerializedName("rank") var rank: String = "" 16 | ) -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_arrow_right.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 11 | -------------------------------------------------------------------------------- /app/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 -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_close.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_tab_my.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/values-night/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_tab_home.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 11 | -------------------------------------------------------------------------------- /app/src/main/java/top/wangchenyan/wancompose/ui/mine/viewmodel/MineViewModel.kt: -------------------------------------------------------------------------------- 1 | package top.wangchenyan.wancompose.ui.mine.viewmodel 2 | 3 | import androidx.compose.runtime.getValue 4 | import androidx.compose.runtime.mutableStateOf 5 | import androidx.compose.runtime.setValue 6 | import androidx.lifecycle.ViewModel 7 | import androidx.lifecycle.viewModelScope 8 | import kotlinx.coroutines.launch 9 | import top.wangchenyan.common.net.apiCall 10 | import top.wangchenyan.wancompose.api.Api 11 | import top.wangchenyan.wancompose.auth.AuthManager 12 | 13 | class MineViewModel : ViewModel() { 14 | var user by mutableStateOf(AuthManager.user.value) 15 | var showLoading by mutableStateOf(false) 16 | var showDialog by mutableStateOf(false) 17 | 18 | init { 19 | AuthManager.user.observeForever { 20 | user = it?.copy() 21 | } 22 | } 23 | 24 | fun logout() { 25 | viewModelScope.launch { 26 | showLoading = true 27 | apiCall { Api.get().logout() } 28 | showLoading = false 29 | AuthManager.onLogout() 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_search.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 11 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 15 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_like.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 11 | -------------------------------------------------------------------------------- /app/src/main/java/top/wangchenyan/wancompose/theme/Type.kt: -------------------------------------------------------------------------------- 1 | package top.wangchenyan.wancompose.theme 2 | 3 | import androidx.compose.material3.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 | bodyLarge = TextStyle( 12 | fontFamily = FontFamily.Default, 13 | fontWeight = FontWeight.Normal, 14 | fontSize = 16.sp, 15 | lineHeight = 24.sp, 16 | letterSpacing = 0.5.sp 17 | ) 18 | /* Other default text styles to override 19 | titleLarge = TextStyle( 20 | fontFamily = FontFamily.Default, 21 | fontWeight = FontWeight.Normal, 22 | fontSize = 22.sp, 23 | lineHeight = 28.sp, 24 | letterSpacing = 0.sp 25 | ), 26 | labelSmall = TextStyle( 27 | fontFamily = FontFamily.Default, 28 | fontWeight = FontWeight.Medium, 29 | fontSize = 11.sp, 30 | lineHeight = 16.sp, 31 | letterSpacing = 0.5.sp 32 | ) 33 | */ 34 | ) -------------------------------------------------------------------------------- /app/src/main/java/top/wangchenyan/wancompose/WanApplication.kt: -------------------------------------------------------------------------------- 1 | package top.wangchenyan.wancompose 2 | 3 | import android.app.Application 4 | import android.util.Log 5 | import me.wcy.mockhttp.MockHttp 6 | import me.wcy.mockhttp.MockHttpOptions 7 | import top.wangchenyan.common.CommonApp 8 | import top.wangchenyan.wancompose.auth.AuthManager 9 | 10 | /** 11 | * Created by wcy on 2021/4/1. 12 | */ 13 | class WanApplication : Application() { 14 | 15 | override fun onCreate() { 16 | super.onCreate() 17 | CommonApp.init { 18 | test = true 19 | apiConfig({}) { 20 | codeJsonNames = listOf("errorCode") 21 | msgJsonNames = listOf("errorMsg") 22 | dataJsonNames = listOf("data") 23 | successCode = 0 24 | } 25 | } 26 | AuthManager.init() 27 | val options = MockHttpOptions.Builder() 28 | .setMockServerPort(3000) 29 | .setMockSleepTime(500) 30 | .setLogEnable(true) 31 | .setLogLevel(Log.ERROR) 32 | .build() 33 | MockHttp.get().setMockHttpOptions(options) 34 | MockHttp.get().start(this) 35 | } 36 | } -------------------------------------------------------------------------------- /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 -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_share.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 11 | -------------------------------------------------------------------------------- /app/src/main/java/top/wangchenyan/wancompose/storage/HistoryPreferences.kt: -------------------------------------------------------------------------------- 1 | package top.wangchenyan.wancompose.storage 2 | 3 | import androidx.datastore.preferences.core.stringPreferencesKey 4 | import top.wangchenyan.common.CommonApp 5 | 6 | object HistoryPreferences { 7 | private val KEY_HISTORY = stringPreferencesKey("history") 8 | 9 | private val dataStore by lazy { 10 | PreferencesDataStore( 11 | CommonApp.app, 12 | CommonApp.app.packageName + ".history" 13 | ) 14 | } 15 | 16 | suspend fun getHistory(): List { 17 | return dataStore.getList(KEY_HISTORY) ?: listOf() 18 | } 19 | 20 | suspend fun addHistory(item: String) { 21 | if (item.isEmpty()) { 22 | return 23 | } 24 | val list = getHistory().toMutableList() 25 | if (list.contains(item)) { 26 | return 27 | } 28 | list.add(0, item) 29 | dataStore.putList(KEY_HISTORY, list) 30 | } 31 | 32 | suspend fun removeHistory(item: String) { 33 | if (item.isEmpty()) { 34 | return 35 | } 36 | val list = getHistory().toMutableList() 37 | if (!list.contains(item)) { 38 | return 39 | } 40 | list.remove(item) 41 | dataStore.putList(KEY_HISTORY, list) 42 | } 43 | } -------------------------------------------------------------------------------- /app/src/main/java/top/wangchenyan/wancompose/theme/Theme.kt: -------------------------------------------------------------------------------- 1 | package top.wangchenyan.wancompose.theme 2 | 3 | import androidx.compose.foundation.isSystemInDarkTheme 4 | import androidx.compose.material3.MaterialTheme 5 | import androidx.compose.material3.darkColorScheme 6 | import androidx.compose.material3.lightColorScheme 7 | import androidx.compose.runtime.Composable 8 | 9 | private val DarkColorPalette = darkColorScheme( 10 | primary = Colors.main, 11 | secondary = Colors.main, 12 | tertiary = Colors.main 13 | ) 14 | 15 | private val LightColorPalette = lightColorScheme( 16 | primary = Colors.main, 17 | secondary = Colors.main, 18 | tertiary = Colors.main 19 | 20 | /* Other default colors to override 21 | background = Color(0xFFFFFBFE), 22 | surface = Color(0xFFFFFBFE), 23 | onPrimary = Color.White, 24 | onSecondary = Color.White, 25 | onTertiary = Color.White, 26 | onBackground = Color(0xFF1C1B1F), 27 | onSurface = Color(0xFF1C1B1F), 28 | */ 29 | ) 30 | 31 | @Composable 32 | fun WanandroidTheme( 33 | darkTheme: Boolean = isSystemInDarkTheme(), 34 | content: @Composable() () -> Unit 35 | ) { 36 | val colors = if (darkTheme) { 37 | DarkColorPalette 38 | } else { 39 | LightColorPalette 40 | } 41 | 42 | MaterialTheme( 43 | colorScheme = colors, 44 | typography = Typography, 45 | content = content 46 | ) 47 | } -------------------------------------------------------------------------------- /app/src/main/java/top/wangchenyan/wancompose/ui/wechat/viewmodel/WeChatViewModel.kt: -------------------------------------------------------------------------------- 1 | package top.wangchenyan.wancompose.ui.wechat.viewmodel 2 | 3 | import android.util.LongSparseArray 4 | import androidx.compose.runtime.getValue 5 | import androidx.compose.runtime.mutableStateOf 6 | import androidx.compose.runtime.setValue 7 | import androidx.lifecycle.ViewModel 8 | import androidx.lifecycle.viewModelScope 9 | import kotlinx.coroutines.launch 10 | import top.wangchenyan.common.net.apiCall 11 | import top.wangchenyan.wancompose.api.Api 12 | import top.wangchenyan.wancompose.ui.wechat.model.WeChatAuthor 13 | import top.wangchenyan.wancompose.widget.LoadState 14 | 15 | class WeChatViewModel : ViewModel() { 16 | var pageState by mutableStateOf(LoadState.LOADING) 17 | var authorList by mutableStateOf(listOf()) 18 | val tabViewModelMap = LongSparseArray() 19 | 20 | init { 21 | getAuthorList() 22 | } 23 | 24 | fun getAuthorList() { 25 | viewModelScope.launch { 26 | pageState = LoadState.LOADING 27 | val authorListRes = apiCall { Api.get().getWeChatAuthorList() } 28 | if (authorListRes.isSuccessWithData()) { 29 | pageState = LoadState.SUCCESS 30 | authorList = authorListRes.data!! 31 | } else { 32 | pageState = LoadState.FAIL 33 | } 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /app/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 18 | 19 | 23 | 24 |