Commit 61e604e9 authored by wanglei's avatar wanglei

...首页

parent 6552196a
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
id("com.google.gms.google-services")
id("com.google.firebase.crashlytics")
}
android {
......@@ -45,6 +47,8 @@ dependencies {
implementation(libs.material)
implementation(libs.androidx.activity)
implementation(libs.androidx.constraintlayout)
implementation(libs.androidx.navigation.fragment.ktx)
implementation(libs.androidx.navigation.ui.ktx)
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
......@@ -52,11 +56,9 @@ dependencies {
// 语种切换框架:https://github.com/getActivity/MultiLanguages
implementation("com.github.getActivity:MultiLanguages:9.3")
// 沉浸式状态栏,基础依赖包,必须要依赖
api (libs.immersionbar)
api(libs.immersionbar)
// 沉浸式状态栏kotlin扩展(可选)
api (libs.immersionbar.ktx)
api(libs.immersionbar.ktx)
//solar 归因
......
{
"project_info": {
"project_number": "755421476297",
"project_id": "comtooladvancedcleaner",
"storage_bucket": "comtooladvancedcleaner.firebasestorage.app"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:755421476297:android:c66d8129d83b17e8af6418",
"android_client_info": {
"package_name": "com.base.appzxhy"
}
},
"oauth_client": [],
"api_key": [
{
"current_key": "AIzaSyAhCB4trMZPymkWCNl_m-bFGPpASG6bsQI"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": []
}
}
}
],
"configuration_version": "1"
}
\ No newline at end of file
......@@ -22,6 +22,15 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-3940256099942544~3347511713" />
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id" />
</application>
</manifest>
\ No newline at end of file
package com.base.appzxhy
import android.graphics.Color
import android.view.LayoutInflater
import android.widget.TextView
import androidx.navigation.NavController
import androidx.navigation.fragment.NavHostFragment
import com.base.appzxhy.base.BaseActivity
import com.base.appzxhy.bean.HomeTabUIBean
import com.base.appzxhy.databinding.ActivityMainBinding
import com.base.appzxhy.databinding.ItemHomeTabBinding
import com.base.appzxhy.utils.LogEx
import com.google.android.material.tabs.TabLayout
import com.google.android.material.tabs.TabLayout.OnTabSelectedListener
class MainActivity : BaseActivity<ActivityMainBinding>(ActivityMainBinding::inflate) {
private lateinit var navController: NavController
private val homeTabs by lazy {
arrayOf(
HomeTabUIBean(R.mipmap.ic_launcher, getString(R.string.home)),
)
}
override fun initView() {
super.initView()
navController = (supportFragmentManager.findFragmentById(R.id.fragment_container) as NavHostFragment).navController
}
private fun initTab() {
homeTabs.forEachIndexed { index, homeTab ->
val tab = binding.tabLayout.newTab()
val view = LayoutInflater.from(this).inflate(R.layout.item_home_tab, null)
val tabBinding = ItemHomeTabBinding.bind(view)
tabBinding.ivIcon.setImageResource(homeTab.icon)
tabBinding.tvTab.text = homeTab.tab
// tabBinding.tvTab.setTextColor(ContextCompat.getColor(this, R.color.color_tab_home))
tab.customView = tabBinding.root
tab.id = index
binding.tabLayout.addTab(tab)
}
binding.tabLayout.addOnTabSelectedListener(object : OnTabSelectedListener {
override fun onTabSelected(tab: TabLayout.Tab?) {
tab?.setSelected()
}
override fun onTabUnselected(tab: TabLayout.Tab?) {
tab?.setUnselected()
}
override fun onTabReselected(tab: TabLayout.Tab?) {
}
})
val defaultTab = binding.tabLayout.getTabAt(0)
defaultTab?.select()
defaultTab?.setSelected()
}
private fun naviFragment(id: Int) {
when (id) {
0 -> {
}
1 -> {
}
2 -> {
}
}
}
fun TabLayout.Tab.setUnselected() {
val textView = customView?.findViewById<TextView>(R.id.tv_tab)
LogEx.logDebug(TAG, "setUnselected ${textView?.text}")
textView?.setTextColor(Color.parseColor("#838383"))
}
fun TabLayout.Tab.setSelected() {
val textView = customView?.findViewById<TextView>(R.id.tv_tab)
LogEx.logDebug(TAG, "setSelected ${textView?.text}")
textView?.setTextColor(Color.parseColor("#FF0000"))
naviFragment(this.id)
}
}
\ No newline at end of file
package com.base.appzxhy.bean
data class HomeTabUIBean(
val icon:Int,
val tab:String
)
\ No newline at end of file
......@@ -4,16 +4,48 @@
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
<androidx.fragment.app.FragmentContainerView
android:id="@+id/fragment_container"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@id/fl_tab"
app:layout_constraintTop_toTopOf="parent"
app:navGraph="@navigation/nav_graph" />
<FrameLayout
android:id="@+id/fl_tab"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
android:layout_marginBottom="60dp"
app:layout_constraintBottom_toBottomOf="parent">
<com.google.android.material.tabs.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
app:tabIndicatorHeight="0dp"
app:tabMaxWidth="200dp"
app:tabMinWidth="100dp"
app:tabMode="fixed"
app:tabRippleColor="@android:color/transparent"
tools:ignore="SpeakableTextPresentCheck" />
</FrameLayout>
<FrameLayout
android:id="@+id/fl_banner"
android:layout_width="match_parent"
android:layout_height="60dp"
app:layout_constraintBottom_toBottomOf="parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
tools:ignore="ContentDescription" />
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:ignore="UseCompoundDrawables">
<ImageView
android:id="@+id/iv_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="12dp"
tools:ignore="ContentDescription"
tools:src="@mipmap/ic_launcher" />
<TextView
android:id="@+id/tv_tab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="5dp"
android:textColor="#838383"
android:textSize="13sp" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/nav_graph">
</navigation>
\ No newline at end of file
<resources>
<string name="app_name">LocalWeatherWhite</string>
<string name="facebook_app_id">1324546913856392</string>
<string name="home">Home</string>
</resources>
\ No newline at end of file
......@@ -2,4 +2,7 @@
plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.kotlin.android) apply false
id("com.google.gms.google-services") version "4.4.1" apply false
id("com.google.firebase.crashlytics") version "3.0.2" apply false
}
\ No newline at end of file
......@@ -9,6 +9,8 @@ appcompat = "1.6.1"
material = "1.10.0"
activity = "1.8.0"
constraintlayout = "2.1.4"
navigationFragmentKtx = "2.6.0"
navigationUiKtx = "2.6.0"
immersionbar = "3.2.2"
......@@ -23,6 +25,9 @@ androidx-activity = { group = "androidx.activity", name = "activity", version.re
androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" }
immersionbar = { module = "com.geyifeng.immersionbar:immersionbar", version.ref = "immersionbar" }
immersionbar-ktx = { module = "com.geyifeng.immersionbar:immersionbar-ktx", version.ref = "immersionbar" }
androidx-navigation-fragment-ktx = { group = "androidx.navigation", name = "navigation-fragment-ktx", version.ref = "navigationFragmentKtx" }
androidx-navigation-ui-ktx = { group = "androidx.navigation", name = "navigation-ui-ktx", version.ref = "navigationUiKtx" }
[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment