Skip to content

Commit

Permalink
Re-animate this project (#424)
Browse files Browse the repository at this point in the history
  • Loading branch information
Feichtmeier authored Aug 5, 2023
1 parent ad9127b commit 4d2a3cd
Show file tree
Hide file tree
Showing 133 changed files with 1,035 additions and 1,515 deletions.
23 changes: 0 additions & 23 deletions .github/workflows/analyze.yml

This file was deleted.

30 changes: 0 additions & 30 deletions .github/workflows/build.yml

This file was deleted.

56 changes: 56 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: CI

on:
push:
branches:
- master
pull_request:
branches:
- master
workflow_dispatch:

env:
FLUTTER_VERSION: 3.10.x

jobs:
analyze:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{env.FLUTTER_VERSION}}
- run: flutter pub get
- run: flutter analyze

format:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{env.FLUTTER_VERSION}}
- run: dart format --set-exit-if-changed .

linux:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
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
env:
DEBIAN_FRONTEND: noninteractive
- run: flutter pub get
- run: flutter build linux -v

test:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{env.FLUTTER_VERSION}}
- run: flutter test
23 changes: 0 additions & 23 deletions .github/workflows/format.yml

This file was deleted.

22 changes: 0 additions & 22 deletions .github/workflows/test.yml

This file was deleted.

27 changes: 23 additions & 4 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,28 @@ analyzer:

linter:
rules:
avoid_print: true
cancel_subscriptions: true
prefer_single_quotes: true
prefer_const_constructors: true
prefer_const_declarations: true
require_trailing_commas: true
always_declare_return_types: true
avoid_catches_without_on_clauses: true
avoid_equals_and_hash_code_on_mutable_classes: true
avoid_types_on_closure_parameters: true
cancel_subscriptions: true
directives_ordering: true
eol_at_end_of_file: true
omit_local_variable_types: true
prefer_asserts_in_initializer_lists: true
prefer_const_constructors: true
prefer_final_in_for_each: true
prefer_final_locals: true
prefer_null_aware_method_calls: true
prefer_null_aware_operators: true
sort_constructors_first: true
sort_unnamed_constructors_first: true
sort_pub_dependencies: true
type_annotate_public_apis: true
unawaited_futures: true
unnecessary_lambdas: true
unnecessary_parenthesis: true
use_named_constants: true
use_super_parameters: true
7 changes: 4 additions & 3 deletions lib/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import 'package:yaru_widgets/yaru_widgets.dart';

class UbuntuSettingsApp extends StatefulWidget {
const UbuntuSettingsApp({
Key? key,
}) : super(key: key);
super.key,
});

@override
State<UbuntuSettingsApp> createState() => _UbuntuSettingsAppState();
Expand Down Expand Up @@ -59,7 +59,8 @@ class _UbuntuSettingsAppState extends State<UbuntuSettingsApp> {
minPageWidth: kYaruMasterDetailBreakpoint / 2,
),
length: pages.length,
tileBuilder: (context, index, selected) => YaruMasterTile(
tileBuilder: (context, index, selected, availableWidth) =>
YaruMasterTile(
title: pages[index].titleBuilder(context),
leading: pages[index].iconBuilder(context, selected),
),
Expand Down
2 changes: 1 addition & 1 deletion lib/l10n/l10n.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

export 'package:flutter_gen/gen_l10n/app_localizations.dart';

Expand Down
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void main() async {
),
Provider<DisplayService>(
create: (_) => DisplayService(),
dispose: (_, DisplayService service) => service.dispose(),
dispose: (_, service) => service.dispose(),
),
],
child: const UbuntuSettingsApp(),
Expand Down
8 changes: 4 additions & 4 deletions lib/services/date_time_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,18 +128,18 @@ extension _DateTimeRemoteObject on DBusRemoteObject {

Future<void> setTimeZone(String timezone) async {
final args = [DBusString(timezone), const DBusBoolean(false)];
callMethod(_kDateTimeInterface, _kSetTimezoneMethodName, args);
await callMethod(_kDateTimeInterface, _kSetTimezoneMethodName, args);
}

Future<void> setTime(int time) async {
bool? ntp = await getNtp();
final ntp = await getNtp();
if (ntp == null || ntp == true) return;
final args = [
DBusInt64(time),
const DBusBoolean(false),
const DBusBoolean(false)
];
callMethod(_kDateTimeInterface, _kSetTimeMethodName, args);
await callMethod(_kDateTimeInterface, _kSetTimeMethodName, args);
}

Future<DateTime?> getDateTime() async {
Expand All @@ -156,7 +156,7 @@ extension _DateTimeRemoteObject on DBusRemoteObject {
Future<void> setNtp(bool? value) async {
if (value == null) return;
final args = [DBusBoolean(value), const DBusBoolean(false)];
callMethod(_kDateTimeInterface, _kSetNtpMethodName, args);
await callMethod(_kDateTimeInterface, _kSetNtpMethodName, args);
}
}

Expand Down
13 changes: 6 additions & 7 deletions lib/services/display/display_dbus_service.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:dbus/dbus.dart';
import 'package:settings/services/display/objects/dbus_displays_config.dart';
import 'package:settings/generated/dbus/display-config-remote-object.dart';
import 'package:settings/services/display/objects/dbus_displays_config.dart';

const _displaysInterface = 'org.gnome.Mutter.DisplayConfig';

Expand All @@ -24,8 +24,7 @@ const _displayPath = '/org/gnome/Mutter/DisplayConfig';
class DisplayDBusService {
DisplayDBusService() : _object = _createObject() {
/// Listen to signal stream, when a change occur, we update our data
_object.monitorsChanged
.listen((OrgGnomeMutterDisplayConfigMonitorsChanged signal) {
_object.monitorsChanged.listen((signal) {
if (signal.name == 'MonitorsChanged') {
getCurrent();
}
Expand All @@ -49,8 +48,8 @@ class DisplayDBusService {
}

Future<DBusDisplaysConfig> getCurrent() async {
List<DBusValue>? state = await _object.callGetCurrentState();
List<dynamic> list = state.map((e) => _toNative(e)).toList();
final state = await _object.callGetCurrentState();
final list = state.map(_toNative).toList();
return DBusDisplaysConfig(list);
}

Expand All @@ -73,9 +72,9 @@ class DisplayDBusService {
output =
value.map((key, value) => MapEntry(_toNative(key), _toNative(value)));
} else if (value is Iterable) {
output = value.map((e) => _toNative(e)).toList();
output = value.map(_toNative).toList();
} else if (value is DBusArray) {
output = value.toNative().map((e) => _toNative(e)).toList();
output = value.toNative().map(_toNative).toList();
} else if (value is DBusValue) {
output = value.toNative();
} else {
Expand Down
20 changes: 9 additions & 11 deletions lib/services/display/display_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class DisplayService {
: _displayDBusService = DisplayDBusService(),
_currentNotifier = ValueNotifier(null),
_initialNotifier = ValueNotifier(null) {
_loadState(notifyStream: true).then((DisplaysConfiguration value) {
_loadState(notifyStream: true).then((value) {
_initialNotifier.value = value;
_currentNotifier.value = value;
});
Expand Down Expand Up @@ -54,14 +54,12 @@ class DisplayService {
/// never pass here)
if (_currentNotifier.value == null) {}

final DBusDisplaysConfig displayConfig =
await _displayDBusService.getCurrent();
final displayConfig = await _displayDBusService.getCurrent();

List<DBusStruct> logicalParameterValues = [];
final logicalParameterValues = <DBusStruct>[];

for (int i = 0; i < displayConfig.monitorsLength; i++) {
final DisplayMonitorConfiguration confMonitor =
_currentNotifier.value!.configurations[i];
for (var i = 0; i < displayConfig.monitorsLength; i++) {
final confMonitor = _currentNotifier.value!.configurations[i];

// x ; y ; scale ; transform(rotation) ; primary ; monitors
logicalParameterValues.add(
Expand Down Expand Up @@ -106,7 +104,7 @@ class DisplayService {
}

Future<DisplaysConfiguration> _loadState({required bool notifyStream}) {
final Future<DisplaysConfiguration> future = _displayDBusService
final future = _displayDBusService
.getCurrent()
.then(_mapToModel)
.then((value) => latest = value);
Expand All @@ -118,10 +116,10 @@ class DisplayService {
}

DisplaysConfiguration _mapToModel(DBusDisplaysConfig dbusConfiguration) {
final int monitorsCount = dbusConfiguration.monitorsLength;
final List<DisplayMonitorConfiguration> confs = [];
final monitorsCount = dbusConfiguration.monitorsLength;
final confs = <DisplayMonitorConfiguration>[];

for (int i = 0; i < monitorsCount; i++) {
for (var i = 0; i < monitorsCount; i++) {
/// map data only if there's a current option
/// if no current option
/// => monitor not used
Expand Down
Loading

0 comments on commit 4d2a3cd

Please sign in to comment.