This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@override | |
void onScaleStart(ScaleStartInfo info) { | |
_startZoom = camera.viewfinder.zoom; | |
} | |
@override | |
void onScaleUpdate(ScaleUpdateInfo info) { | |
if (currentScale.isIdentity()) { | |
_processDrag(info); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
late TiledComponent mapComponent; | |
static const double _minZoom = 0.5; | |
static const double _maxZoom = 2.0; | |
double _startZoom = _minZoom; | |
@override | |
Future<void> onLoad() async { | |
camera.viewfinder | |
..zoom = _startZoom |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
runApp( | |
GameWidget(game: TiledGame()), | |
); | |
} | |
class TiledGame extends FlameGame with ScaleDetector, TapDetector { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: flame_tiled_example | |
description: Simple project to showcase the usage of flame_tiled | |
publish_to: 'none' | |
version: 1.0.0+1 | |
environment: | |
sdk: ">=3.0.0 <4.0.0" | |
dependencies: | |
tuple: ^2.0.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
internal fun Root() { | |
val toolbarHeightPx = remember { mutableStateOf(0f) } | |
val topPanelOffset = remember { mutableStateOf(0f) } | |
Scaffold( | |
topBar = { | |
TopBarFixed( | |
maxOffset = toolbarHeightPx.value, | |
currentOffset = topPanelOffset.value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun ScrollableContent( | |
contentTopPadding: Dp, | |
modifier: Modifier = Modifier | |
) { | |
Card( | |
modifier = modifier.padding(top = contentTopPadding), | |
backgroundColor = Color.Companion.LightGray, | |
shape = RoundedCornerShape(30.dp, 30.dp, 0.dp, 0.dp) | |
) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
internal fun CoordinatedScroll( | |
collapsingAreaHeightPx: MutableState<Float> = remember { mutableStateOf(0f) }, | |
content: @Composable (Float, NestedScrollConnection) -> Unit | |
) { | |
val currentOffsetPx = remember { mutableStateOf(0f) } | |
val currentAbsoluteOffsetPx = remember { mutableStateOf(0f) } | |
val nestedScrollConnection = remember { | |
object : NestedScrollConnection { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
internal fun Root() { | |
val toolbarHeightPx = remember { mutableStateOf(0f) } | |
val topPanelOffset = remember { mutableStateOf(0f) } | |
Scaffold( | |
topBar = { | |
TopBarFixed( | |
maxOffset = toolbarHeightPx.value, | |
currentOffset = topPanelOffset.value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
internal fun TopBarCollapsing( | |
currentOffset: Float, | |
maxOffset: Float, | |
modifier: Modifier = Modifier, | |
onHeightCalculated: (Float) -> Unit | |
) { | |
val alpha = (abs(currentOffset) / maxOffset).pow(0.75f) | |
Column( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun ScrollableContent( | |
contentTopPadding: Dp, | |
modifier: Modifier = Modifier | |
) { | |
LazyColumn( | |
contentPadding = PaddingValues(top = contentTopPadding), | |
modifier = modifier | |
) { | |
items(100) { index -> |