diff --git a/lib/view/duration_dropdown_button.dart b/lib/view/common/duration_dropdown_button.dart similarity index 100% rename from lib/view/duration_dropdown_button.dart rename to lib/view/common/duration_dropdown_button.dart diff --git a/lib/view/link.dart b/lib/view/common/link.dart similarity index 100% rename from lib/view/link.dart rename to lib/view/common/link.dart diff --git a/lib/view/section_description.dart b/lib/view/common/section_description.dart similarity index 100% rename from lib/view/section_description.dart rename to lib/view/common/section_description.dart diff --git a/lib/view/selectable_svg_image.dart b/lib/view/common/selectable_svg_image.dart similarity index 100% rename from lib/view/selectable_svg_image.dart rename to lib/view/common/selectable_svg_image.dart diff --git a/lib/view/settings_section.dart b/lib/view/common/settings_section.dart similarity index 100% rename from lib/view/settings_section.dart rename to lib/view/common/settings_section.dart diff --git a/lib/view/common/title_bar_tab.dart b/lib/view/common/title_bar_tab.dart new file mode 100644 index 00000000..e8f9483e --- /dev/null +++ b/lib/view/common/title_bar_tab.dart @@ -0,0 +1,35 @@ +import 'package:flutter/material.dart'; + +class TitleBarTab extends StatelessWidget { + const TitleBarTab({ + super.key, + required this.text, + required this.iconData, + }); + + final String text; + final IconData iconData; + + @override + Widget build(BuildContext context) { + return Tab( + child: Row( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon(iconData), + const SizedBox( + width: 5, + ), + Flexible( + child: Text( + text, + textAlign: TextAlign.center, + overflow: TextOverflow.ellipsis, + ), + ) + ], + ), + ); + } +} diff --git a/lib/view/pages/accessibility/global_section.dart b/lib/view/pages/accessibility/global_section.dart index e58c1090..33526cba 100644 --- a/lib/view/pages/accessibility/global_section.dart +++ b/lib/view/pages/accessibility/global_section.dart @@ -2,9 +2,9 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:settings/constants.dart'; import 'package:settings/l10n/l10n.dart'; +import 'package:settings/view/common/settings_section.dart'; import 'package:settings/view/common/yaru_switch_row.dart'; import 'package:settings/view/pages/accessibility/accessibility_model.dart'; -import 'package:settings/view/settings_section.dart'; class GlobalSection extends StatelessWidget { const GlobalSection({super.key}); diff --git a/lib/view/pages/accessibility/hearing_section.dart b/lib/view/pages/accessibility/hearing_section.dart index e499fbda..44b60fb0 100644 --- a/lib/view/pages/accessibility/hearing_section.dart +++ b/lib/view/pages/accessibility/hearing_section.dart @@ -2,10 +2,10 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:settings/constants.dart'; import 'package:settings/l10n/l10n.dart'; +import 'package:settings/view/common/settings_section.dart'; import 'package:settings/view/common/yaru_extra_option_row.dart'; import 'package:settings/view/pages/accessibility/accessibility_model.dart'; import 'package:settings/view/pages/settings_simple_dialog.dart'; -import 'package:settings/view/settings_section.dart'; import 'package:yaru_icons/yaru_icons.dart'; import 'package:yaru_widgets/yaru_widgets.dart'; diff --git a/lib/view/pages/accessibility/pointing_and_clicking_section.dart b/lib/view/pages/accessibility/pointing_and_clicking_section.dart index 1b436395..0276eb97 100644 --- a/lib/view/pages/accessibility/pointing_and_clicking_section.dart +++ b/lib/view/pages/accessibility/pointing_and_clicking_section.dart @@ -2,11 +2,11 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:settings/constants.dart'; import 'package:settings/l10n/l10n.dart'; +import 'package:settings/view/common/settings_section.dart'; import 'package:settings/view/common/yaru_slider_row.dart'; import 'package:settings/view/common/yaru_switch_row.dart'; import 'package:settings/view/pages/accessibility/accessibility_model.dart'; import 'package:settings/view/pages/settings_simple_dialog.dart'; -import 'package:settings/view/settings_section.dart'; import 'package:yaru_icons/yaru_icons.dart'; import 'package:yaru_widgets/yaru_widgets.dart'; diff --git a/lib/view/pages/accessibility/seeing_section.dart b/lib/view/pages/accessibility/seeing_section.dart index 1775906a..f6894f8a 100644 --- a/lib/view/pages/accessibility/seeing_section.dart +++ b/lib/view/pages/accessibility/seeing_section.dart @@ -5,13 +5,13 @@ import 'package:provider/provider.dart'; import 'package:settings/constants.dart'; import 'package:settings/l10n/l10n.dart'; import 'package:settings/utils.dart'; +import 'package:settings/view/common/settings_section.dart'; import 'package:settings/view/common/yaru_checkbox_row.dart'; import 'package:settings/view/common/yaru_extra_option_row.dart'; import 'package:settings/view/common/yaru_slider_row.dart'; import 'package:settings/view/common/yaru_switch_row.dart'; import 'package:settings/view/pages/accessibility/accessibility_model.dart'; import 'package:settings/view/pages/settings_simple_dialog.dart'; -import 'package:settings/view/settings_section.dart'; import 'package:yaru_icons/yaru_icons.dart'; import 'package:yaru_widgets/yaru_widgets.dart'; diff --git a/lib/view/pages/accessibility/typing_section.dart b/lib/view/pages/accessibility/typing_section.dart index b672aacd..82122d6f 100644 --- a/lib/view/pages/accessibility/typing_section.dart +++ b/lib/view/pages/accessibility/typing_section.dart @@ -2,13 +2,13 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:settings/constants.dart'; import 'package:settings/l10n/l10n.dart'; +import 'package:settings/view/common/settings_section.dart'; import 'package:settings/view/common/yaru_checkbox_row.dart'; import 'package:settings/view/common/yaru_extra_option_row.dart'; import 'package:settings/view/common/yaru_slider_row.dart'; import 'package:settings/view/common/yaru_switch_row.dart'; import 'package:settings/view/pages/accessibility/accessibility_model.dart'; import 'package:settings/view/pages/settings_simple_dialog.dart'; -import 'package:settings/view/settings_section.dart'; import 'package:yaru_icons/yaru_icons.dart'; import 'package:yaru_widgets/yaru_widgets.dart'; diff --git a/lib/view/pages/appearance/dock_section.dart b/lib/view/pages/appearance/dock_section.dart index c4a0a134..dd3e4b0b 100644 --- a/lib/view/pages/appearance/dock_section.dart +++ b/lib/view/pages/appearance/dock_section.dart @@ -4,11 +4,11 @@ import 'package:provider/provider.dart'; import 'package:settings/constants.dart'; import 'package:settings/l10n/l10n.dart'; import 'package:settings/utils.dart'; +import 'package:settings/view/common/selectable_svg_image.dart'; +import 'package:settings/view/common/settings_section.dart'; import 'package:settings/view/common/yaru_slider_row.dart'; import 'package:settings/view/common/yaru_switch_row.dart'; import 'package:settings/view/pages/appearance/dock_model.dart'; -import 'package:settings/view/selectable_svg_image.dart'; -import 'package:settings/view/settings_section.dart'; import 'package:yaru_widgets/yaru_widgets.dart'; class DockSection extends StatelessWidget { diff --git a/lib/view/pages/appearance/theme_section.dart b/lib/view/pages/appearance/theme_section.dart index 32e651ba..d33d00d7 100644 --- a/lib/view/pages/appearance/theme_section.dart +++ b/lib/view/pages/appearance/theme_section.dart @@ -3,8 +3,8 @@ import 'package:linux_system_info/linux_system_info.dart'; import 'package:provider/provider.dart'; import 'package:settings/constants.dart'; import 'package:settings/view/app_theme.dart'; +import 'package:settings/view/common/settings_section.dart'; import 'package:settings/view/common/yaru_switch_row.dart'; -import 'package:settings/view/settings_section.dart'; import 'package:yaru/yaru.dart'; import 'package:yaru_icons/yaru_icons.dart'; import 'package:yaru_widgets/yaru_widgets.dart'; diff --git a/lib/view/pages/bluetooth/bluetooth_page.dart b/lib/view/pages/bluetooth/bluetooth_page.dart index 934c30c9..b61c43ea 100644 --- a/lib/view/pages/bluetooth/bluetooth_page.dart +++ b/lib/view/pages/bluetooth/bluetooth_page.dart @@ -3,11 +3,11 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:settings/constants.dart'; import 'package:settings/l10n/l10n.dart'; +import 'package:settings/view/common/settings_section.dart'; import 'package:settings/view/common/yaru_switch_row.dart'; import 'package:settings/view/pages/bluetooth/bluetooth_device_row.dart'; import 'package:settings/view/pages/bluetooth/bluetooth_model.dart'; import 'package:settings/view/pages/settings_page.dart'; -import 'package:settings/view/settings_section.dart'; import 'package:ubuntu_service/ubuntu_service.dart'; import 'package:yaru_widgets/yaru_widgets.dart'; diff --git a/lib/view/pages/connections/connections_page.dart b/lib/view/pages/connections/connections_page.dart index 56a7fe48..ede0cfe8 100644 --- a/lib/view/pages/connections/connections_page.dart +++ b/lib/view/pages/connections/connections_page.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:nm/nm.dart'; import 'package:provider/provider.dart'; import 'package:settings/l10n/l10n.dart'; +import 'package:settings/view/common/title_bar_tab.dart'; import 'package:settings/view/pages/connections/wifi_content.dart'; import 'package:settings/view/pages/settings_page.dart'; import 'package:ubuntu_service/ubuntu_service.dart'; @@ -33,8 +34,7 @@ class ConnectionsPage extends StatefulWidget { State createState() => _ConnectionsPageState(); } -class _ConnectionsPageState extends State - with SingleTickerProviderStateMixin { +class _ConnectionsPageState extends State { @override Widget build(BuildContext context) { final wifiModel = context.watch(); @@ -43,21 +43,30 @@ class _ConnectionsPageState extends State length: 3, child: Scaffold( appBar: YaruWindowTitleBar( + titleSpacing: 0, centerTitle: true, border: BorderSide.none, backgroundColor: Theme.of(context).scaffoldBackgroundColor, title: const SizedBox( - width: 400, - child: TabBar( - isScrollable: false, - tabs: [ - _Tab(text: 'Wi-Fi', iconData: YaruIcons.network_wireless), - _Tab(text: 'Ethernet', iconData: YaruIcons.network_wired), - _Tab( - iconData: YaruIcons.network_cellular, - text: 'Cellular', - ) - ], + width: 450, + child: Padding( + padding: EdgeInsets.only(right: 50), + child: TabBar( + tabs: [ + TitleBarTab( + text: 'Wi-Fi', + iconData: YaruIcons.network_wireless, + ), + TitleBarTab( + text: 'Ethernet', + iconData: YaruIcons.network_wired, + ), + TitleBarTab( + iconData: YaruIcons.network_cellular, + text: 'Cellular', + ) + ], + ), ), ), ), @@ -82,36 +91,3 @@ class _ConnectionsPageState extends State ); } } - -class _Tab extends StatelessWidget { - const _Tab({ - required this.text, - required this.iconData, - }); - - final String text; - final IconData iconData; - - @override - Widget build(BuildContext context) { - return Tab( - child: Row( - mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Icon(iconData), - const SizedBox( - width: 5, - ), - Flexible( - child: Text( - text, - textAlign: TextAlign.center, - overflow: TextOverflow.ellipsis, - ), - ) - ], - ), - ); - } -} diff --git a/lib/view/pages/connections/wifi_content.dart b/lib/view/pages/connections/wifi_content.dart index 310e324d..0a3eb6a1 100644 --- a/lib/view/pages/connections/wifi_content.dart +++ b/lib/view/pages/connections/wifi_content.dart @@ -2,10 +2,10 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:settings/constants.dart'; import 'package:settings/l10n/l10n.dart'; +import 'package:settings/view/common/settings_section.dart'; import 'package:settings/view/common/yaru_switch_row.dart'; import 'package:settings/view/pages/connections/models/access_point_model.dart'; import 'package:settings/view/pages/settings_page.dart'; -import 'package:settings/view/settings_section.dart'; import 'package:yaru_icons/yaru_icons.dart'; import 'data/authentication.dart'; diff --git a/lib/view/pages/date_and_time/date_time_page.dart b/lib/view/pages/date_and_time/date_time_page.dart index 85c67cdc..4afc313d 100644 --- a/lib/view/pages/date_and_time/date_time_page.dart +++ b/lib/view/pages/date_and_time/date_time_page.dart @@ -4,12 +4,12 @@ import 'package:provider/provider.dart'; import 'package:settings/constants.dart'; import 'package:settings/l10n/l10n.dart'; import 'package:settings/services/settings_service.dart'; +import 'package:settings/view/common/settings_section.dart'; import 'package:settings/view/common/yaru_switch_row.dart'; import 'package:settings/view/pages/date_and_time/date_time_model.dart'; import 'package:settings/view/pages/date_and_time/timezones.dart'; import 'package:settings/view/pages/settings_alert_dialog.dart'; import 'package:settings/view/pages/settings_page.dart'; -import 'package:settings/view/settings_section.dart'; import 'package:ubuntu_service/ubuntu_service.dart'; import 'package:yaru_widgets/yaru_widgets.dart'; diff --git a/lib/view/pages/displays/displays_page.dart b/lib/view/pages/displays/displays_page.dart index deaa9cf0..c375483f 100644 --- a/lib/view/pages/displays/displays_page.dart +++ b/lib/view/pages/displays/displays_page.dart @@ -3,14 +3,15 @@ import 'package:provider/provider.dart'; import 'package:settings/constants.dart'; import 'package:settings/l10n/l10n.dart'; import 'package:settings/services/display/display_service.dart'; +import 'package:settings/view/common/title_bar_tab.dart'; import 'package:settings/view/pages/displays/displays_configuration.dart'; import 'package:settings/view/pages/displays/displays_model.dart'; import 'package:settings/view/pages/displays/nightlight_page.dart'; import 'package:settings/view/pages/displays/widgets/monitor_section.dart'; import 'package:settings/view/pages/settings_page.dart'; -import 'package:settings/view/tabbed_page.dart'; import 'package:ubuntu_service/ubuntu_service.dart'; import 'package:yaru_icons/yaru_icons.dart'; +import 'package:yaru_widgets/yaru_widgets.dart'; class DisplaysPage extends StatefulWidget { /// private as we have to pass from create method below @@ -45,16 +46,40 @@ class _DisplaysPageState extends State { return ValueListenableBuilder( valueListenable: model.configuration, builder: (context, configurations, _) { - return TabbedPage( - width: kDefaultWidth, - tabIcons: DisplaysPageSection.values - .map((e) => Icon(e.icon(context))) - .toList(), - tabTitles: - DisplaysPageSection.values.map((e) => e.name(context)).toList(), - views: DisplaysPageSection.values - .map((e) => _buildPage(e, model, configurations)) - .toList(), + return DefaultTabController( + length: DisplaysPageSection.values.length, + child: Scaffold( + appBar: YaruWindowTitleBar( + backgroundColor: Theme.of(context).scaffoldBackgroundColor, + border: BorderSide.none, + title: SizedBox( + width: 350, + child: Padding( + padding: const EdgeInsets.only(right: 50), + child: TabBar( + tabs: DisplaysPageSection.values + .map( + (e) => TitleBarTab( + text: e.name(context), + iconData: e.icon(context), + ), + ) + .toList(), + ), + ), + ), + ), + body: TabBarView( + children: DisplaysPageSection.values + .map( + (e) => Padding( + padding: const EdgeInsets.only(top: kYaruPagePadding), + child: _buildPage(e, model, configurations), + ), + ) + .toList(), + ), + ), ); }, ); diff --git a/lib/view/pages/displays/nightlight_page.dart b/lib/view/pages/displays/nightlight_page.dart index 723d2ff1..cb857d12 100644 --- a/lib/view/pages/displays/nightlight_page.dart +++ b/lib/view/pages/displays/nightlight_page.dart @@ -1,12 +1,13 @@ import 'package:flutter/widgets.dart'; import 'package:flutter_spinbox/material.dart'; import 'package:provider/provider.dart'; +import 'package:settings/constants.dart'; import 'package:settings/l10n/l10n.dart'; import 'package:settings/services/settings_service.dart'; +import 'package:settings/view/common/settings_section.dart'; import 'package:settings/view/common/yaru_slider_row.dart'; import 'package:settings/view/common/yaru_switch_row.dart'; import 'package:settings/view/pages/displays/nightlight_model.dart'; -import 'package:settings/view/settings_section.dart'; import 'package:ubuntu_service/ubuntu_service.dart'; import 'package:yaru_widgets/yaru_widgets.dart'; @@ -24,6 +25,7 @@ class NightlightPage extends StatelessWidget { Widget build(BuildContext context) { final model = context.watch(); return SettingsSection( + width: kDefaultWidth, headline: Text(context.l10n.nightLightPageTitle), children: [ YaruSwitchRow( diff --git a/lib/view/pages/displays/widgets/monitor_section.dart b/lib/view/pages/displays/widgets/monitor_section.dart index 10020209..7cda2660 100644 --- a/lib/view/pages/displays/widgets/monitor_section.dart +++ b/lib/view/pages/displays/widgets/monitor_section.dart @@ -2,10 +2,10 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:settings/constants.dart'; import 'package:settings/l10n/l10n.dart'; +import 'package:settings/view/common/settings_section.dart'; import 'package:settings/view/common/yaru_switch_row.dart'; import 'package:settings/view/pages/displays/displays_configuration.dart'; import 'package:settings/view/pages/displays/displays_model.dart'; -import 'package:settings/view/settings_section.dart'; import 'package:yaru_widgets/yaru_widgets.dart'; class MonitorSection extends StatelessWidget { diff --git a/lib/view/pages/info/info_page.dart b/lib/view/pages/info/info_page.dart index 7176386d..f6950cbb 100644 --- a/lib/view/pages/info/info_page.dart +++ b/lib/view/pages/info/info_page.dart @@ -6,10 +6,10 @@ import 'package:settings/constants.dart'; import 'package:settings/l10n/l10n.dart'; import 'package:settings/services/hostname_service.dart'; import 'package:settings/services/pdf_service.dart'; +import 'package:settings/view/common/settings_section.dart'; import 'package:settings/view/common/yaru_single_info_row.dart'; import 'package:settings/view/pages/settings_page.dart'; import 'package:settings/view/pages/settings_simple_dialog.dart'; -import 'package:settings/view/settings_section.dart'; import 'package:ubuntu_service/ubuntu_service.dart'; import 'package:udisks/udisks.dart'; import 'package:url_launcher/url_launcher.dart'; diff --git a/lib/view/pages/keyboard/input_source_section.dart b/lib/view/pages/keyboard/input_source_section.dart index ea609f96..13873b77 100644 --- a/lib/view/pages/keyboard/input_source_section.dart +++ b/lib/view/pages/keyboard/input_source_section.dart @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:settings/constants.dart'; +import 'package:settings/view/common/settings_section.dart'; import 'package:settings/view/pages/keyboard/input_source_model.dart'; -import 'package:settings/view/settings_section.dart'; import 'package:yaru_widgets/yaru_widgets.dart'; class InputSourceSection extends StatelessWidget { diff --git a/lib/view/pages/keyboard/input_source_selection_section.dart b/lib/view/pages/keyboard/input_source_selection_section.dart index c903122e..ecdd4945 100644 --- a/lib/view/pages/keyboard/input_source_selection_section.dart +++ b/lib/view/pages/keyboard/input_source_selection_section.dart @@ -1,9 +1,9 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:settings/constants.dart'; +import 'package:settings/view/common/settings_section.dart'; import 'package:settings/view/pages/keyboard/input_source_model.dart'; import 'package:settings/view/pages/settings_simple_dialog.dart'; -import 'package:settings/view/settings_section.dart'; import 'package:yaru_icons/yaru_icons.dart'; import 'package:yaru_widgets/yaru_widgets.dart'; diff --git a/lib/view/pages/keyboard/keyboard_page.dart b/lib/view/pages/keyboard/keyboard_page.dart index 3c740e0a..410970cc 100644 --- a/lib/view/pages/keyboard/keyboard_page.dart +++ b/lib/view/pages/keyboard/keyboard_page.dart @@ -1,10 +1,10 @@ import 'package:flutter/material.dart'; -import 'package:settings/constants.dart'; import 'package:settings/l10n/l10n.dart'; +import 'package:settings/view/common/title_bar_tab.dart'; import 'package:settings/view/pages/keyboard/keyboard_settings_page.dart'; import 'package:settings/view/pages/keyboard/keyboard_shortcuts_page.dart'; -import 'package:settings/view/tabbed_page.dart'; import 'package:yaru_icons/yaru_icons.dart'; +import 'package:yaru_widgets/yaru_widgets.dart'; class KeyboardPage extends StatefulWidget { const KeyboardPage({super.key}); @@ -37,14 +37,40 @@ class _KeyboardPageState extends State @override Widget build(BuildContext context) { - return const TabbedPage( - tabIcons: [ - Icon(YaruIcons.keyboard), - Icon(YaruIcons.keyboard_shortcuts), - ], - tabTitles: ['Keyboard Settings', 'Keyboard Shortcuts'], - views: [KeyboardSettingsPage(), KeyboardShortcutsPage()], - width: kDefaultWidth, + const views = [KeyboardSettingsPage(), KeyboardShortcutsPage()]; + return DefaultTabController( + length: 2, + child: Scaffold( + appBar: YaruWindowTitleBar( + border: BorderSide.none, + backgroundColor: Theme.of(context).scaffoldBackgroundColor, + title: const SizedBox( + width: 400, + child: TabBar( + tabs: [ + TitleBarTab( + text: 'Keyboard Settings', + iconData: YaruIcons.keyboard, + ), + TitleBarTab( + text: 'Keyboard Shortcuts', + iconData: YaruIcons.keyboard_shortcuts, + ), + ], + ), + ), + ), + body: TabBarView( + children: views + .map( + (e) => Padding( + padding: const EdgeInsets.only(top: kYaruPagePadding), + child: e, + ), + ) + .toList(), + ), + ), ); } } diff --git a/lib/view/pages/keyboard/keyboard_shortcuts_page.dart b/lib/view/pages/keyboard/keyboard_shortcuts_page.dart index 2074e85c..56312d78 100644 --- a/lib/view/pages/keyboard/keyboard_shortcuts_page.dart +++ b/lib/view/pages/keyboard/keyboard_shortcuts_page.dart @@ -4,10 +4,10 @@ import 'package:settings/constants.dart'; import 'package:settings/schemas/schemas.dart'; import 'package:settings/services/keyboard_service.dart'; import 'package:settings/services/settings_service.dart'; +import 'package:settings/view/common/settings_section.dart'; import 'package:settings/view/pages/keyboard/keyboard_shortcut_row.dart'; import 'package:settings/view/pages/keyboard/keyboard_shortcuts_model.dart'; import 'package:settings/view/pages/settings_page.dart'; -import 'package:settings/view/settings_section.dart'; import 'package:ubuntu_service/ubuntu_service.dart'; class KeyboardShortcutsPage extends StatelessWidget { diff --git a/lib/view/pages/keyboard/special_characters_section.dart b/lib/view/pages/keyboard/special_characters_section.dart index fa0eec61..21057021 100644 --- a/lib/view/pages/keyboard/special_characters_section.dart +++ b/lib/view/pages/keyboard/special_characters_section.dart @@ -2,10 +2,10 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:settings/constants.dart'; import 'package:settings/l10n/l10n.dart'; +import 'package:settings/view/common/settings_section.dart'; import 'package:settings/view/common/yaru_switch_row.dart'; import 'package:settings/view/pages/keyboard/special_characters_model.dart'; import 'package:settings/view/pages/settings_simple_dialog.dart'; -import 'package:settings/view/settings_section.dart'; import 'package:yaru_icons/yaru_icons.dart'; import 'package:yaru_widgets/yaru_widgets.dart'; diff --git a/lib/view/pages/mouse_and_touchpad/general_section.dart b/lib/view/pages/mouse_and_touchpad/general_section.dart index 5a8b369d..87968fbc 100644 --- a/lib/view/pages/mouse_and_touchpad/general_section.dart +++ b/lib/view/pages/mouse_and_touchpad/general_section.dart @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:settings/constants.dart'; +import 'package:settings/view/common/settings_section.dart'; import 'package:settings/view/common/yaru_toggle_buttons_row.dart'; -import 'package:settings/view/settings_section.dart'; import 'mouse_and_touchpad_model.dart'; diff --git a/lib/view/pages/mouse_and_touchpad/mouse_section.dart b/lib/view/pages/mouse_and_touchpad/mouse_section.dart index d96d464b..10d07408 100644 --- a/lib/view/pages/mouse_and_touchpad/mouse_section.dart +++ b/lib/view/pages/mouse_and_touchpad/mouse_section.dart @@ -1,10 +1,10 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:settings/constants.dart'; +import 'package:settings/view/common/settings_section.dart'; import 'package:settings/view/common/yaru_slider_row.dart'; import 'package:settings/view/common/yaru_switch_row.dart'; import 'package:settings/view/pages/mouse_and_touchpad/mouse_and_touchpad_model.dart'; -import 'package:settings/view/settings_section.dart'; class MouseSection extends StatelessWidget { const MouseSection({super.key}); diff --git a/lib/view/pages/mouse_and_touchpad/touchpad_section.dart b/lib/view/pages/mouse_and_touchpad/touchpad_section.dart index 155c24ca..a4da19fa 100644 --- a/lib/view/pages/mouse_and_touchpad/touchpad_section.dart +++ b/lib/view/pages/mouse_and_touchpad/touchpad_section.dart @@ -1,10 +1,10 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:settings/constants.dart'; +import 'package:settings/view/common/settings_section.dart'; import 'package:settings/view/common/yaru_slider_row.dart'; import 'package:settings/view/common/yaru_switch_row.dart'; import 'package:settings/view/pages/mouse_and_touchpad/mouse_and_touchpad_model.dart'; -import 'package:settings/view/settings_section.dart'; class TouchpadSection extends StatelessWidget { const TouchpadSection({super.key}); diff --git a/lib/view/pages/multitasking/multi_tasking_page.dart b/lib/view/pages/multitasking/multi_tasking_page.dart index 0ad85ee1..b172aba8 100644 --- a/lib/view/pages/multitasking/multi_tasking_page.dart +++ b/lib/view/pages/multitasking/multi_tasking_page.dart @@ -6,10 +6,10 @@ import 'package:settings/constants.dart'; import 'package:settings/l10n/l10n.dart'; import 'package:settings/services/settings_service.dart'; import 'package:settings/utils.dart'; +import 'package:settings/view/common/settings_section.dart'; import 'package:settings/view/common/yaru_switch_row.dart'; import 'package:settings/view/pages/multitasking/multi_tasking_model.dart'; import 'package:settings/view/pages/settings_page.dart'; -import 'package:settings/view/settings_section.dart'; import 'package:ubuntu_service/ubuntu_service.dart'; import 'package:yaru_widgets/yaru_widgets.dart'; diff --git a/lib/view/pages/notifications/app_notifications_section.dart b/lib/view/pages/notifications/app_notifications_section.dart index 3a35f9fb..392283d2 100644 --- a/lib/view/pages/notifications/app_notifications_section.dart +++ b/lib/view/pages/notifications/app_notifications_section.dart @@ -2,9 +2,9 @@ import 'package:flutter/widgets.dart'; import 'package:provider/provider.dart'; import 'package:settings/constants.dart'; import 'package:settings/services/settings_service.dart'; +import 'package:settings/view/common/settings_section.dart'; import 'package:settings/view/common/yaru_switch_row.dart'; import 'package:settings/view/pages/notifications/notifications_model.dart'; -import 'package:settings/view/settings_section.dart'; import 'package:ubuntu_service/ubuntu_service.dart'; class AppNotificationsSection extends StatelessWidget { diff --git a/lib/view/pages/notifications/global_notifications_section.dart b/lib/view/pages/notifications/global_notifications_section.dart index c6bf978a..5a8324ad 100644 --- a/lib/view/pages/notifications/global_notifications_section.dart +++ b/lib/view/pages/notifications/global_notifications_section.dart @@ -1,9 +1,9 @@ import 'package:flutter/widgets.dart'; import 'package:provider/provider.dart'; import 'package:settings/constants.dart'; +import 'package:settings/view/common/settings_section.dart'; import 'package:settings/view/common/yaru_switch_row.dart'; import 'package:settings/view/pages/notifications/notifications_model.dart'; -import 'package:settings/view/settings_section.dart'; class GlobalNotificationsSection extends StatelessWidget { const GlobalNotificationsSection({super.key}); diff --git a/lib/view/pages/page_items.dart b/lib/view/pages/page_items.dart index 41343fc9..f0e4e393 100644 --- a/lib/view/pages/page_items.dart +++ b/lib/view/pages/page_items.dart @@ -63,6 +63,7 @@ List getPageItems(BuildContext context) => [ searchMatches: PrivacyPage.searchMatches, iconBuilder: (context, selected) => const Icon(YaruIcons.lock), title: context.l10n.privacyPageTitle, + hasAppBar: false, ), SettingsPageItem( titleBuilder: MultiTaskingPage.createTitle, @@ -120,6 +121,7 @@ List getPageItems(BuildContext context) => [ builder: DisplaysPage.create, searchMatches: DisplaysPage.searchMatches, title: context.l10n.displaysPageTitle, + hasAppBar: false, ), SettingsPageItem( titleBuilder: MouseAndTouchpadPage.createTitle, @@ -134,6 +136,7 @@ List getPageItems(BuildContext context) => [ builder: KeyboardPage.create, searchMatches: KeyboardPage.searchMatches, title: context.l10n.keyboardPageTitle, + hasAppBar: false, ), SettingsPageItem( titleBuilder: (context) => const Text('Printers'), diff --git a/lib/view/pages/power/battery_section.dart b/lib/view/pages/power/battery_section.dart index 3280c051..3e346dce 100644 --- a/lib/view/pages/power/battery_section.dart +++ b/lib/view/pages/power/battery_section.dart @@ -2,9 +2,9 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:settings/constants.dart'; import 'package:settings/l10n/l10n.dart'; +import 'package:settings/view/common/settings_section.dart'; import 'package:settings/view/pages/power/battery_model.dart'; import 'package:settings/view/pages/power/battery_widgets.dart'; -import 'package:settings/view/settings_section.dart'; import 'package:ubuntu_service/ubuntu_service.dart'; import 'package:upower/upower.dart'; import 'package:yaru_colors/yaru_colors.dart'; diff --git a/lib/view/pages/power/lid_close_section.dart b/lib/view/pages/power/lid_close_section.dart index eb1ca8fe..b576adc3 100644 --- a/lib/view/pages/power/lid_close_section.dart +++ b/lib/view/pages/power/lid_close_section.dart @@ -3,9 +3,9 @@ import 'package:provider/provider.dart'; import 'package:settings/constants.dart'; import 'package:settings/l10n/l10n.dart'; import 'package:settings/services/settings_service.dart'; +import 'package:settings/view/common/settings_section.dart'; import 'package:settings/view/pages/power/lid_close_action.dart'; import 'package:settings/view/pages/power/lid_close_model.dart'; -import 'package:settings/view/settings_section.dart'; import 'package:ubuntu_service/ubuntu_service.dart'; import 'package:yaru_widgets/yaru_widgets.dart'; diff --git a/lib/view/pages/power/power_profile_section.dart b/lib/view/pages/power/power_profile_section.dart index 256a44b7..ec566f77 100644 --- a/lib/view/pages/power/power_profile_section.dart +++ b/lib/view/pages/power/power_profile_section.dart @@ -3,10 +3,10 @@ import 'package:provider/provider.dart'; import 'package:settings/constants.dart'; import 'package:settings/l10n/l10n.dart'; import 'package:settings/services/power_profile_service.dart'; +import 'package:settings/view/common/settings_section.dart'; import 'package:settings/view/pages/power/power_profile_model.dart'; import 'package:settings/view/pages/power/power_profile_widgets.dart'; import 'package:settings/view/pages/power/power_profile_x.dart'; -import 'package:settings/view/settings_section.dart'; import 'package:ubuntu_service/ubuntu_service.dart'; import 'package:yaru_widgets/yaru_widgets.dart'; diff --git a/lib/view/pages/power/power_settings_dialogs.dart b/lib/view/pages/power/power_settings_dialogs.dart index 80327d64..82f562c7 100644 --- a/lib/view/pages/power/power_settings_dialogs.dart +++ b/lib/view/pages/power/power_settings_dialogs.dart @@ -2,8 +2,8 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:settings/constants.dart'; import 'package:settings/l10n/l10n.dart'; +import 'package:settings/view/common/duration_dropdown_button.dart'; import 'package:settings/view/common/yaru_switch_row.dart'; -import 'package:settings/view/duration_dropdown_button.dart'; import 'package:settings/view/pages/power/power_settings.dart'; import 'package:settings/view/pages/power/power_settings_model.dart'; import 'package:settings/view/pages/settings_simple_dialog.dart'; diff --git a/lib/view/pages/power/power_settings_section.dart b/lib/view/pages/power/power_settings_section.dart index 50ab9920..cd08d1a9 100644 --- a/lib/view/pages/power/power_settings_section.dart +++ b/lib/view/pages/power/power_settings_section.dart @@ -6,13 +6,13 @@ import 'package:settings/l10n/l10n.dart'; import 'package:settings/services/bluetooth_service.dart'; import 'package:settings/services/power_settings_service.dart'; import 'package:settings/services/settings_service.dart'; +import 'package:settings/view/common/duration_dropdown_button.dart'; +import 'package:settings/view/common/settings_section.dart'; import 'package:settings/view/common/yaru_slider_row.dart'; import 'package:settings/view/common/yaru_switch_row.dart'; -import 'package:settings/view/duration_dropdown_button.dart'; import 'package:settings/view/pages/power/power_settings.dart'; import 'package:settings/view/pages/power/power_settings_dialogs.dart'; import 'package:settings/view/pages/power/power_settings_model.dart'; -import 'package:settings/view/settings_section.dart'; import 'package:ubuntu_service/ubuntu_service.dart'; import 'package:yaru_icons/yaru_icons.dart'; import 'package:yaru_widgets/yaru_widgets.dart'; diff --git a/lib/view/pages/power/suspend_section.dart b/lib/view/pages/power/suspend_section.dart index 41920882..59e451cc 100644 --- a/lib/view/pages/power/suspend_section.dart +++ b/lib/view/pages/power/suspend_section.dart @@ -3,10 +3,10 @@ import 'package:provider/provider.dart'; import 'package:settings/constants.dart'; import 'package:settings/l10n/l10n.dart'; import 'package:settings/services/settings_service.dart'; +import 'package:settings/view/common/settings_section.dart'; import 'package:settings/view/common/yaru_switch_row.dart'; import 'package:settings/view/pages/power/suspend.dart'; import 'package:settings/view/pages/power/suspend_model.dart'; -import 'package:settings/view/settings_section.dart'; import 'package:ubuntu_service/ubuntu_service.dart'; import 'package:yaru_widgets/yaru_widgets.dart'; diff --git a/lib/view/pages/privacy/connectivity_page.dart b/lib/view/pages/privacy/connectivity_page.dart index 2a044d70..01c60f2f 100644 --- a/lib/view/pages/privacy/connectivity_page.dart +++ b/lib/view/pages/privacy/connectivity_page.dart @@ -3,11 +3,11 @@ import 'package:nm/nm.dart'; import 'package:provider/provider.dart'; import 'package:settings/constants.dart'; import 'package:settings/l10n/l10n.dart'; +import 'package:settings/view/common/section_description.dart'; +import 'package:settings/view/common/settings_section.dart'; import 'package:settings/view/common/yaru_switch_row.dart'; import 'package:settings/view/pages/privacy/connectivity_model.dart'; import 'package:settings/view/pages/settings_page.dart'; -import 'package:settings/view/section_description.dart'; -import 'package:settings/view/settings_section.dart'; import 'package:ubuntu_service/ubuntu_service.dart'; class ConnectivityPage extends StatefulWidget { diff --git a/lib/view/pages/privacy/house_keeping_page.dart b/lib/view/pages/privacy/house_keeping_page.dart index 51c77ded..3451a29e 100644 --- a/lib/view/pages/privacy/house_keeping_page.dart +++ b/lib/view/pages/privacy/house_keeping_page.dart @@ -4,12 +4,12 @@ import 'package:settings/constants.dart'; import 'package:settings/l10n/l10n.dart'; import 'package:settings/services/house_keeping_service.dart'; import 'package:settings/services/settings_service.dart'; +import 'package:settings/view/common/section_description.dart'; +import 'package:settings/view/common/settings_section.dart'; import 'package:settings/view/common/yaru_slider_row.dart'; import 'package:settings/view/common/yaru_switch_row.dart'; import 'package:settings/view/pages/privacy/privacy_model.dart'; import 'package:settings/view/pages/settings_page.dart'; -import 'package:settings/view/section_description.dart'; -import 'package:settings/view/settings_section.dart'; import 'package:ubuntu_service/ubuntu_service.dart'; import 'package:yaru_icons/yaru_icons.dart'; import 'package:yaru_widgets/yaru_widgets.dart'; diff --git a/lib/view/pages/privacy/location_page.dart b/lib/view/pages/privacy/location_page.dart index b344b4b5..89d918fc 100644 --- a/lib/view/pages/privacy/location_page.dart +++ b/lib/view/pages/privacy/location_page.dart @@ -3,12 +3,12 @@ import 'package:provider/provider.dart'; import 'package:settings/constants.dart'; import 'package:settings/l10n/l10n.dart'; import 'package:settings/services/settings_service.dart'; +import 'package:settings/view/common/link.dart'; +import 'package:settings/view/common/section_description.dart'; +import 'package:settings/view/common/settings_section.dart'; import 'package:settings/view/common/yaru_switch_row.dart'; -import 'package:settings/view/link.dart'; import 'package:settings/view/pages/privacy/location_model.dart'; import 'package:settings/view/pages/settings_page.dart'; -import 'package:settings/view/section_description.dart'; -import 'package:settings/view/settings_section.dart'; import 'package:ubuntu_service/ubuntu_service.dart'; const kPrivacyUrl = 'https://location.services.mozilla.com/privacy'; diff --git a/lib/view/pages/privacy/privacy_page.dart b/lib/view/pages/privacy/privacy_page.dart index fa61372f..b5fbe052 100644 --- a/lib/view/pages/privacy/privacy_page.dart +++ b/lib/view/pages/privacy/privacy_page.dart @@ -1,14 +1,14 @@ import 'package:flutter/material.dart'; -import 'package:settings/constants.dart'; import 'package:settings/l10n/l10n.dart'; +import 'package:settings/view/common/title_bar_tab.dart'; import 'package:settings/view/pages/privacy/connectivity_page.dart'; import 'package:settings/view/pages/privacy/house_keeping_page.dart'; import 'package:settings/view/pages/privacy/location_page.dart'; import 'package:settings/view/pages/privacy/reporting_page.dart'; import 'package:settings/view/pages/privacy/screen_saver_page.dart'; import 'package:settings/view/pages/settings_page.dart'; -import 'package:settings/view/tabbed_page.dart'; import 'package:yaru_icons/yaru_icons.dart'; +import 'package:yaru_widgets/yaru_widgets.dart'; class PrivacyPage extends StatelessWidget { const PrivacyPage({super.key}); @@ -30,39 +30,62 @@ class PrivacyPage extends StatelessWidget { @override Widget build(BuildContext context) { - return TabbedPage( - width: kDefaultWidth * 2, - tabIcons: const [ - Icon(YaruIcons.network), - Icon(YaruIcons.location), - Icon(YaruIcons.thunderbolt), - Icon(YaruIcons.trash), - Icon(YaruIcons.lock), - Icon(YaruIcons.question), - ], - tabTitles: [ - context.l10n.connectivityPageTitle, - context.l10n.locationPageTitle, - context.l10n.thunderBoltPageTitle, - context.l10n.houseKeepingPageTitle, - context.l10n.screenLockPageTitle, + final content = { + ConnectivityPage.create(context): ( + YaruIcons.network, + context.l10n.connectivityPageTitle + ), + LocationPage.create(context): ( + YaruIcons.location, + context.l10n.locationPageTitle + ), + const SettingsPage( + children: [ + Padding( + padding: EdgeInsets.all(8.0), + child: Text('Thunderbolt - Please implement 🥲️'), + ) + ], + ): (YaruIcons.thunderbolt, context.l10n.thunderBoltPageTitle), + HouseKeepingPage.create(context): ( + YaruIcons.trash, + context.l10n.houseKeepingPageTitle + ), + ScreenSaverPage.create(context): ( + YaruIcons.lock, + context.l10n.screenLockPageTitle + ), + ReportingPage.create(context): ( + YaruIcons.question, context.l10n.diagnosisPageTitle - ], - views: [ - ConnectivityPage.create(context), - LocationPage.create(context), - const SettingsPage( - children: [ - Padding( - padding: EdgeInsets.all(8.0), - child: Text('Thunderbolt - Please implement 🥲️'), - ) - ], + ), + }; + + return DefaultTabController( + length: content.length, + child: Scaffold( + appBar: YaruWindowTitleBar( + titleSpacing: kYaruPagePadding, + backgroundColor: Theme.of(context).scaffoldBackgroundColor, + border: BorderSide.none, + title: TabBar( + isScrollable: true, + tabs: content.entries + .map((e) => TitleBarTab(text: e.value.$2, iconData: e.value.$1)) + .toList(), + ), + ), + body: TabBarView( + children: content.entries + .map( + (e) => Padding( + padding: const EdgeInsets.only(top: kYaruPagePadding), + child: e.key, + ), + ) + .toList(), ), - HouseKeepingPage.create(context), - ScreenSaverPage.create(context), - ReportingPage.create(context), - ], + ), ); } } diff --git a/lib/view/pages/privacy/reporting_page.dart b/lib/view/pages/privacy/reporting_page.dart index 8a0cda35..1b405a47 100644 --- a/lib/view/pages/privacy/reporting_page.dart +++ b/lib/view/pages/privacy/reporting_page.dart @@ -3,12 +3,12 @@ import 'package:provider/provider.dart'; import 'package:settings/constants.dart'; import 'package:settings/l10n/l10n.dart'; import 'package:settings/services/settings_service.dart'; +import 'package:settings/view/common/link.dart'; +import 'package:settings/view/common/section_description.dart'; +import 'package:settings/view/common/settings_section.dart'; import 'package:settings/view/common/yaru_switch_row.dart'; -import 'package:settings/view/link.dart'; import 'package:settings/view/pages/privacy/reporting_model.dart'; import 'package:settings/view/pages/settings_page.dart'; -import 'package:settings/view/section_description.dart'; -import 'package:settings/view/settings_section.dart'; import 'package:ubuntu_service/ubuntu_service.dart'; const kUbuntuReportingLink = 'https://ubuntu.com/legal/data-privacy'; diff --git a/lib/view/pages/privacy/screen_saver_page.dart b/lib/view/pages/privacy/screen_saver_page.dart index 75c97d4a..6511311d 100644 --- a/lib/view/pages/privacy/screen_saver_page.dart +++ b/lib/view/pages/privacy/screen_saver_page.dart @@ -3,13 +3,13 @@ import 'package:provider/provider.dart'; import 'package:settings/constants.dart'; import 'package:settings/l10n/l10n.dart'; import 'package:settings/services/settings_service.dart'; +import 'package:settings/view/common/duration_dropdown_button.dart'; +import 'package:settings/view/common/section_description.dart'; +import 'package:settings/view/common/settings_section.dart'; import 'package:settings/view/common/yaru_switch_row.dart'; -import 'package:settings/view/duration_dropdown_button.dart'; import 'package:settings/view/pages/power/power_settings.dart'; import 'package:settings/view/pages/privacy/screen_saver_model.dart'; import 'package:settings/view/pages/settings_page.dart'; -import 'package:settings/view/section_description.dart'; -import 'package:settings/view/settings_section.dart'; import 'package:ubuntu_service/ubuntu_service.dart'; import 'package:yaru_widgets/yaru_widgets.dart'; diff --git a/lib/view/pages/region_and_language/region_and_language_page.dart b/lib/view/pages/region_and_language/region_and_language_page.dart index 7144ab4e..295324f6 100644 --- a/lib/view/pages/region_and_language/region_and_language_page.dart +++ b/lib/view/pages/region_and_language/region_and_language_page.dart @@ -4,9 +4,9 @@ import 'package:provider/provider.dart'; import 'package:settings/constants.dart'; import 'package:settings/l10n/l10n.dart'; import 'package:settings/services/locale_service.dart'; +import 'package:settings/view/common/settings_section.dart'; import 'package:settings/view/pages/region_and_language/region_and_language_model.dart'; import 'package:settings/view/pages/settings_page.dart'; -import 'package:settings/view/settings_section.dart'; import 'package:ubuntu_service/ubuntu_service.dart'; import 'package:yaru_icons/yaru_icons.dart'; import 'package:yaru_widgets/yaru_widgets.dart'; diff --git a/lib/view/pages/sound/sound_page.dart b/lib/view/pages/sound/sound_page.dart index ebff0c28..b791dfef 100644 --- a/lib/view/pages/sound/sound_page.dart +++ b/lib/view/pages/sound/sound_page.dart @@ -3,10 +3,10 @@ import 'package:provider/provider.dart'; import 'package:settings/constants.dart'; import 'package:settings/l10n/l10n.dart'; import 'package:settings/services/settings_service.dart'; +import 'package:settings/view/common/settings_section.dart'; import 'package:settings/view/common/yaru_switch_row.dart'; import 'package:settings/view/pages/settings_page.dart'; import 'package:settings/view/pages/sound/sound_model.dart'; -import 'package:settings/view/settings_section.dart'; import 'package:ubuntu_service/ubuntu_service.dart'; class SoundPage extends StatelessWidget { diff --git a/lib/view/search_app_bar.dart b/lib/view/search_app_bar.dart deleted file mode 100644 index e5c34596..00000000 --- a/lib/view/search_app_bar.dart +++ /dev/null @@ -1,118 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:yaru_widgets/yaru_widgets.dart'; - -/// Creates a search bar inside an [AppBar]. -/// -/// By default the text style will be, -/// ```dart -/// const TextStyle(fontSize: 18, fontWeight: FontWeight.w200) -/// ``` -/// -/// Example usage: -/// -/// ```dart -/// SearchAppBar( -/// searchHint: 'Search...', -/// searchController: TextEditingController(), -/// onChanged: (v) {}, -/// onEscape: () {}, -/// appBarHeight: AppBarTheme.of(context).toolbarHeight, -/// ) -/// ``` -class SearchAppBar extends StatelessWidget { - const SearchAppBar({ - super.key, - this.searchController, - required this.onChanged, - required this.onEscape, - this.searchIconData, - this.appBarHeight = kToolbarHeight, - this.searchHint, - this.textStyle, - this.automaticallyImplyLeading = false, - this.clearSearchIconData, - }); - - /// An optional [TextEditingController]. - final TextEditingController? searchController; - - /// The callback that gets invoked when the value changes in the text field. - final Function(String value) onChanged; - - /// The callback that gets invoked when `escape` key is pressed. - final Function() onEscape; - - /// Search icon for search bar. - final IconData? searchIconData; - - /// The height of the [SearchAppBar], needed if it is put into - /// a container without height. - /// It defaults to [kToolbarHeight]. - /// - /// Recommended height is ```AppBarTheme.of(context).toolbarHeight``` - final double appBarHeight; - - /// Specifies the search hint. - final String? searchHint; - - /// Specifies the [TextStyle] - final TextStyle? textStyle; - - /// If false, hides the back icon in the [AppBar] - final bool automaticallyImplyLeading; - - final IconData? clearSearchIconData; - - @override - Widget build(BuildContext context) { - final theme = Theme.of(context); - final textColor = theme.appBarTheme.foregroundColor; - return RawKeyboardListener( - onKey: (event) { - if (event.logicalKey == LogicalKeyboardKey.escape) { - onEscape(); - return; - } - }, - focusNode: FocusNode(), - child: TextField( - maxLines: null, - minLines: null, - cursorColor: textColor, - textAlignVertical: TextAlignVertical.center, - decoration: InputDecoration( - filled: true, - focusColor: Colors.transparent, - fillColor: Colors.transparent, - contentPadding: const EdgeInsets.only(top: 4), - prefixIcon: Icon( - searchIconData ?? Icons.search, - color: textColor, - size: 20, - ), - prefixIconConstraints: - BoxConstraints.expand(width: 40, height: appBarHeight), - suffixIcon: Padding( - padding: const EdgeInsets.only(right: 8.0), - child: YaruIconButton( - onPressed: onEscape, - icon: Icon( - clearSearchIconData ?? Icons.close, - color: textColor, - ), - ), - ), - hintText: searchHint, - enabledBorder: const UnderlineInputBorder( - borderSide: BorderSide(color: Colors.transparent), - ), - border: const UnderlineInputBorder(), - ), - controller: searchController, - autofocus: false, - onChanged: onChanged, - ), - ); - } -} diff --git a/lib/view/tabbed_page.dart b/lib/view/tabbed_page.dart deleted file mode 100644 index 12234233..00000000 --- a/lib/view/tabbed_page.dart +++ /dev/null @@ -1,98 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:yaru_widgets/yaru_widgets.dart'; - -/// A width responsive widget combining a [TabBar] and a [TabBarView]. -/// -/// [tabIcons], [views] and [tabTitles] must have the same amount of children. The [width] and [height] must be provided. -/// If there is not enough space only the [tabIcons] are shown. -class TabbedPage extends StatefulWidget { - const TabbedPage({ - super.key, - required this.tabIcons, - required this.tabTitles, - required this.views, - this.width, - this.padding = const EdgeInsets.only( - top: kYaruPagePadding, - right: kYaruPagePadding, - left: kYaruPagePadding, - ), - this.initialIndex = 0, - this.onTap, - }); - - /// A list of [Widget]s used inside the tabs - must have the same length as [tabTitles] and [views]. - final List tabIcons; - - /// The list of titles as [String]s - must have the same length as [tabIcons] and [views]. - final List tabTitles; - - /// The list of [Widget]-views - must have the same length as [tabTitles] and [tabIcons]. - final List views; - - /// The width used for the [TabBarView] - final double? width; - - /// The padding [EdgeInsets] which defaults to [kDefaultPadding] at top, right and left. - final EdgeInsetsGeometry padding; - - /// The initialIndex of the [TabController] - final int initialIndex; - - /// The [Function] used when one of the [Tab] is tapped. - final Function(int index)? onTap; - - @override - State createState() => _TabbedPageState(); -} - -class _TabbedPageState extends State with TickerProviderStateMixin { - late TabController tabController; - - @override - void initState() { - tabController = TabController( - initialIndex: widget.initialIndex, - length: widget.views.length, - vsync: this, - ); - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Column( - children: [ - Padding( - padding: widget.padding, - child: Container( - width: widget.width, - height: 60, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(kYaruContainerRadius), - ), - child: TabBar( - dividerColor: Colors.transparent, - controller: tabController, - splashBorderRadius: BorderRadius.circular(kYaruContainerRadius), - onTap: widget.onTap, - tabs: [ - for (var i = 0; i < widget.views.length; i++) - Tab( - text: widget.tabTitles[i], - icon: widget.tabIcons[i], - ) - ], - ), - ), - ), - Expanded( - child: TabBarView( - controller: tabController, - children: widget.views, - ), - ), - ], - ); - } -}