Skip to content

Commit

Permalink
Refactor (#437)
Browse files Browse the repository at this point in the history
* Refactor

* format
  • Loading branch information
Feichtmeier authored Aug 7, 2023
1 parent 141a98e commit 8987768
Show file tree
Hide file tree
Showing 49 changed files with 236 additions and 362 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
35 changes: 35 additions & 0 deletions lib/view/common/title_bar_tab.dart
Original file line number Diff line number Diff line change
@@ -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,
),
)
],
),
);
}
}
2 changes: 1 addition & 1 deletion lib/view/pages/accessibility/global_section.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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});
Expand Down
2 changes: 1 addition & 1 deletion lib/view/pages/accessibility/hearing_section.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion lib/view/pages/accessibility/seeing_section.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion lib/view/pages/accessibility/typing_section.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
4 changes: 2 additions & 2 deletions lib/view/pages/appearance/dock_section.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion lib/view/pages/appearance/theme_section.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion lib/view/pages/bluetooth/bluetooth_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
68 changes: 22 additions & 46 deletions lib/view/pages/connections/connections_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -33,8 +34,7 @@ class ConnectionsPage extends StatefulWidget {
State<ConnectionsPage> createState() => _ConnectionsPageState();
}

class _ConnectionsPageState extends State<ConnectionsPage>
with SingleTickerProviderStateMixin {
class _ConnectionsPageState extends State<ConnectionsPage> {
@override
Widget build(BuildContext context) {
final wifiModel = context.watch<WifiModel>();
Expand All @@ -43,21 +43,30 @@ class _ConnectionsPageState extends State<ConnectionsPage>
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',
)
],
),
),
),
),
Expand All @@ -82,36 +91,3 @@ class _ConnectionsPageState extends State<ConnectionsPage>
);
}
}

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,
),
)
],
),
);
}
}
2 changes: 1 addition & 1 deletion lib/view/pages/connections/wifi_content.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion lib/view/pages/date_and_time/date_time_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
47 changes: 36 additions & 11 deletions lib/view/pages/displays/displays_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -45,16 +46,40 @@ class _DisplaysPageState extends State<DisplaysPage> {
return ValueListenableBuilder<DisplaysConfiguration?>(
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(),
),
),
);
},
);
Expand Down
4 changes: 3 additions & 1 deletion lib/view/pages/displays/nightlight_page.dart
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -24,6 +25,7 @@ class NightlightPage extends StatelessWidget {
Widget build(BuildContext context) {
final model = context.watch<NightlightModel>();
return SettingsSection(
width: kDefaultWidth,
headline: Text(context.l10n.nightLightPageTitle),
children: [
YaruSwitchRow(
Expand Down
2 changes: 1 addition & 1 deletion lib/view/pages/displays/widgets/monitor_section.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion lib/view/pages/info/info_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion lib/view/pages/keyboard/input_source_section.dart
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
Loading

0 comments on commit 8987768

Please sign in to comment.