Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .metadata
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled.
# This file should be version controlled and should not be manually edited.

version:
revision: 135454af32477f815a7525073027a3ff9eff1bfd
channel: stable
revision: "300451adae589accbece3490f4396f10bdf15e6e"
channel: "stable"

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: 135454af32477f815a7525073027a3ff9eff1bfd
base_revision: 135454af32477f815a7525073027a3ff9eff1bfd
- platform: ios
create_revision: 135454af32477f815a7525073027a3ff9eff1bfd
base_revision: 135454af32477f815a7525073027a3ff9eff1bfd
create_revision: 300451adae589accbece3490f4396f10bdf15e6e
base_revision: 300451adae589accbece3490f4396f10bdf15e6e
- platform: macos
create_revision: 300451adae589accbece3490f4396f10bdf15e6e
base_revision: 300451adae589accbece3490f4396f10bdf15e6e

# User provided section

Expand Down
25 changes: 25 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "pulse",
"request": "launch",
"type": "dart"
},
{
"name": "pulse (profile mode)",
"request": "launch",
"type": "dart",
"flutterMode": "profile"
},
{
"name": "pulse (release mode)",
"request": "launch",
"type": "dart",
"flutterMode": "release"
}
]
}
22 changes: 13 additions & 9 deletions lib/src/app/app.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'dart:io';
import 'dart:ui';

import 'package:flutter/material.dart';
Expand All @@ -7,6 +8,7 @@ import 'package:yaru/yaru.dart';

import '../../constants.dart';
import '../../weather.dart';
import '../build_context_x.dart';
import '../l10n/l10n.dart';
import '../weather/weather_model.dart';
import 'side_bar.dart';
Expand Down Expand Up @@ -70,25 +72,27 @@ class _AppPageState extends State<AppPage> {

return LayoutBuilder(
builder: (context, constraints) {
var list = [
if (constraints.maxWidth > kBreakPoint) const SideBar(),
Expanded(
child: WeatherPage(
showDrawer: constraints.maxWidth < kBreakPoint,
),
),
];
return Stack(
alignment: Alignment.center,
children: [
Opacity(
opacity: 0.7,
opacity: Platform.isMacOS ? (context.light ? 1 : 0.6) : 0.7,
child: WeatherBg(
weatherType: weatherType,
width: constraints.maxWidth,
height: constraints.maxHeight,
),
),
Row(
children: [
if (constraints.maxWidth > kBreakPoint) const SideBar(),
Expanded(
child: WeatherPage(
showDrawer: constraints.maxWidth < kBreakPoint,
),
),
],
children: Platform.isMacOS ? list.reversed.toList() : list,
),
],
);
Expand Down
35 changes: 21 additions & 14 deletions lib/src/app/side_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,24 @@ class SideBar extends StatelessWidget with WatchItMixin {
itemCount: favLocationsLength,
itemBuilder: (context, index) {
final location = favLocations.elementAt(index);
return YaruMasterTile(
onTap: () {
model.loadWeather(cityName: location);
onSelected?.call();
},
selected: lastLocation == location,
title: Text(
favLocations.elementAt(index),
),
trailing: favLocationsLength > 1
? Center(
widthFactor: 0.1,
return Stack(
alignment: Alignment.centerRight,
children: [
YaruMasterTile(
onTap: () {
model.loadWeather(cityName: location);
onSelected?.call();
},
selected: lastLocation == location,
title: Text(
favLocations.elementAt(index),
),
),
if (favLocationsLength > 1 && lastLocation == location)
Positioned(
right: 20,
child: SizedBox.square(
dimension: 30,
child: IconButton(
padding: EdgeInsets.zero,
onPressed: () {
Expand All @@ -52,8 +58,9 @@ class SideBar extends StatelessWidget with WatchItMixin {
YaruIcons.window_close,
),
),
)
: null,
),
),
],
);
},
);
Expand Down
37 changes: 18 additions & 19 deletions lib/src/weather/view/city_search_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class _CitySearchFieldState extends State<CitySearchField> {
Widget build(BuildContext context) {
final model = di<WeatherModel>();
final error = watchPropertyValue((WeatherModel m) => m.error);
final loading = watchPropertyValue((WeatherModel m) => m.loading);

final theme = context.theme;
var textField = TextField(
autofocus: true,
Expand Down Expand Up @@ -76,26 +78,23 @@ class _CitySearchFieldState extends State<CitySearchField> {
: null,
errorMaxLines: 10,
suffixIconConstraints: const BoxConstraints(
maxHeight: kYaruTitleBarItemHeight,
minHeight: kYaruTitleBarItemHeight,
minWidth: kYaruTitleBarItemHeight,
maxWidth: kYaruTitleBarItemHeight,
maxHeight: 20,
minHeight: 20,
minWidth: 20,
maxWidth: 20,
),
// suffixIcon: ClipRRect(
// borderRadius: const BorderRadius.only(
// topRight: Radius.circular(kYaruButtonRadius),
// bottomRight: Radius.circular(kYaruButtonRadius),
// ),
// child: Material(
// color: Colors.transparent,
// child: InkWell(
// child: const Icon(
// YaruIcons.location,
// ),
// onTap: () => model.init(cityName: null),
// ),
// ),
// ),
suffixIcon: (loading)
? Padding(
padding: const EdgeInsets.only(right: 8),
child: SizedBox.square(
dimension: 20,
child: YaruCircularProgressIndicator(
color: context.theme.colorScheme.onSurface,
strokeWidth: 1,
),
),
)
: null,
),
);
return textField;
Expand Down
8 changes: 6 additions & 2 deletions lib/src/weather/view/hourly_line_chart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,12 @@ class _HourlyLineChartState extends State<HourlyLineChart> {
),
minX: 0,
maxX: (forecast.length - 1).toDouble(),
minY: forecast.map((e) => e.temperature.currentTemperature).min,
maxY: forecast.map((e) => e.temperature.currentTemperature).max,
minY: forecast.isEmpty
? 10
: forecast.map((e) => e.temperature.currentTemperature).min,
maxY: forecast.isEmpty
? 100
: forecast.map((e) => e.temperature.currentTemperature).max,
lineBarsData: [
LineChartBarData(
spots: forecast
Expand Down
84 changes: 63 additions & 21 deletions lib/src/weather/view/weather_page.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:watch_it/watch_it.dart';
import 'package:yaru/yaru.dart';
Expand All @@ -23,29 +25,22 @@ class WeatherPage extends StatelessWidget with WatchItMixin {
initialIndex: appModel.tabIndex,
length: 2,
child: Scaffold(
drawer: Drawer(
child: Builder(
builder: (context) {
return SideBar(
onSelected: () => Scaffold.of(context).closeDrawer(),
);
},
),
),
drawer: Platform.isMacOS ? null : const _Drawer(),
endDrawer: Platform.isMacOS ? const _Drawer() : null,
backgroundColor: Colors.transparent,
appBar: YaruWindowTitleBar(
leading: showDrawer
? Builder(
builder: (context) {
return Center(
child: IconButton(
onPressed: () => Scaffold.of(context).openDrawer(),
icon: const Icon(YaruIcons.menu),
),
);
},
)
: null,
leading: Platform.isMacOS
? null
: showDrawer
? const _DrawerButton()
: null,
actions: [
if (Platform.isMacOS && showDrawer)
const Padding(
padding: EdgeInsets.only(right: 8),
child: _DrawerButton(),
),
],
backgroundColor: Colors.transparent,
border: BorderSide.none,
title: SizedBox(
Expand All @@ -64,3 +59,50 @@ class WeatherPage extends StatelessWidget with WatchItMixin {
);
}
}

class _DrawerButton extends StatelessWidget {
const _DrawerButton();

@override
Widget build(BuildContext context) {
return Builder(
builder: (context) {
return Center(
child: IconButton(
onPressed: () {
if (Platform.isMacOS) {
Scaffold.of(context).openEndDrawer();
} else {
Scaffold.of(context).openDrawer();
}
},
icon: const Icon(YaruIcons.menu),
),
);
},
);
}
}

class _Drawer extends StatelessWidget {
const _Drawer();

@override
Widget build(BuildContext context) {
return Drawer(
child: Builder(
builder: (context) {
return SideBar(
onSelected: () {
if (Platform.isMacOS) {
Scaffold.of(context).closeEndDrawer();
} else {
Scaffold.of(context).closeDrawer();
}
},
);
},
),
);
}
}
13 changes: 10 additions & 3 deletions lib/src/weather/weather_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,17 @@ class WeatherModel extends SafeChangeNotifier {
notifyListeners();
}

bool _loading = false;
bool get loading => _loading;
set loading(bool value) {
if (value == _loading) return;
_loading = value;
notifyListeners();
}

Future<void> loadWeather({String? cityName}) async {
_weatherData = null;
_error = null;
notifyListeners();
loading = true;

cityName ??= lastLocation ?? '';

Expand All @@ -77,7 +84,7 @@ class WeatherModel extends SafeChangeNotifier {
_weatherType = _weatherData!.weatherType;
}

notifyListeners();
loading = false;
}

@override
Expand Down
7 changes: 7 additions & 0 deletions macos/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Flutter-related
**/Flutter/ephemeral/
**/Pods/

# Xcode-related
**/dgph
**/xcuserdata/
2 changes: 2 additions & 0 deletions macos/Flutter/Flutter-Debug.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "ephemeral/Flutter-Generated.xcconfig"
2 changes: 2 additions & 0 deletions macos/Flutter/Flutter-Release.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "ephemeral/Flutter-Generated.xcconfig"
16 changes: 16 additions & 0 deletions macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// Generated file. Do not edit.
//

import FlutterMacOS
import Foundation

import path_provider_foundation
import screen_retriever
import window_manager

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
ScreenRetrieverPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverPlugin"))
WindowManagerPlugin.register(with: registry.registrar(forPlugin: "WindowManagerPlugin"))
}
Loading