Skip to content

Commit

Permalink
dart fix
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-ding committed Jul 17, 2024
1 parent 3ace109 commit bae9c3a
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 51 deletions.
2 changes: 1 addition & 1 deletion ui/lib/activity.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@ class ActivityPage extends ConsumerWidget {
);
},
error: (err, trace) => Text("$err"),
loading: () => MyProgressIndicator());
loading: () => const MyProgressIndicator());
}
}
1 change: 1 addition & 0 deletions ui/lib/login_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class LoginScreen extends ConsumerWidget {
title: 'Polaris',
onLogin: (data) {
ref.read(authSettingProvider.notifier).login(data.name, data.password);
return null;
},
onSubmitAnimationCompleted: () {
context.go(WelcomePage.routeTv);
Expand Down
8 changes: 4 additions & 4 deletions ui/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
// GoRouter configuration
final _shellRoute = ShellRoute(
final shellRoute = ShellRoute(
builder: (BuildContext context, GoRouterState state, Widget child) {
return SelectionArea(
child: Scaffold(
Expand Down Expand Up @@ -139,10 +139,10 @@ class MyApp extends StatelessWidget {
],
);

final _router = GoRouter(
final router = GoRouter(
navigatorKey: APIs.navigatorKey,
routes: [
_shellRoute,
shellRoute,
GoRoute(
path: LoginScreen.route,
builder: (context, state) => const LoginScreen(),
Expand Down Expand Up @@ -172,7 +172,7 @@ class MyApp extends StatelessWidget {
seedColor: Colors.blue, brightness: Brightness.dark),
useMaterial3: true,
),
routerConfig: _router,
routerConfig: router,
),
);
}
Expand Down
2 changes: 1 addition & 1 deletion ui/lib/movie_watchlist.dart
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class _MovieDetailsPageState extends ConsumerState<MovieDetailsPage> {
icon: const Icon(Icons.download),
onPressed: () async {
await ref
.read(movieTorrentsDataProvider(this.id)
.read(movieTorrentsDataProvider(id)
.notifier)
.download(torrent.link!);
},
Expand Down
32 changes: 16 additions & 16 deletions ui/lib/providers/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ import 'package:ui/providers/APIs.dart';
import 'package:ui/providers/server_response.dart';

var settingProvider =
AsyncNotifierProvider.family<EditSettingData, String, String>(
AsyncNotifierProvider.autoDispose.family<EditSettingData, String, String>(
EditSettingData.new);

var indexersProvider =
AsyncNotifierProvider<IndexerSetting, List<Indexer>>(IndexerSetting.new);
AsyncNotifierProvider.autoDispose<IndexerSetting, List<Indexer>>(IndexerSetting.new);

var dwonloadClientsProvider =
AsyncNotifierProvider<DownloadClientSetting, List<DownloadClient>>(
AsyncNotifierProvider.autoDispose<DownloadClientSetting, List<DownloadClient>>(
DownloadClientSetting.new);

var storageSettingProvider =
AsyncNotifierProvider<StorageSettingData, List<Storage>>(
AsyncNotifierProvider.autoDispose<StorageSettingData, List<Storage>>(
StorageSettingData.new);

class EditSettingData extends FamilyAsyncNotifier<String, String> {
Expand Down Expand Up @@ -113,10 +113,10 @@ class Indexer {
id = json["id"];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['name'] = this.name;
data['url'] = this.url;
data['api_key'] = this.apiKey;
final Map<String, dynamic> data = <String, dynamic>{};
data['name'] = name;
data['url'] = url;
data['api_key'] = apiKey;
return data;
}
}
Expand Down Expand Up @@ -196,14 +196,14 @@ class DownloadClient {
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['enable'] = this.enable;
data['name'] = this.name;
data['implementation'] = this.implementation;
data['url'] = this.url;
data['remove_completed_downloads'] = this.removeCompletedDownloads;
data['remove_failed_downloads'] = this.removeFailedDownloads;
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['enable'] = enable;
data['name'] = name;
data['implementation'] = implementation;
data['url'] = url;
data['remove_completed_downloads'] = removeCompletedDownloads;
data['remove_failed_downloads'] = removeFailedDownloads;
return data;
}
}
Expand Down
22 changes: 11 additions & 11 deletions ui/lib/search.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ class _SearchPageState extends ConsumerState<SearchPage> {
return cards;
},
error: (err, trace) => [Text("$err")],
loading: () => [MyProgressIndicator()]);
loading: () => [const MyProgressIndicator()]);

var f = FutureBuilder(
// We listen to the pending operation, to update the UI accordingly.
future: _pendingFuture,
builder: (context, snapshot) {
if (snapshot.connectionState != ConnectionState.done &&
snapshot.connectionState != ConnectionState.none) {
return MyProgressIndicator();
return const MyProgressIndicator();
}
return ListView(
children: res,
Expand Down Expand Up @@ -126,8 +126,8 @@ class _SearchPageState extends ConsumerState<SearchPage> {
builder: (BuildContext context) {
return Consumer(
builder: (context, ref, _) {
String _resSelected = "1080p";
int _storageSelected = 0;
String resSelected = "1080p";
int storageSelected = 0;
var storage = ref.watch(storageSettingProvider);

return AlertDialog(
Expand All @@ -137,30 +137,30 @@ class _SearchPageState extends ConsumerState<SearchPage> {
children: [
DropdownMenu(
label: const Text("清晰度"),
initialSelection: _resSelected,
initialSelection: resSelected,
dropdownMenuEntries: const [
DropdownMenuEntry(value: "720p", label: "720p"),
DropdownMenuEntry(value: "1080p", label: "1080p"),
DropdownMenuEntry(value: "4k", label: "4k"),
],
onSelected: (value) {
setState(() {
_resSelected = value!;
resSelected = value!;
});
},
),
storage.when(
data: (v) {
return DropdownMenu(
label: const Text("存储位置"),
initialSelection: _storageSelected,
initialSelection: storageSelected,
dropdownMenuEntries: v
.map((s) => DropdownMenuEntry(
label: s.name!, value: s.id))
.toList(),
onSelected: (value) {
setState(() {
_storageSelected = value!;
storageSelected = value!;
});
},
);
Expand All @@ -185,11 +185,11 @@ class _SearchPageState extends ConsumerState<SearchPage> {
),
child: const Text('确定'),
onPressed: () {
print(_storageSelected);
print(storageSelected);
ref
.read(searchPageDataProvider.notifier)
.submit2Watchlist(item.id!, _storageSelected,
_resSelected, item.mediaType!);
.submit2Watchlist(item.id!, storageSelected,
resSelected, item.mediaType!);
Navigator.of(context).pop();
},
),
Expand Down
34 changes: 17 additions & 17 deletions ui/lib/system_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class _SystemSettingsPageState extends ConsumerState<SystemSettingsPage> {
);
},
error: (err, trace) => Text("$err"),
loading: () => MyProgressIndicator()),
loading: () => const MyProgressIndicator()),
dirKey.when(
data: (data) {
_downloadDirController.text = data;
Expand All @@ -80,7 +80,7 @@ class _SystemSettingsPageState extends ConsumerState<SystemSettingsPage> {
);
},
error: (err, trace) => Text("$err"),
loading: () => MyProgressIndicator()),
loading: () => const MyProgressIndicator()),
Center(
child: Padding(
padding: const EdgeInsets.only(top: 28.0),
Expand Down Expand Up @@ -154,7 +154,7 @@ class _SystemSettingsPageState extends ConsumerState<SystemSettingsPage> {
)));
}),
error: (err, trace) => Text("$err"),
loading: () => MyProgressIndicator());
loading: () => const MyProgressIndicator());
});

var downloadClients = ref.watch(dwonloadClientsProvider);
Expand Down Expand Up @@ -197,7 +197,7 @@ class _SystemSettingsPageState extends ConsumerState<SystemSettingsPage> {
)));
}),
error: (err, trace) => Text("$err"),
loading: () => MyProgressIndicator());
loading: () => const MyProgressIndicator());
});

var storageSettingData = ref.watch(storageSettingProvider);
Expand Down Expand Up @@ -238,20 +238,20 @@ class _SystemSettingsPageState extends ConsumerState<SystemSettingsPage> {
)));
}),
error: (err, trace) => Text("$err"),
loading: () => MyProgressIndicator());
loading: () => const MyProgressIndicator());
});

var authData = ref.watch(authSettingProvider);
TextEditingController _userController = TextEditingController();
TextEditingController _passController = TextEditingController();
TextEditingController userController = TextEditingController();
TextEditingController passController = TextEditingController();
var authSetting = authData.when(
data: (data) {
if (_enableAuth == null) {
setState(() {
_enableAuth = data.enable;
});
}
_userController.text = data.user;
userController.text = data.user;
return Column(
children: [
SwitchListTile(
Expand All @@ -266,13 +266,13 @@ class _SystemSettingsPageState extends ConsumerState<SystemSettingsPage> {
? Column(
children: [
TextFormField(
controller: _userController,
controller: userController,
decoration: const InputDecoration(
labelText: "用户名",
icon: Icon(Icons.verified_user),
)),
TextFormField(
controller: _passController,
controller: passController,
decoration: const InputDecoration(
labelText: "密码",
icon: Icon(Icons.verified_user),
Expand All @@ -287,13 +287,13 @@ class _SystemSettingsPageState extends ConsumerState<SystemSettingsPage> {
ref
.read(authSettingProvider.notifier)
.updateAuthSetting(_enableAuth!,
_userController.text, _passController.text);
userController.text, passController.text);
}))
],
);
},
error: (err, trace) => Text("$err"),
loading: () => MyProgressIndicator());
loading: () => const MyProgressIndicator());

return ListView(
children: [
Expand Down Expand Up @@ -490,7 +490,7 @@ class _SystemSettingsPageState extends ConsumerState<SystemSettingsPage> {
passController.text = s.settings!["password"] ?? "";
}

String _selectImpl =
String selectImpl =
s.implementation == null ? "local" : s.implementation!;
return StatefulBuilder(builder: (context, setState) {
return AlertDialog(
Expand All @@ -502,10 +502,10 @@ class _SystemSettingsPageState extends ConsumerState<SystemSettingsPage> {
label: const Text("实现"),
onSelected: (value) {
setState(() {
_selectImpl = value!;
selectImpl = value!;
});
},
initialSelection: _selectImpl,
initialSelection: selectImpl,
dropdownMenuEntries: const [
DropdownMenuEntry(value: "local", label: "本地存储"),
DropdownMenuEntry(value: "webdav", label: "webdav")
Expand All @@ -515,7 +515,7 @@ class _SystemSettingsPageState extends ConsumerState<SystemSettingsPage> {
decoration: const InputDecoration(labelText: "名称"),
controller: nameController,
),
_selectImpl != "local"
selectImpl != "local"
?
Column(
children: [
Expand Down Expand Up @@ -573,7 +573,7 @@ class _SystemSettingsPageState extends ConsumerState<SystemSettingsPage> {
.read(storageSettingProvider.notifier)
.addStorage(Storage(
name: nameController.text,
implementation: _selectImpl,
implementation: selectImpl,
settings: {
"tv_path": tvPathController.text,
"movie_path": moviePathController.text,
Expand Down
2 changes: 1 addition & 1 deletion ui/lib/tv_details.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class _TvDetailsPageState extends ConsumerState<TvDetailsPage> {
builder: (context, snapshot) {
return seriesDetails.when(
data: (details) {
Map<int, List<DataRow>> m = Map();
Map<int, List<DataRow>> m = {};
for (final ep in details.episodes!) {
var row = DataRow(cells: [
DataCell(Text("${ep.episodeNumber}")),
Expand Down

0 comments on commit bae9c3a

Please sign in to comment.