Skip to content

Commit

Permalink
Active unit color (apache#23593)
Browse files Browse the repository at this point in the history
  • Loading branch information
darkhan.nausharipov committed Oct 21, 2022
1 parent e3b4385 commit d9acc0f
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions learning/tour-of-beam/frontend/lib/pages/tour/widgets/unit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import '../../../models/unit.dart';
import '../controllers/content_tree.dart';
import 'tour_progress_indicator.dart';

class UnitWidget extends StatelessWidget {
class UnitWidget extends StatefulWidget {
final UnitModel unit;
final ContentTreeController contentTreeController;

Expand All @@ -33,16 +33,39 @@ class UnitWidget extends StatelessWidget {
required this.contentTreeController,
});

@override
State<UnitWidget> createState() => _UnitWidgetState();
}

class _UnitWidgetState extends State<UnitWidget> {
@override
void initState() {
super.initState();
widget.contentTreeController.addListener(() {
setState(() {});
});
}

@override
Widget build(BuildContext context) {
return ClickableWidget(
onTap: () => contentTreeController.onNodeTap(unit),
onTap: () => widget.contentTreeController.onNodeTap(widget.unit),
child: Padding(
padding: const EdgeInsets.symmetric(vertical: BeamSizes.size10),
child: Row(
children: [
TourProgressIndicator(assetPath: Assets.svg.unitProgress0),
Expanded(child: Text(unit.title)),
Expanded(
child: Text(
widget.unit.title,
style: TextStyle(
color: widget.contentTreeController.currentNode?.id ==
widget.unit.id
? Theme.of(context).primaryColor
: null,
),
),
),
],
),
),
Expand Down

0 comments on commit d9acc0f

Please sign in to comment.