mirror of https://github.com/flutter/samples.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.3 KiB
48 lines
1.3 KiB
2 years ago
|
import 'package:flutter/material.dart';
|
||
|
|
||
|
import 'app_state.dart';
|
||
|
import 'app_state_manager.dart';
|
||
|
|
||
|
/// The toggle buttons that can be selected.
|
||
|
enum ToggleButtonsState {
|
||
|
bold,
|
||
|
italic,
|
||
|
underline,
|
||
|
}
|
||
|
|
||
|
class FormattingToolbar extends StatelessWidget {
|
||
|
const FormattingToolbar({super.key});
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
final AppStateManager manager = AppStateManager.of(context);
|
||
|
|
||
|
return Padding(
|
||
|
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
||
|
child: Row(
|
||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||
|
children: [
|
||
|
ToggleButtons(
|
||
|
borderRadius: const BorderRadius.all(Radius.circular(4.0)),
|
||
|
isSelected: [
|
||
|
manager.appState.toggleButtonsState
|
||
|
.contains(ToggleButtonsState.bold),
|
||
|
manager.appState.toggleButtonsState
|
||
|
.contains(ToggleButtonsState.italic),
|
||
|
manager.appState.toggleButtonsState
|
||
|
.contains(ToggleButtonsState.underline),
|
||
|
],
|
||
|
onPressed: (index) => AppStateWidget.of(context)
|
||
|
.updateToggleButtonsStateOnButtonPressed(index),
|
||
|
children: const [
|
||
|
Icon(Icons.format_bold),
|
||
|
Icon(Icons.format_italic),
|
||
|
Icon(Icons.format_underline),
|
||
|
],
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
}
|