Initial commit
This commit is contained in:
parent
32e425f961
commit
e94d583b8b
67 changed files with 2516 additions and 698 deletions
10
lib/providers/button_layout_provider.dart
Normal file
10
lib/providers/button_layout_provider.dart
Normal file
|
@ -0,0 +1,10 @@
|
|||
import 'package:gsettings/gsettings.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
part 'button_layout_provider.g.dart';
|
||||
|
||||
@riverpod
|
||||
Future<String> buttonLayout(Ref ref) =>
|
||||
GSettings('org.gnome.desktop.wm.preferences')
|
||||
.get("button-layout")
|
||||
.then((dbusValue) => dbusValue.asString());
|
28
lib/providers/decorations_provider.dart
Normal file
28
lib/providers/decorations_provider.dart
Normal file
|
@ -0,0 +1,28 @@
|
|||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import "package:riverpod_annotation/riverpod_annotation.dart";
|
||||
import 'package:canal/models/decorations.dart';
|
||||
import 'package:canal/providers/button_layout_provider.dart';
|
||||
import 'package:yaru/yaru.dart';
|
||||
import "package:collection/collection.dart";
|
||||
part 'decorations_provider.g.dart';
|
||||
|
||||
@riverpod
|
||||
Decorations decorations(Ref ref) {
|
||||
List<YaruWindowControlType> parse(String section) => section
|
||||
.split(",")
|
||||
.map(
|
||||
(button) => YaruWindowControlType.values.firstWhereOrNull(
|
||||
(element) => element.name == button,
|
||||
),
|
||||
)
|
||||
.whereNotNull()
|
||||
.toList();
|
||||
|
||||
final buttons = ref.watch(buttonLayoutProvider).requireValue;
|
||||
|
||||
final [leading, trailing] = buttons.split(":");
|
||||
return Decorations(
|
||||
leading: parse(leading),
|
||||
trailing: parse(trailing),
|
||||
);
|
||||
}
|
13
lib/providers/home_sections_provider.dart
Normal file
13
lib/providers/home_sections_provider.dart
Normal file
|
@ -0,0 +1,13 @@
|
|||
import 'package:canal/providers/ytmusic_provider.dart';
|
||||
import 'package:dart_ytmusic_api/dart_ytmusic_api.dart';
|
||||
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
part "home_sections_provider.g.dart";
|
||||
|
||||
@riverpod
|
||||
Future<IList<HomeSection>> homeSections(Ref ref) async {
|
||||
final yt = await ytmusic(ref);
|
||||
|
||||
return IList(await yt.getHomeSections());
|
||||
}
|
15
lib/providers/warmup_provider.dart
Normal file
15
lib/providers/warmup_provider.dart
Normal file
|
@ -0,0 +1,15 @@
|
|||
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
part "warmup_provider.g.dart";
|
||||
|
||||
@riverpod
|
||||
Future<void> warmup(
|
||||
Ref ref,
|
||||
IList<AutoDisposeFutureProvider> providers,
|
||||
) async =>
|
||||
await Future.wait(
|
||||
providers.map(
|
||||
(provider) => ref.watch(provider.future),
|
||||
),
|
||||
);
|
7
lib/providers/ytmusic_provider.dart
Normal file
7
lib/providers/ytmusic_provider.dart
Normal file
|
@ -0,0 +1,7 @@
|
|||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
import 'package:dart_ytmusic_api/yt_music.dart';
|
||||
part "ytmusic_provider.g.dart";
|
||||
|
||||
@riverpod
|
||||
Future<YTMusic> ytmusic(Ref ref) async => YTMusic().initialize();
|
Reference in a new issue