1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-08 22:09:06 +00:00
Files
samples/simplistic_editor/lib/formatting_toolbar.dart
Renzo Olivares c00e838c51 Refactor Simplistic_Editor (#1375)
* refactor out FormattingToolbar and TextEditingDeltaHistoryView from main`

* replace togglebuttonstatemanager and texteditingdeltahistorymanager with appstatemanager

* fix up tests

* clean up

* Add ReplacementTextEditingController to AppState

* formatting

* `dart format`

Co-authored-by: Renzo Olivares <roliv@google.com>
Co-authored-by: Brett Morgan <brettmorgan@google.com>
2022-08-11 18:06:32 +10:00

48 lines
1.3 KiB
Dart

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),
],
),
],
),
);
}
}