Browse Source

1.添加登录页面布局,及其素材。

master
wangwanlei 9 months ago
parent
commit
5270b79922

+ 81
- 0
app/src/main/java/com/xhly/manageapp/ui/login/activity/LoginActivity.kt View File

@@ -0,0 +1,81 @@
1
+package com.xhly.manageapp.ui.login.activity
2
+
3
+import BaseActivity
4
+import android.graphics.Color
5
+import android.view.View
6
+import android.widget.EditText
7
+import android.widget.TextView
8
+import androidx.activity.addCallback
9
+import com.kongzue.dialogx.dialogs.CustomDialog
10
+import com.kongzue.dialogx.interfaces.OnBindView
11
+import com.xhly.corelib.Const
12
+import com.xhly.manageapp.R
13
+import com.xhly.manageapp.databinding.ActivityLoginBinding
14
+import com.xhly.manageapp.ui.MainActivity
15
+import com.xhly.manageapp.ui.login.viewmodel.LoginViewModel
16
+
17
+class LoginActivity : BaseActivity<LoginViewModel, ActivityLoginBinding>() {
18
+    private var regioncode = ""
19
+    override fun getBinding() = ActivityLoginBinding.inflate(layoutInflater)
20
+
21
+    override fun initData() {
22
+
23
+    }
24
+
25
+    override fun initView() {
26
+        setSoftInput(mBinding.root)
27
+        mBinding.loginBtn.setOnClickListener {
28
+            login()
29
+        }
30
+        mBinding.codeLoginIv.setOnClickListener {
31
+            showEditDialog()
32
+        }
33
+        onBackPressedDispatcher.addCallback {
34
+            //屏蔽返回
35
+        }
36
+    }
37
+
38
+    private fun login() {
39
+        val account = mBinding.accountEt.text.toString()
40
+        val code = mBinding.codeEt.text.toString()
41
+        if (account.isNullOrBlank()) {
42
+            Toast(getString(R.string.accountnoempty))
43
+            return
44
+        }
45
+        if (code.isNullOrBlank()) {
46
+            Toast(getString(R.string.codenoempty))
47
+            return
48
+        }
49
+        viewModel.getTest()
50
+        spUtils.setParam("user", "user")
51
+        startIntentActivity(MainActivity().javaClass)
52
+        finish()
53
+    }
54
+
55
+    private fun showEditDialog() {
56
+        CustomDialog
57
+            .build()
58
+            .setCustomView(object : OnBindView<CustomDialog>(R.layout.layout_edit_dialog) {
59
+                override fun onBind(dialog: CustomDialog, v: View) {
60
+                    val enterTv = v.findViewById<TextView>(R.id.dialog_enter_tv)
61
+                    val cancelTv = v.findViewById<TextView>(R.id.dialog_cancel_tv)
62
+                    val editText = v.findViewById<EditText>(R.id.dialog_et)
63
+                    enterTv.setOnClickListener {
64
+                        dialog.dismiss()
65
+                        val text = editText.text
66
+                        val list= arrayListOf("com.xhly.manageapp")
67
+                        spUtils.saveJson(Const.WHITELISTAPP,list)
68
+                        regioncode = if (text != null && text.isNotEmpty()) {
69
+                            text.toString()
70
+                        } else {
71
+                            ""
72
+                        }
73
+                    }
74
+                    cancelTv.setOnClickListener {
75
+                        dialog.dismiss()
76
+                    }
77
+                }
78
+            }).setCancelable(false).setMaskColor(Color.parseColor("#66000000"))
79
+            .setAlign(CustomDialog.ALIGN.CENTER).show()
80
+    }
81
+}

+ 9
- 0
app/src/main/java/com/xhly/manageapp/ui/login/netservice/LoginService.kt View File

@@ -0,0 +1,9 @@
1
+package com.xhly.manageapp.ui.login.netservice
2
+
3
+import com.xhly.corelib.network.bean.ResponseData
4
+import retrofit2.http.GET
5
+
6
+interface LoginService {
7
+    @GET("/status/info")
8
+    suspend fun getTest():ResponseData<String>
9
+}

+ 17
- 0
app/src/main/java/com/xhly/manageapp/ui/login/viewmodel/LoginViewModel.kt View File

@@ -0,0 +1,17 @@
1
+package com.xhly.manageapp.ui.login.viewmodel
2
+
3
+import com.xhly.corelib.base.viewmodel.CommonBaseViewModel
4
+import com.xhly.corelib.network.RetrofitService
5
+import com.xhly.corelib.utils.LogShow
6
+import com.xhly.manageapp.ui.login.netservice.LoginService
7
+
8
+class LoginViewModel: CommonBaseViewModel() {
9
+    private var service=RetrofitService.create<LoginService>()
10
+
11
+    fun getTest(){
12
+        launchUI {
13
+            val test = service.getTest()
14
+            LogShow(test.toString()+"|||"+test.msg)
15
+        }
16
+    }
17
+}

BIN
app/src/main/res/drawable-xxhdpi/ic_manageapp_launcher.png View File


BIN
app/src/main/res/drawable/bg_login.png View File


+ 9
- 0
app/src/main/res/drawable/icon_setting.xml View File

@@ -0,0 +1,9 @@
1
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
2
+    android:width="64dp"
3
+    android:height="64dp"
4
+    android:viewportWidth="1024"
5
+    android:viewportHeight="1024">
6
+  <path
7
+      android:pathData="M849.1,540.2a42.7,42.7 0,0 1,0 -56.3l54.6,-61.4a42.7,42.7 0,0 0,5.1 -49.9l-85.3,-147.6a42.7,42.7 0,0 0,-45.7 -20.5l-80.2,16.2a42.7,42.7 0,0 1,-49.1 -28.2l-26,-78.1A42.7,42.7 0,0 0,582 85.3h-170.7a42.7,42.7 0,0 0,-42.7 29l-23.9,78.1a42.7,42.7 0,0 1,-49.1 28.2l-82.3,-16.2a42.7,42.7 0,0 0,-42.7 20.5l-85.3,147.6a42.7,42.7 0,0 0,4.3 49.9l54.2,61.4a42.7,42.7 0,0 1,0 56.3l-54.2,61.4a42.7,42.7 0,0 0,-4.3 49.9l85.3,147.6a42.7,42.7 0,0 0,45.7 20.5l80.2,-16.2a42.7,42.7 0,0 1,49.1 28.2l26,78.1a42.7,42.7 0,0 0,42.7 29h170.7a42.7,42.7 0,0 0,40.5 -29l26,-78.1a42.7,42.7 0,0 1,49.1 -28.2l80.2,16.2a42.7,42.7 0,0 0,45.7 -20.5l85.3,-147.6a42.7,42.7 0,0 0,-5.1 -49.9l-57.6,-61.4zM785.5,597.3l34.1,38.4 -54.6,94.7 -50.3,-10.2a128,128 0,0 0,-147.2 85.3l-16.2,47.8L442,853.3L426.7,804.7a128,128 0,0 0,-147.2 -85.3l-50.3,10.2 -55.5,-94.3 34.1,-38.4a128,128 0,0 0,0 -170.7l-34.1,-38.4 54.6,-93.9 50.3,10.2a128,128 0,0 0,147.2 -85.3L442,170.7h109.2l16.2,48.6a128,128 0,0 0,147.2 85.3l50.3,-10.2 54.6,94.7 -34.1,38.4a128,128 0,0 0,0 169.8zM496.6,341.3a170.7,170.7 0,1 0,0 341.3,170.7 170.7,0 0,0 0,-341.3zM496.6,597.3a85.3,85.3 0,1 1,0 -170.7,85.3 85.3,0 0,1 0,170.7z"
8
+      android:fillColor="#253A70"/>
9
+</vector>

+ 133
- 0
app/src/main/res/layout/activity_login.xml View File

@@ -0,0 +1,133 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
+    xmlns:app="http://schemas.android.com/apk/res-auto"
4
+    android:layout_width="match_parent"
5
+    android:layout_height="match_parent">
6
+
7
+    <androidx.constraintlayout.widget.ConstraintLayout
8
+        android:layout_width="match_parent"
9
+        android:layout_height="match_parent"
10
+        android:background="@color/white"
11
+        android:orientation="vertical">
12
+
13
+        <ImageView
14
+            android:layout_width="match_parent"
15
+            android:layout_height="0dp"
16
+            android:src="@drawable/bg_login"
17
+            app:layout_constraintDimensionRatio="2.87:1"
18
+            app:layout_constraintTop_toTopOf="parent" />
19
+
20
+        <ImageView
21
+            android:id="@+id/code_login_iv"
22
+            android:layout_width="21dp"
23
+            android:layout_height="21dp"
24
+            android:layout_marginTop="42dp"
25
+            android:layout_marginRight="28dp"
26
+            android:src="@drawable/icon_setting"
27
+            app:layout_constraintRight_toRightOf="parent"
28
+            app:layout_constraintTop_toTopOf="parent" />
29
+
30
+        <androidx.core.widget.NestedScrollView
31
+            android:id="@+id/login_sv"
32
+            android:layout_width="match_parent"
33
+            android:layout_height="match_parent"
34
+            android:layout_marginTop="72dp">
35
+
36
+            <androidx.constraintlayout.widget.ConstraintLayout
37
+                android:layout_width="match_parent"
38
+                android:layout_height="match_parent">
39
+
40
+                <ImageView
41
+                    android:layout_width="wrap_content"
42
+                    android:layout_height="37dp"
43
+                    android:src="@drawable/ic_manageapp_launcher"
44
+                    app:layout_constraintLeft_toLeftOf="parent"
45
+                    app:layout_constraintRight_toRightOf="parent"
46
+                    app:layout_constraintTop_toTopOf="parent" />
47
+
48
+                <ImageView
49
+                    android:layout_width="22dp"
50
+                    android:layout_height="22dp"
51
+                    android:layout_marginRight="15dp"
52
+                    android:src="@drawable/icon_zhanghao"
53
+                    app:layout_constraintBottom_toBottomOf="@id/account_et"
54
+                    app:layout_constraintRight_toLeftOf="@id/account_et"
55
+                    app:layout_constraintTop_toTopOf="@id/account_et" />
56
+
57
+                <EditText
58
+                    android:id="@+id/account_et"
59
+                    android:layout_width="300dp"
60
+                    android:layout_height="wrap_content"
61
+                    android:layout_marginTop="82dp"
62
+                    android:background="@null"
63
+                    android:gravity="center_vertical"
64
+                    android:hint="@string/inputaccount"
65
+                    android:singleLine="true"
66
+                    android:textColor="@color/black"
67
+                    android:textColorHint="#FFB8C2D9"
68
+                    android:textSize="21sp"
69
+                    app:layout_constraintLeft_toLeftOf="parent"
70
+                    app:layout_constraintRight_toRightOf="parent"
71
+                    app:layout_constraintTop_toTopOf="parent" />
72
+
73
+                <ImageView
74
+                    android:layout_width="387dp"
75
+                    android:layout_height="1dp"
76
+                    android:layout_marginTop="12dp"
77
+                    android:src="#D0DBF4"
78
+                    app:layout_constraintLeft_toLeftOf="parent"
79
+                    app:layout_constraintRight_toRightOf="parent"
80
+                    app:layout_constraintTop_toBottomOf="@id/account_et" />
81
+
82
+                <ImageView
83
+                    android:layout_width="22dp"
84
+                    android:layout_height="22dp"
85
+                    android:layout_marginRight="15dp"
86
+                    android:src="@drawable/icon_mima"
87
+                    app:layout_constraintBottom_toBottomOf="@id/code_et"
88
+                    app:layout_constraintRight_toLeftOf="@id/code_et"
89
+                    app:layout_constraintTop_toTopOf="@id/code_et" />
90
+
91
+                <EditText
92
+                    android:id="@+id/code_et"
93
+                    android:layout_width="300dp"
94
+                    android:layout_height="wrap_content"
95
+                    android:layout_marginTop="165dp"
96
+                    android:background="@null"
97
+                    android:digits="@string/psw_style"
98
+                    android:inputType="numberPassword"
99
+                    android:gravity="center_vertical"
100
+                    android:hint="@string/inputcode"
101
+                    android:singleLine="true"
102
+                    android:textColor="@color/black"
103
+                    android:textColorHint="#FFB8C2D9"
104
+                    android:textSize="21sp"
105
+                    app:layout_constraintLeft_toLeftOf="parent"
106
+                    app:layout_constraintRight_toRightOf="parent"
107
+                    app:layout_constraintTop_toTopOf="parent" />
108
+
109
+                <ImageView
110
+                    android:layout_width="387dp"
111
+                    android:layout_height="1dp"
112
+                    android:layout_marginTop="12dp"
113
+                    android:src="#D0DBF4"
114
+                    app:layout_constraintLeft_toLeftOf="parent"
115
+                    app:layout_constraintRight_toRightOf="parent"
116
+                    app:layout_constraintTop_toBottomOf="@id/code_et" />
117
+
118
+                <Button
119
+                    android:id="@+id/login_btn"
120
+                    android:layout_width="387dp"
121
+                    android:layout_height="49dp"
122
+                    android:layout_marginTop="279dp"
123
+                    android:background="@drawable/icon_login"
124
+                    android:text="@string/loginnow"
125
+                    android:textColor="@color/white"
126
+                    app:layout_constraintLeft_toLeftOf="parent"
127
+                    app:layout_constraintRight_toRightOf="parent"
128
+                    app:layout_constraintTop_toTopOf="parent" />
129
+
130
+            </androidx.constraintlayout.widget.ConstraintLayout>
131
+        </androidx.core.widget.NestedScrollView>
132
+    </androidx.constraintlayout.widget.ConstraintLayout>
133
+</LinearLayout>

Loading…
Cancel
Save