5
5
package at.bitfire.davdroid.ui.intro
6
6
7
7
import android.content.Context
8
+ import android.content.res.Configuration
8
9
import android.os.Bundle
9
10
import android.view.LayoutInflater
10
11
import android.view.View
11
12
import android.view.ViewGroup
13
+ import androidx.compose.foundation.Image
14
+ import androidx.compose.foundation.background
15
+ import androidx.compose.foundation.layout.Column
16
+ import androidx.compose.foundation.layout.Row
17
+ import androidx.compose.foundation.layout.fillMaxHeight
18
+ import androidx.compose.foundation.layout.fillMaxSize
19
+ import androidx.compose.foundation.layout.fillMaxWidth
20
+ import androidx.compose.foundation.layout.padding
21
+ import androidx.compose.foundation.layout.wrapContentHeight
22
+ import androidx.compose.material.MaterialTheme
23
+ import androidx.compose.material.Text
24
+ import androidx.compose.runtime.Composable
25
+ import androidx.compose.ui.Alignment
26
+ import androidx.compose.ui.Modifier
27
+ import androidx.compose.ui.graphics.Color
28
+ import androidx.compose.ui.platform.ComposeView
29
+ import androidx.compose.ui.platform.LocalConfiguration
30
+ import androidx.compose.ui.res.colorResource
31
+ import androidx.compose.ui.res.dimensionResource
32
+ import androidx.compose.ui.res.painterResource
33
+ import androidx.compose.ui.res.stringResource
34
+ import androidx.compose.ui.text.style.TextAlign
35
+ import androidx.compose.ui.tooling.preview.Preview
36
+ import androidx.compose.ui.unit.dp
37
+ import androidx.compose.ui.unit.sp
12
38
import androidx.fragment.app.Fragment
13
- import at.bitfire.davdroid.databinding.IntroWelcomeBinding
39
+ import at.bitfire.davdroid.R
14
40
import dagger.Binds
15
41
import dagger.Module
16
42
import dagger.hilt.InstallIn
@@ -20,39 +46,114 @@ import javax.inject.Inject
20
46
21
47
class WelcomeFragment : Fragment () {
22
48
23
- private var _binding : IntroWelcomeBinding ? = null
24
- private val binding get() = _binding !!
25
-
26
49
override fun onCreateView (inflater : LayoutInflater , container : ViewGroup ? , savedInstanceState : Bundle ? ): View {
27
- _binding = IntroWelcomeBinding .inflate(inflater, container, false )
28
-
29
- if (true /* ose build */ ) {
30
- binding.logo.apply {
31
- alpha = 0f
32
- animate()
33
- .alpha(1f )
34
- .setDuration(300 )
35
- }
36
- binding.yourDataYourChoice.apply {
37
- translationX = - 1000f
38
- animate()
39
- .translationX(0f )
40
- .setDuration(300 )
41
- }
42
- binding.takeControl.apply {
43
- translationX = 1000f
44
- animate()
45
- .translationX(0f )
46
- .setDuration(300 )
50
+ return ComposeView (requireContext()).apply {
51
+ setContent {
52
+ if (LocalConfiguration .current.orientation == Configuration .ORIENTATION_LANDSCAPE )
53
+ ContentLandscape ()
54
+ else
55
+ ContentPortrait ()
47
56
}
48
57
}
58
+ }
59
+
60
+ @Preview(showSystemUi = true )
61
+ @Composable
62
+ private fun ContentPortrait () {
63
+ Column (
64
+ modifier = Modifier
65
+ .fillMaxSize()
66
+ .background(color = colorResource(R .color.primaryDarkColor)),
67
+ ) {
68
+ Image (
69
+ painter = painterResource(R .drawable.ic_launcher_foreground),
70
+ contentDescription = null ,
71
+ modifier = Modifier
72
+ .fillMaxWidth()
73
+ .padding(top = 48 .dp)
74
+ .weight(2f )
75
+ )
76
+
77
+ Text (
78
+ text = stringResource(R .string.intro_slogan1),
79
+ color = Color .White ,
80
+ style = MaterialTheme .typography.subtitle1.copy(fontSize = 34 .sp),
81
+ lineHeight = 38 .sp,
82
+ textAlign = TextAlign .Center ,
83
+ modifier = Modifier
84
+ .fillMaxWidth()
85
+ .wrapContentHeight()
86
+ .padding(horizontal = 16 .dp)
87
+ )
49
88
50
- return binding.root
89
+ Text (
90
+ text = stringResource(R .string.intro_slogan2),
91
+ color = Color .White ,
92
+ style = MaterialTheme .typography.h5.copy(fontSize = 48 .sp),
93
+ lineHeight = 52 .sp,
94
+ textAlign = TextAlign .Center ,
95
+ modifier = Modifier
96
+ .fillMaxWidth()
97
+ .weight(1f )
98
+ .padding(horizontal = 32 .dp)
99
+ .padding(
100
+ bottom = dimensionResource(
101
+ com.github.appintro.R .dimen.appintro2_bottombar_height
102
+ )
103
+ )
104
+ )
105
+ }
51
106
}
52
107
53
- override fun onDestroyView () {
54
- super .onDestroyView()
55
- _binding = null
108
+ @Preview(
109
+ showSystemUi = true ,
110
+ device = " spec:width=411dp,height=891dp,dpi=420,isRound=false,chinSize=0dp,orientation=landscape"
111
+ )
112
+ @Composable
113
+ private fun ContentLandscape () {
114
+ Row (
115
+ modifier = Modifier
116
+ .fillMaxSize()
117
+ .background(color = colorResource(R .color.primaryDarkColor))
118
+ .padding(
119
+ bottom = dimensionResource(
120
+ com.github.appintro.R .dimen.appintro2_bottombar_height
121
+ )
122
+ ),
123
+ verticalAlignment = Alignment .CenterVertically
124
+ ) {
125
+ Image (
126
+ painter = painterResource(R .drawable.ic_launcher_foreground),
127
+ contentDescription = null ,
128
+ modifier = Modifier
129
+ .fillMaxHeight()
130
+ .weight(1f )
131
+ )
132
+
133
+ Column (
134
+ modifier = Modifier
135
+ .padding(horizontal = 32 .dp)
136
+ .weight(2f )
137
+ ) {
138
+ Text (
139
+ text = stringResource(R .string.intro_slogan1),
140
+ color = Color .White ,
141
+ style = MaterialTheme .typography.subtitle1.copy(fontSize = 34 .sp),
142
+ lineHeight = 38 .sp,
143
+ textAlign = TextAlign .Center ,
144
+ modifier = Modifier .fillMaxWidth()
145
+ )
146
+
147
+ Text (
148
+ text = stringResource(R .string.intro_slogan2),
149
+ color = Color .White ,
150
+ style = MaterialTheme .typography.h5.copy(fontSize = 48 .sp),
151
+ lineHeight = 52 .sp,
152
+ textAlign = TextAlign .Center ,
153
+ modifier = Modifier .fillMaxWidth()
154
+ )
155
+ }
156
+ }
56
157
}
57
158
58
159
0 commit comments