mirror of
https://github.com/BetterAndroid/FlexiUI.git
synced 2025-09-07 19:14:12 +08:00
feat: add Popup
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Flexi UI - A flexible and useful UI component library.
|
||||
* Copyright (C) 2019-2023 HighCapable
|
||||
* https://github.com/BetterAndroid/FlexiUI
|
||||
*
|
||||
* Apache License Version 2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is created by fankes on 2023/11/16.
|
||||
*/
|
||||
@file:Suppress("unused")
|
||||
|
||||
package com.highcapable.flexiui.component
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.input.key.KeyEvent
|
||||
import androidx.compose.ui.unit.IntOffset
|
||||
import androidx.compose.ui.window.PopupPositionProvider
|
||||
import androidx.compose.ui.window.PopupProperties
|
||||
import androidx.compose.ui.window.Popup as ComposePopup
|
||||
|
||||
@Composable
|
||||
actual fun Popup(
|
||||
alignment: Alignment,
|
||||
offset: IntOffset,
|
||||
popupPositionProvider: PopupPositionProvider?,
|
||||
onDismissRequest: (() -> Unit)?,
|
||||
properties: PopupProperties,
|
||||
onPreviewKeyEvent: ((KeyEvent) -> Boolean)?,
|
||||
onKeyEvent: ((KeyEvent) -> Boolean)?,
|
||||
content: @Composable () -> Unit
|
||||
) {
|
||||
popupPositionProvider?.also {
|
||||
ComposePopup(
|
||||
popupPositionProvider = it,
|
||||
onDismissRequest = onDismissRequest,
|
||||
properties = properties,
|
||||
content = content
|
||||
)
|
||||
} ?: ComposePopup(
|
||||
alignment = alignment,
|
||||
offset = offset,
|
||||
onDismissRequest = onDismissRequest,
|
||||
properties = properties,
|
||||
content = content
|
||||
)
|
||||
}
|
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
* Flexi UI - A flexible and useful UI component library.
|
||||
* Copyright (C) 2019-2023 HighCapable
|
||||
* https://github.com/BetterAndroid/FlexiUI
|
||||
*
|
||||
* Apache License Version 2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is created by fankes on 2023/11/9.
|
||||
*/
|
||||
@file:Suppress("unused")
|
||||
|
||||
package com.highcapable.flexiui.component
|
||||
|
||||
// TODO: To be implemented
|
@@ -21,6 +21,23 @@
|
||||
*/
|
||||
@file:Suppress("unused")
|
||||
|
||||
package com.highcapable.flexiui.interaction
|
||||
package com.highcapable.flexiui.component
|
||||
|
||||
// TODO: To be implemented
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.input.key.KeyEvent
|
||||
import androidx.compose.ui.unit.IntOffset
|
||||
import androidx.compose.ui.window.PopupPositionProvider
|
||||
import androidx.compose.ui.window.PopupProperties
|
||||
|
||||
@Composable
|
||||
expect fun Popup(
|
||||
alignment: Alignment = Alignment.TopStart,
|
||||
offset: IntOffset = IntOffset(0, 0),
|
||||
popupPositionProvider: PopupPositionProvider? = null,
|
||||
onDismissRequest: (() -> Unit)? = null,
|
||||
properties: PopupProperties = PopupProperties(),
|
||||
onPreviewKeyEvent: ((KeyEvent) -> Boolean)? = null,
|
||||
onKeyEvent: ((KeyEvent) -> Boolean)? = null,
|
||||
content: @Composable () -> Unit
|
||||
)
|
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Flexi UI - A flexible and useful UI component library.
|
||||
* Copyright (C) 2019-2023 HighCapable
|
||||
* https://github.com/BetterAndroid/FlexiUI
|
||||
*
|
||||
* Apache License Version 2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is created by fankes on 2023/11/16.
|
||||
*/
|
||||
@file:Suppress("unused")
|
||||
|
||||
package com.highcapable.flexiui.component
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.input.key.KeyEvent
|
||||
import androidx.compose.ui.unit.IntOffset
|
||||
import androidx.compose.ui.window.PopupPositionProvider
|
||||
import androidx.compose.ui.window.PopupProperties
|
||||
import androidx.compose.ui.window.Popup as ComposePopup
|
||||
|
||||
@Composable
|
||||
actual fun Popup(
|
||||
alignment: Alignment,
|
||||
offset: IntOffset,
|
||||
popupPositionProvider: PopupPositionProvider?,
|
||||
onDismissRequest: (() -> Unit)?,
|
||||
properties: PopupProperties,
|
||||
onPreviewKeyEvent: ((KeyEvent) -> Boolean)?,
|
||||
onKeyEvent: ((KeyEvent) -> Boolean)?,
|
||||
content: @Composable () -> Unit
|
||||
) {
|
||||
popupPositionProvider?.also {
|
||||
ComposePopup(
|
||||
popupPositionProvider = it,
|
||||
onDismissRequest = onDismissRequest,
|
||||
properties = properties,
|
||||
onPreviewKeyEvent = onPreviewKeyEvent,
|
||||
onKeyEvent = onKeyEvent,
|
||||
content = content
|
||||
)
|
||||
} ?: ComposePopup(
|
||||
alignment = alignment,
|
||||
offset = offset,
|
||||
onDismissRequest = onDismissRequest,
|
||||
properties = properties,
|
||||
onPreviewKeyEvent = onPreviewKeyEvent,
|
||||
onKeyEvent = onKeyEvent,
|
||||
content = content
|
||||
)
|
||||
}
|
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Flexi UI - A flexible and useful UI component library.
|
||||
* Copyright (C) 2019-2023 HighCapable
|
||||
* https://github.com/BetterAndroid/FlexiUI
|
||||
*
|
||||
* Apache License Version 2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is created by fankes on 2023/11/16.
|
||||
*/
|
||||
@file:Suppress("unused")
|
||||
|
||||
package com.highcapable.flexiui.component
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.input.key.KeyEvent
|
||||
import androidx.compose.ui.unit.IntOffset
|
||||
import androidx.compose.ui.window.PopupPositionProvider
|
||||
import androidx.compose.ui.window.PopupProperties
|
||||
import androidx.compose.ui.window.Popup as ComposePopup
|
||||
|
||||
@Composable
|
||||
actual fun Popup(
|
||||
alignment: Alignment,
|
||||
offset: IntOffset,
|
||||
popupPositionProvider: PopupPositionProvider?,
|
||||
onDismissRequest: (() -> Unit)?,
|
||||
properties: PopupProperties,
|
||||
onPreviewKeyEvent: ((KeyEvent) -> Boolean)?,
|
||||
onKeyEvent: ((KeyEvent) -> Boolean)?,
|
||||
content: @Composable () -> Unit
|
||||
) {
|
||||
popupPositionProvider?.also {
|
||||
ComposePopup(
|
||||
popupPositionProvider = it,
|
||||
onDismissRequest = onDismissRequest,
|
||||
properties = properties,
|
||||
onPreviewKeyEvent = onPreviewKeyEvent,
|
||||
onKeyEvent = onKeyEvent,
|
||||
content = content
|
||||
)
|
||||
} ?: ComposePopup(
|
||||
alignment = alignment,
|
||||
offset = offset,
|
||||
onDismissRequest = onDismissRequest,
|
||||
properties = properties,
|
||||
onPreviewKeyEvent = onPreviewKeyEvent,
|
||||
onKeyEvent = onKeyEvent,
|
||||
content = content
|
||||
)
|
||||
}
|
Reference in New Issue
Block a user