blob: 1207504e7cc5d64300328789d24d6e4d90283d2d [file] [log] [blame]
// Copyright 2018 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:example_modular_models/shape.dart';
import 'package:fuchsia_modular/module.dart';
import 'circle_renderer.dart';
import 'square_renderer.dart';
const _circleAction = 'com.fuchsia.shapes_mod.show_circle';
const _squareAction = 'com.fuchsia.shapes_mod.show_square';
class RootIntentHandler extends IntentHandler {
@override
void handleIntent(Intent intent) {
final stream = intent
.getEntity(name: 'shape', codec: ShapeCodec())
.watch()
.cast<Shape>();
if (intent.action == _circleAction) {
CircleRenderer().render(stream);
} else if (intent.action == _squareAction) {
SquareRenderer().render(stream);
} else {
print('Skipping unknown intent $intent');
}
}
}