@@ -5,22 +5,20 @@ import 'package:flutter_weather_bg_null_safety/bg/weather_bg.dart';
55import 'package:watch_it/watch_it.dart' ;
66import 'package:yaru/yaru.dart' ;
77
8- import '../build_context_x.dart' ;
98import '../../constants.dart' ;
109import '../../weather.dart' ;
11- import '../weather/view/city_search_field.dart' ;
12- import '../weather/weather_data_x.dart' ;
1310import '../weather/weather_model.dart' ;
1411import 'app_model.dart' ;
1512import 'offline_page.dart' ;
13+ import 'side_bar.dart' ;
1614
1715class App extends StatelessWidget {
1816 const App ({super .key});
1917
2018 @override
2119 Widget build (BuildContext context) {
2220 return MaterialApp (
23- title: 'Weather' ,
21+ title: kAppTitle ,
2422 debugShowCheckedModeBanner: false ,
2523 theme: yaruLight,
2624 darkTheme: yaruDark.copyWith (
@@ -63,88 +61,35 @@ class _AppPageState extends State<AppPage> {
6361 Widget build (BuildContext context) {
6462 final isOnline = watchPropertyValue ((AppModel m) => m.isOnline);
6563
66- final model = di <WeatherModel >();
67- final mq = context.mq;
68- final theme = context.theme;
69- final data = watchPropertyValue ((WeatherModel m) => m.data);
70- final favLocationsLength =
71- watchPropertyValue ((WeatherModel m) => m.favLocations.length);
72- final favLocations = watchPropertyValue ((WeatherModel m) => m.favLocations);
73- final lastLocation = watchPropertyValue ((WeatherModel m) => m.lastLocation);
64+ final weatherType = watchPropertyValue ((WeatherModel m) => m.weatherType);
7465
75- final listView = ListView .builder (
76- itemCount: favLocationsLength,
77- itemBuilder: (context, index) {
78- final location = favLocations.elementAt (index);
79- return YaruMasterTile (
80- onTap: () => model.loadWeather (cityName: location),
81- selected: lastLocation == location,
82- title: Text (
83- favLocations.elementAt (index),
84- ),
85- trailing: favLocationsLength > 1
86- ? Center (
87- widthFactor: 0.1 ,
88- child: IconButton (
89- padding: EdgeInsets .zero,
90- onPressed: () {
91- model.removeFavLocation (location).then (
92- (value) => model.loadWeather (
93- cityName: favLocations.lastOrNull,
94- ),
95- );
96- },
97- icon: const Icon (
98- YaruIcons .window_close,
99- ),
100- ),
101- )
102- : null ,
103- );
104- },
105- );
106-
107- return Stack (
108- children: [
109- if (data != null )
110- Opacity (
111- opacity: 0.6 ,
112- child: WeatherBg (
113- weatherType: data.weatherType,
114- width: mq.size.width,
115- height: mq.size.height,
116- ),
117- ),
118- Row (
66+ return LayoutBuilder (
67+ builder: (context, constraints) {
68+ return Stack (
11969 children: [
120- Material (
121- color: theme.colorScheme.surface.withOpacity (0.4 ),
122- child: SizedBox (
123- width: kPaneWidth,
124- child: Column (
125- children: [
126- const YaruDialogTitleBar (
127- shape: RoundedRectangleBorder (
128- borderRadius: BorderRadius .only (
129- topLeft: Radius .circular (kYaruContainerRadius),
130- ),
131- ),
132- backgroundColor: Colors .transparent,
133- border: BorderSide .none,
134- style: YaruTitleBarStyle .undecorated,
135- title: CitySearchField (),
136- ),
137- Expanded (child: listView),
138- ],
139- ),
70+ Opacity (
71+ opacity: 0.7 ,
72+ child: WeatherBg (
73+ weatherType: weatherType,
74+ width: constraints.maxWidth,
75+ height: constraints.maxHeight,
14076 ),
14177 ),
142- Expanded (
143- child: ! isOnline ? const OfflinePage () : const WeatherPage (),
78+ Row (
79+ children: [
80+ if (constraints.maxWidth > kBreakPoint) const SideBar (),
81+ Expanded (
82+ child: ! isOnline
83+ ? const OfflinePage ()
84+ : WeatherPage (
85+ showDrawer: constraints.maxWidth < kBreakPoint,
86+ ),
87+ ),
88+ ],
14489 ),
14590 ],
146- ),
147- ] ,
91+ );
92+ } ,
14893 );
14994 }
15095}
0 commit comments