import 'package:flutter/material.dart'; /// A single icon button that fills with a solid circle when active — /// the building block for Drive-style toggle controls. class ToggleIconButton extends StatelessWidget { final IconData icon; final bool isSelected; final VoidCallback onTap; final String? tooltip; const ToggleIconButton({ super.key, required this.icon, required this.isSelected, required this.onTap, this.tooltip, }); @override Widget build(BuildContext context) { final colorScheme = Theme.of(context).colorScheme; final button = Material( color: isSelected ? colorScheme.primaryContainer : Colors.transparent, shape: const CircleBorder(), child: InkWell( onTap: onTap, customBorder: const CircleBorder(), child: Padding( padding: const EdgeInsets.all(8), child: Icon( icon, size: 20, color: isSelected ? colorScheme.onPrimaryContainer : colorScheme.onSurfaceVariant, ), ), ), ); return tooltip != null ? Tooltip(message: tooltip!, child: button) : button; } } /// A pill-shaped row of [ToggleIconButton]s sharing one background, matching /// the list/grid view switch seen in Google Drive's toolbar. class SegmentedIconGroup extends StatelessWidget { final List children; const SegmentedIconGroup({super.key, required this.children}); @override Widget build(BuildContext context) { final colorScheme = Theme.of(context).colorScheme; return Container( padding: const EdgeInsets.all(2), decoration: BoxDecoration( color: colorScheme.surfaceContainerHigh, borderRadius: BorderRadius.circular(20), ), child: Row(mainAxisSize: MainAxisSize.min, children: children), ); } }