fix: update Flutter example project to use new API
fix: don't keep example project Podfile.lock in repo
This commit is contained in:
@@ -1,14 +1,10 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:thermion_flutter/filament/widgets/debug/entity_list_widget.dart';
|
||||
import 'package:thermion_flutter_example/camera_matrix_overlay.dart';
|
||||
import 'package:thermion_flutter/thermion/widgets/debug/entity_list_widget.dart';
|
||||
import 'package:thermion_flutter_example/menus/controller_menu.dart';
|
||||
import 'package:thermion_flutter_example/example_viewport.dart';
|
||||
import 'package:thermion_dart/thermion_dart/entities/entity_transform_controller.dart';
|
||||
import 'package:thermion_flutter_example/menus/scene_menu.dart';
|
||||
import 'package:thermion_flutter/thermion_flutter.dart';
|
||||
import 'package:thermion_flutter_example/picker_result_widget.dart';
|
||||
|
||||
|
||||
const loadDefaultScene = bool.hasEnvironment('--load-default-scene');
|
||||
|
||||
@@ -38,8 +34,7 @@ class _MyAppState extends State<MyApp> with SingleTickerProviderStateMixin {
|
||||
bodyMedium: TextStyle(fontSize: 12))),
|
||||
// showPerformanceOverlay: true,
|
||||
home: const Scaffold(
|
||||
backgroundColor: Color(0x00000000),
|
||||
body: ExampleWidget()));
|
||||
backgroundColor: Color(0x00000000), body: ExampleWidget()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +50,7 @@ class ExampleWidget extends StatefulWidget {
|
||||
enum MenuType { controller, assets, camera, misc }
|
||||
|
||||
class ExampleWidgetState extends State<ExampleWidget> {
|
||||
final _plugin = ThermionFlutterPlugin();
|
||||
ThermionViewer? _viewer;
|
||||
|
||||
EdgeInsets _viewportMargin = EdgeInsets.zero;
|
||||
|
||||
@@ -99,105 +94,103 @@ class ExampleWidgetState extends State<ExampleWidget> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FutureBuilder(
|
||||
future: _plugin.initialized,
|
||||
builder: (_, AsyncSnapshot<bool> initialized) {
|
||||
var isInitialized = initialized.data == true;
|
||||
|
||||
return Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
if (isInitialized)
|
||||
Positioned.fill(
|
||||
child: ExampleViewport(
|
||||
controller: isInitialized ? _plugin : null,
|
||||
entityTransformController: _transformController,
|
||||
padding: _viewportMargin,
|
||||
keyboardFocusNode: _sharedFocusNode),
|
||||
return Stack(fit: StackFit.expand, children: [
|
||||
if (_viewer != null)
|
||||
Positioned.fill(
|
||||
child: ExampleViewport(
|
||||
viewer: _viewer!,
|
||||
entityTransformController: _transformController,
|
||||
padding: _viewportMargin,
|
||||
keyboardFocusNode: _sharedFocusNode),
|
||||
),
|
||||
Positioned(
|
||||
bottom: 30,
|
||||
left: 0,
|
||||
right: 10,
|
||||
height: 30,
|
||||
child: Container(
|
||||
height: 30,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
color: Colors.white.withOpacity(0.25),
|
||||
),
|
||||
Positioned(
|
||||
bottom: 30,
|
||||
left: 0,
|
||||
right: 10,
|
||||
height: 30,
|
||||
child: Container(
|
||||
height: 30,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
color: Colors.white.withOpacity(0.25),
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
ControllerMenu(
|
||||
sharedFocusNode: _sharedFocusNode,
|
||||
controller: _plugin,
|
||||
onToggleViewport: () {
|
||||
setState(() {
|
||||
_viewportMargin =
|
||||
(_viewportMargin == EdgeInsets.zero)
|
||||
? const EdgeInsets.all(30)
|
||||
: EdgeInsets.zero;
|
||||
});
|
||||
},
|
||||
onControllerDestroyed: () {},
|
||||
onControllerCreated: () {}),
|
||||
SceneMenu(
|
||||
sharedFocusNode: _sharedFocusNode,
|
||||
controller: _plugin,
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
await _plugin.viewer.loadGlb(
|
||||
'assets/shapes/shapes.glb',
|
||||
numInstances: 1);
|
||||
},
|
||||
child: Container(
|
||||
color: Colors.transparent,
|
||||
child: const Text("shapes.glb"))),
|
||||
const SizedBox(width: 5),
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
await _plugin.viewer.loadGlb('assets/1.glb');
|
||||
},
|
||||
child: Container(
|
||||
color: Colors.transparent,
|
||||
child: const Text("1.glb"))),
|
||||
const SizedBox(width: 5),
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
await _plugin.viewer.loadGlb('assets/2.glb');
|
||||
},
|
||||
child: Container(
|
||||
color: Colors.transparent,
|
||||
child: const Text("2.glb"))),
|
||||
const SizedBox(width: 5),
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
await _plugin.viewer.loadGlb('assets/3.glb');
|
||||
},
|
||||
child: Container(
|
||||
color: Colors.transparent,
|
||||
child: const Text("3.glb"))),
|
||||
Expanded(child: Container()),
|
||||
]))),
|
||||
if (isInitialized) ...[
|
||||
Positioned(top:10, left:10, width:200, height:200, child:Container(
|
||||
child:EntityListWidget(controller: _plugin.viewer))),
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.only(top: 10, left: 20, right: 20),
|
||||
// child: ValueListenableBuilder(
|
||||
// valueListenable: showProjectionMatrices,
|
||||
// builder: (ctx, value, child) => CameraMatrixOverlay(
|
||||
// controller: _plugin.viewer, showProjectionMatrices: value)),
|
||||
// ),
|
||||
// Align(
|
||||
// alignment: Alignment.topRight,
|
||||
// child: PickerResultWidget(controller: _plugin.viewer),
|
||||
// )
|
||||
]
|
||||
]);
|
||||
});
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
child:
|
||||
Row(crossAxisAlignment: CrossAxisAlignment.center, children: [
|
||||
ViewerMenu(
|
||||
sharedFocusNode: _sharedFocusNode,
|
||||
viewer: _viewer,
|
||||
onToggleViewport: () {
|
||||
setState(() {
|
||||
_viewportMargin = (_viewportMargin == EdgeInsets.zero)
|
||||
? const EdgeInsets.all(30)
|
||||
: EdgeInsets.zero;
|
||||
});
|
||||
},
|
||||
onViewerDestroyed: () {
|
||||
setState(() {
|
||||
_viewer = null;
|
||||
});
|
||||
},
|
||||
onViewerCreated: (v) {
|
||||
setState(() {
|
||||
_viewer = v;
|
||||
});
|
||||
}),
|
||||
SceneMenu(
|
||||
sharedFocusNode: _sharedFocusNode,
|
||||
controller: _viewer,
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
await _viewer!
|
||||
.loadGlb('assets/shapes/shapes.glb', numInstances: 1);
|
||||
},
|
||||
child: Container(
|
||||
color: Colors.transparent,
|
||||
child: const Text("shapes.glb"))),
|
||||
const SizedBox(width: 5),
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
await _viewer!.loadGlb('assets/1.glb');
|
||||
},
|
||||
child: Container(
|
||||
color: Colors.transparent, child: const Text("1.glb"))),
|
||||
const SizedBox(width: 5),
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
await _viewer!.loadGlb('assets/2.glb');
|
||||
},
|
||||
child: Container(
|
||||
color: Colors.transparent, child: const Text("2.glb"))),
|
||||
const SizedBox(width: 5),
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
await _viewer!.loadGlb('assets/3.glb');
|
||||
},
|
||||
child: Container(
|
||||
color: Colors.transparent, child: const Text("3.glb"))),
|
||||
Expanded(child: Container()),
|
||||
]))),
|
||||
if (_viewer != null) ...[
|
||||
Positioned(
|
||||
top: 10,
|
||||
left: 10,
|
||||
width: 200,
|
||||
height: 200,
|
||||
child: Container(child: EntityListWidget(controller: _viewer!))),
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.only(top: 10, left: 20, right: 20),
|
||||
// child: ValueListenableBuilder(
|
||||
// valueListenable: showProjectionMatrices,
|
||||
// builder: (ctx, value, child) => CameraMatrixOverlay(
|
||||
// controller: _viewer!, showProjectionMatrices: value)),
|
||||
// ),
|
||||
// Align(
|
||||
// alignment: Alignment.topRight,
|
||||
// child: PickerResultWidget(controller: _viewer!),
|
||||
// )
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user