123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- import 'package:flutter/material.dart';
- import 'package:flyinsono/lab/components/rect_icon_button.dart';
- class ViewModeSwitcher extends StatefulWidget {
- const ViewModeSwitcher({
- super.key,
- required this.viewMode,
- required this.onModeChanged,
- });
- final ViewMode viewMode;
- final ValueChanged onModeChanged;
- @override
- State<ViewModeSwitcher> createState() => _ViewModeSwitcherState();
- }
- class _ViewModeSwitcherState extends State<ViewModeSwitcher> {
- @override
- void initState() {
- super.initState();
- }
- @override
- Widget build(BuildContext context) {
- return Row(
- children: [
- RectIconButton(
- onPressed: () {
- widget.onModeChanged(ViewMode.grid);
- },
- isSelected: widget.viewMode == ViewMode.grid,
- tooltipMessage: "切换为网格视图",
- ),
- SizedBox(width: 5),
- RectIconButton(
- onPressed: () {
- widget.onModeChanged(ViewMode.list);
- },
- isSelected: widget.viewMode == ViewMode.list,
- icon: Icons.menu_rounded,
- tooltipMessage: "切换为列表视图",
- ),
- ],
- );
- }
- }
- enum ViewMode { grid, list }
|