-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathconnections_page.dart
112 lines (102 loc) · 3.17 KB
/
connections_page.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
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:watch_it/watch_it.dart';
import 'package:yaru/yaru.dart';
import 'models/wifi_model.dart';
class ConnectionsPage extends StatefulWidget {
const ConnectionsPage({super.key});
static Widget create(BuildContext context) {
return ChangeNotifierProvider<WifiModel>(
create: (_) => WifiModel(di<NetworkManagerClient>()),
child: const ConnectionsPage(),
);
}
static Widget createTitle(BuildContext context) =>
Text(context.l10n.connectionsPageTitle);
static bool searchMatches(String value, BuildContext context) =>
value.isNotEmpty
? context.l10n.connectionsPageTitle
.toLowerCase()
.contains(value.toLowerCase())
: false;
@override
State<ConnectionsPage> createState() => _ConnectionsPageState();
}
class _ConnectionsPageState extends State<ConnectionsPage>
with SingleTickerProviderStateMixin {
late TabController _controller;
@override
void initState() {
super.initState();
_controller = TabController(length: 3, vsync: this);
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final wifiModel = context.watch<WifiModel>();
return Scaffold(
appBar: YaruWindowTitleBar(
titleSpacing: 20,
centerTitle: true,
border: BorderSide.none,
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
title: Text(context.l10n.connectionsPageTitle),
),
body: Column(
children: [
SizedBox(
width: 400,
child: YaruTabBar(
tabController: _controller,
tabs:
// TODO: localize
const [
TitleBarTab(
text: 'Wi-Fi',
iconData: YaruIcons.network_wireless,
),
TitleBarTab(
text: 'Ethernet',
iconData: YaruIcons.network_wired,
),
TitleBarTab(
iconData: YaruIcons.network_cellular,
text: 'Cellular',
),
],
),
),
Expanded(
child: TabBarView(
controller: _controller,
children: [
wifiModel.isWifiDeviceAvailable
? const WifiDevicesContent()
: const WifiAdaptorNotFound(),
const SettingsPage(
children: [
Text('Ethernet - Please implement 🥲️'),
],
),
const SettingsPage(
children: [
Text('Cellular - Please implement 🥲️'),
],
),
],
),
),
],
),
);
}
}