@@ -9,9 +9,6 @@ import androidx.compose.animation.scaleIn
9
9
import androidx.compose.animation.scaleOut
10
10
import androidx.compose.foundation.focusable
11
11
import androidx.compose.foundation.horizontalScroll
12
- import androidx.compose.foundation.interaction.MutableInteractionSource
13
- import androidx.compose.foundation.interaction.PressInteraction
14
- import androidx.compose.foundation.layout.WindowInsets
15
12
import androidx.compose.foundation.layout.fillMaxWidth
16
13
import androidx.compose.foundation.layout.padding
17
14
import androidx.compose.foundation.lazy.LazyColumn
@@ -56,7 +53,6 @@ import com.sanmer.mrepo.app.Event.Companion.isLoading
56
53
import com.sanmer.mrepo.app.Event.Companion.isSucceeded
57
54
import com.sanmer.mrepo.ui.component.NavigateUpTopBar
58
55
import com.sanmer.mrepo.ui.utils.isScrollingUp
59
- import com.sanmer.mrepo.ui.utils.none
60
56
import com.sanmer.mrepo.utils.Utils
61
57
import com.sanmer.mrepo.viewmodel.InstallViewModel
62
58
import kotlinx.coroutines.launch
@@ -88,14 +84,13 @@ fun InstallScreen(
88
84
)
89
85
90
86
val context = LocalContext .current
91
- val interactionSource = remember { MutableInteractionSource () }
92
87
val launcher = rememberLauncherForActivityResult(
93
88
ActivityResultContracts .CreateDocument (" */*" )
94
89
) { uri ->
95
90
if (uri == null ) return @rememberLauncherForActivityResult
96
91
97
92
scope.launch {
98
- viewModel.saveLog (context, uri)
93
+ viewModel.writeLogsTo (context, uri)
99
94
.onSuccess {
100
95
val message = context.getString(R .string.install_logs_saved)
101
96
snackbarHostState.showSnackbar(
@@ -115,21 +110,12 @@ fun InstallScreen(
115
110
}
116
111
}
117
112
118
- LaunchedEffect (interactionSource) {
119
- interactionSource.interactions.collect { interaction ->
120
- if (interaction is PressInteraction .Release ) {
121
- launcher.launch(viewModel.logfile)
122
- }
123
- }
124
- }
125
-
126
113
Scaffold (
127
114
modifier = Modifier
128
115
.onKeyEvent {
129
116
when (it.key) {
130
117
Key .VolumeUp ,
131
118
Key .VolumeDown -> viewModel.event.isLoading
132
-
133
119
else -> false
134
120
}
135
121
}
@@ -138,8 +124,8 @@ fun InstallScreen(
138
124
.nestedScroll(scrollBehavior.nestedScrollConnection),
139
125
topBar = {
140
126
TopBar (
127
+ exportLog = { launcher.launch(viewModel.logfile) },
141
128
event = viewModel.event,
142
- interactionSource = interactionSource,
143
129
scrollBehavior = scrollBehavior
144
130
)
145
131
},
@@ -158,8 +144,7 @@ fun InstallScreen(
158
144
FloatingButton ()
159
145
}
160
146
},
161
- snackbarHost = { SnackbarHost (snackbarHostState) },
162
- contentWindowInsets = WindowInsets .none
147
+ snackbarHost = { SnackbarHost (snackbarHostState) }
163
148
) {
164
149
Console (
165
150
list = viewModel.console.asReversed(),
@@ -196,8 +181,8 @@ private fun Console(
196
181
197
182
@Composable
198
183
private fun TopBar (
184
+ exportLog : () -> Unit ,
199
185
event : Event ,
200
- interactionSource : MutableInteractionSource ,
201
186
scrollBehavior : TopAppBarScrollBehavior
202
187
) = NavigateUpTopBar (
203
188
title = stringResource(id = R .string.install_screen_title),
@@ -211,8 +196,7 @@ private fun TopBar(
211
196
actions = {
212
197
if (event.isFinished) {
213
198
IconButton (
214
- interactionSource = interactionSource,
215
- onClick = {}
199
+ onClick = exportLog
216
200
) {
217
201
Icon (
218
202
painter = painterResource(id = R .drawable.device_floppy),
0 commit comments