-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: update flutter, remove custom settings, build snap on github (#14
- Loading branch information
1 parent
8184194
commit 74cce8a
Showing
39 changed files
with
786 additions
and
588 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
name: Create Snap Package | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
workflow_dispatch: | ||
|
||
env: | ||
FLUTTER_VERSION: "3.27.4" | ||
|
||
jobs: | ||
build_and_release_linux_snap_edge_amd64: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 5 | ||
- uses: subosito/flutter-action@v2 | ||
with: | ||
channel: "stable" | ||
flutter-version: ${{env.FLUTTER_VERSION}} | ||
- run: sudo apt update | ||
- run: sudo apt install -y clang cmake curl libgtk-3-dev ninja-build pkg-config unzip libunwind-dev libsecret-1-dev | ||
- run: flutter pub get | ||
- uses: snapcore/action-build@v1 | ||
env: | ||
API_KEY: ${{ secrets.API_KEY }} | ||
id: build | ||
- uses: snapcore/action-publish@v1 | ||
if: steps.build.outcome == 'success' | ||
env: | ||
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }} | ||
with: | ||
snap: ${{ steps.build.outputs.snap }} | ||
release: edge | ||
|
||
build_and_release_linux_snap_edge_arm64: | ||
runs-on: ubuntu-24.04-arm | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 5 | ||
- uses: subosito/flutter-action@v2 | ||
with: | ||
channel: "main" | ||
flutter-version: ${{env.FLUTTER_VERSION}} | ||
- run: sudo apt update | ||
- run: sudo apt install -y clang cmake curl libgtk-3-dev ninja-build pkg-config unzip libunwind-dev libsecret-1-dev | ||
- run: flutter pub get | ||
- uses: snapcore/action-build@v1 | ||
id: build | ||
env: | ||
API_KEY: ${{ secrets.API_KEY }} | ||
- uses: snapcore/action-publish@v1 | ||
if: steps.build.outcome == 'success' | ||
env: | ||
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }} | ||
with: | ||
snap: ${{ steps.build.outputs.snap }} | ||
release: edge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
import 'dart:io'; | ||
import 'dart:ui'; | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_weather_bg_null_safety/bg/weather_bg.dart'; | ||
import 'package:watch_it/watch_it.dart'; | ||
import 'package:yaru/yaru.dart'; | ||
|
||
import '../constants.dart'; | ||
import '../weather.dart'; | ||
import '../extensions/build_context_x.dart'; | ||
import '../l10n/l10n.dart'; | ||
import '../weather/weather_model.dart'; | ||
import 'side_bar.dart'; | ||
|
||
class App extends StatelessWidget { | ||
const App({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) => MaterialApp( | ||
localizationsDelegates: AppLocalizations.localizationsDelegates, | ||
supportedLocales: supportedLocales, | ||
onGenerateTitle: (context) => 'MusicPod', | ||
debugShowCheckedModeBanner: false, | ||
theme: yaruLight, | ||
darkTheme: yaruDark.copyWith( | ||
tabBarTheme: TabBarTheme.of(context).copyWith( | ||
labelColor: Colors.white, | ||
unselectedLabelColor: Colors.white.withValues( | ||
alpha: 0.8, | ||
), | ||
), | ||
), | ||
home: const _StartPage(), | ||
scrollBehavior: const MaterialScrollBehavior().copyWith( | ||
dragDevices: { | ||
PointerDeviceKind.mouse, | ||
PointerDeviceKind.touch, | ||
PointerDeviceKind.stylus, | ||
PointerDeviceKind.unknown, | ||
PointerDeviceKind.trackpad, | ||
}, | ||
), | ||
); | ||
} | ||
|
||
class _StartPage extends StatefulWidget { | ||
const _StartPage(); | ||
|
||
@override | ||
State<_StartPage> createState() => _StartPageState(); | ||
} | ||
|
||
class _StartPageState extends State<_StartPage> { | ||
late final Future<void> _allReady; | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
_allReady = di.allReady(); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) => FutureBuilder( | ||
future: _allReady, | ||
builder: (context, snapshot) => | ||
snapshot.hasData ? const _AppPage() : const _LoadingPage(), | ||
); | ||
} | ||
|
||
class _LoadingPage extends StatelessWidget { | ||
const _LoadingPage(); | ||
|
||
@override | ||
Widget build(BuildContext context) => const Scaffold( | ||
appBar: YaruWindowTitleBar( | ||
border: BorderSide.none, | ||
backgroundColor: Colors.transparent, | ||
), | ||
body: Center( | ||
child: YaruCircularProgressIndicator(), | ||
), | ||
); | ||
} | ||
|
||
class _AppPage extends StatefulWidget with WatchItStatefulWidgetMixin { | ||
const _AppPage(); | ||
|
||
@override | ||
State<_AppPage> createState() => _AppPageState(); | ||
} | ||
|
||
class _AppPageState extends State<_AppPage> { | ||
@override | ||
void initState() { | ||
di<WeatherModel>().loadWeather(); | ||
super.initState(); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final weatherType = watchPropertyValue((WeatherModel m) => m.weatherType); | ||
|
||
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: Platform.isMacOS ? (context.light ? 1 : 0.6) : 0.7, | ||
child: WeatherBg( | ||
weatherType: weatherType, | ||
width: constraints.maxWidth, | ||
height: constraints.maxHeight, | ||
), | ||
), | ||
Row( | ||
children: Platform.isMacOS ? list.reversed.toList() : list, | ||
), | ||
], | ||
); | ||
}, | ||
); | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import 'dart:async'; | ||
|
||
import '../settings/settings_service.dart'; | ||
|
||
class LocationsService { | ||
LocationsService({ | ||
required SettingsService settingsService, | ||
}) : _settingsService = settingsService; | ||
final SettingsService _settingsService; | ||
|
||
String? get lastLocation => | ||
_settingsService.getString(key: SettingKeys.lastLocation); | ||
void setLastLocation(String? value) { | ||
if (value == null) return; | ||
_settingsService.setString(key: SettingKeys.lastLocation, value: value); | ||
} | ||
|
||
Set<String> get favLocations => | ||
_settingsService | ||
.getStrings(key: SettingKeys.favoriteLocations) | ||
?.toSet() ?? | ||
{}; | ||
bool isFavLocation(String value) => favLocations.contains(value); | ||
|
||
void addFavLocation(String name) { | ||
if (favLocations.contains(name)) return; | ||
final favs = Set<String>.from(favLocations); | ||
favs.add(name); | ||
_settingsService.setStrings( | ||
key: SettingKeys.favoriteLocations, | ||
value: favs.toList(), | ||
); | ||
} | ||
|
||
Future<void> removeFavLocation(String name) async { | ||
if (!favLocations.contains(name)) return; | ||
final favs = Set<String>.from(favLocations); | ||
favs.remove(name); | ||
_settingsService.setStrings( | ||
key: SettingKeys.favoriteLocations, | ||
value: favs.toList(), | ||
); | ||
} | ||
|
||
Stream<bool> get propertiesChanged => _settingsService.propertiesChanged; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,13 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:open_weather_client/open_weather.dart'; | ||
import 'package:watch_it/watch_it.dart'; | ||
import 'package:yaru/yaru.dart'; | ||
|
||
import 'src/app/app.dart'; | ||
import 'src/app/app_model.dart'; | ||
import 'src/locations/locations_service.dart'; | ||
import 'src/weather/weather_model.dart'; | ||
import 'app/app.dart'; | ||
import 'register_dependencies.dart'; | ||
|
||
Future<void> main() async { | ||
await YaruWindowTitleBar.ensureInitialized(); | ||
|
||
final locationsService = LocationsService(); | ||
await locationsService.init(); | ||
di.registerSingleton<LocationsService>( | ||
locationsService, | ||
dispose: (s) => s.dispose(), | ||
); | ||
di.registerSingleton(AppModel()); | ||
|
||
di.registerLazySingleton( | ||
() => WeatherModel( | ||
locationsService: locationsService, | ||
openWeather: OpenWeather(apiKey: locationsService.apiKey ?? ''), | ||
), | ||
dispose: (s) => s.dispose(), | ||
); | ||
registerDependencies(); | ||
|
||
runApp(const App()); | ||
} |
Oops, something went wrong.