1 /* 2 * Copyright 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package androidx.compose.material3.adaptive.layout 18 19 import androidx.compose.material3.adaptive.ExperimentalMaterial3AdaptiveApi 20 import androidx.compose.runtime.Stable 21 22 /** 23 * The adapted state of a pane. It gives clues to pane scaffolds about if a certain pane should be 24 * composed and how. 25 */ 26 @ExperimentalMaterial3AdaptiveApi 27 @Stable 28 sealed interface PaneAdaptedValue { 29 private class Simple(private val description: String) : PaneAdaptedValue { toStringnull30 override fun toString() = "PaneAdaptedValue[$description]" 31 } 32 33 /** 34 * Indicates that the associated pane should be reflowed to its [targetPane], i.e., it will be 35 * displayed under the target pane. 36 * 37 * @param targetPane the target pane of the reflowing, i.e., the pane that the reflowed pane 38 * will be put under. 39 */ 40 class Reflowed(val targetPane: Any) : PaneAdaptedValue { 41 override fun toString() = "PaneAdaptedValue[Reflowed to $targetPane]" 42 43 override fun equals(other: Any?): Boolean { 44 if (this === other) return true 45 if (other !is Reflowed) return false 46 return targetPane == other.targetPane 47 } 48 49 override fun hashCode(): Int { 50 return targetPane.hashCode() 51 } 52 } 53 54 companion object { 55 /** Indicates that the associated pane should be displayed in its full width and height. */ 56 val Expanded: PaneAdaptedValue = Simple("Expanded") 57 /** Indicates that the associated pane should be hidden. */ 58 val Hidden: PaneAdaptedValue = Simple("Hidden") 59 } 60 } 61