Skip to content

Commit eaad014

Browse files
committed
ref: rename Prefs to stows
Prefs are assigned and initialized on the same line as they're defined. Prefs will soon be replaced with Stows
1 parent 3a838e0 commit eaad014

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+516
-669
lines changed

lib/components/canvas/canvas_gesture_detector.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,17 +148,17 @@ class CanvasGestureDetectorState extends State<CanvasGestureDetector> {
148148

149149
/// If zooming is locked, this is the zoom level.
150150
/// Otherwise, this is null.
151-
late double? zoomLockedValue = Prefs.lastZoomLock.value
151+
late double? zoomLockedValue = stows.lastZoomLock.value
152152
? widget._transformationController.value.approxScale
153153
: null;
154154

155155
/// Whether single-finger panning is locked.
156156
/// Two-finger panning is always enabled.
157-
late bool singleFingerPanLock = Prefs.lastSingleFingerPanLock.value;
157+
late bool singleFingerPanLock = stows.lastSingleFingerPanLock.value;
158158

159159
/// Whether panning is locked to being horizontal or vertical.
160160
/// Otherwise, panning can be done in any (i.e. diagonal) direction.
161-
late bool axisAlignedPanLock = Prefs.lastAxisAlignedPanLock.value;
161+
late bool axisAlignedPanLock = stows.lastAxisAlignedPanLock.value;
162162

163163
void zoomIn() => widget._transformationController.value = setZoom(
164164
scaleDelta: 0.1,
@@ -495,18 +495,18 @@ class CanvasGestureDetectorState extends State<CanvasGestureDetector> {
495495
zoomLockedValue = zoomLock
496496
? widget._transformationController.value.approxScale
497497
: null;
498-
Prefs.lastZoomLock.value = zoomLock;
498+
stows.lastZoomLock.value = zoomLock;
499499
}),
500500
resetZoom: zoomLockedValue != null ? null : resetZoom,
501501
singleFingerPanLock: singleFingerPanLock,
502502
setSingleFingerPanLock: (bool singleFingerPanLock) => setState(() {
503503
this.singleFingerPanLock = singleFingerPanLock;
504-
Prefs.lastSingleFingerPanLock.value = singleFingerPanLock;
504+
stows.lastSingleFingerPanLock.value = singleFingerPanLock;
505505
}),
506506
axisAlignedPanLock: axisAlignedPanLock,
507507
setAxisAlignedPanLock: (bool axisAlignedPanLock) => setState(() {
508508
this.axisAlignedPanLock = axisAlignedPanLock;
509-
Prefs.lastAxisAlignedPanLock.value = axisAlignedPanLock;
509+
stows.lastAxisAlignedPanLock.value = axisAlignedPanLock;
510510
}),
511511
),
512512
),

lib/components/canvas/canvas_image.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class _CanvasImageState extends State<CanvasImage> {
116116
Brightness currentBrightness = Theme.of(context).brightness;
117117
if (!widget.image.invertible) currentBrightness = Brightness.light;
118118

119-
if (Prefs.editorAutoInvert.value && currentBrightness != imageBrightness) {
119+
if (stows.editorAutoInvert.value && currentBrightness != imageBrightness) {
120120
imageBrightness = currentBrightness;
121121
}
122122

lib/components/canvas/canvas_image_dialog.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ class _CanvasImageDialogState extends State<CanvasImageDialog> {
4949
final children = <Widget>[
5050
MergeSemantics(
5151
child: _CanvasImageDialogItem(
52-
onTap: Prefs.editorAutoInvert.value ? setInvertible : null,
52+
onTap: stows.editorAutoInvert.value ? setInvertible : null,
5353
title: t.editor.imageOptions.invertible,
5454
child: Switch.adaptive(
5555
value: widget.image.invertible,
56-
onChanged: Prefs.editorAutoInvert.value ? setInvertible : null,
56+
onChanged: stows.editorAutoInvert.value ? setInvertible : null,
5757
thumbIcon: WidgetStateProperty.all(widget.image.invertible
5858
? const Icon(Icons.invert_colors)
5959
: const Icon(Icons.invert_colors_off)),

lib/components/canvas/canvas_preview.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class CanvasPreview extends StatelessWidget implements PreferredSizeWidget {
8383
currentStroke: null,
8484
currentStrokeDetectedShape: null,
8585
currentSelection: null,
86-
hideBackground: Prefs.hideHomeBackgrounds.value,
86+
hideBackground: stows.hideHomeBackgrounds.value,
8787
currentToolIsSelect: false,
8888
currentScale: double.minPositive,
8989
);

lib/components/canvas/image/png_editor_image.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ class PngEditorImage extends EditorImage {
140140
Size(descriptor.width.toDouble(), descriptor.height.toDouble()));
141141

142142
if (maxSize == null) {
143-
await Prefs.maxImageSize.waitUntilLoaded();
144-
maxSize = Size.square(Prefs.maxImageSize.value);
143+
await stows.maxImageSize.waitUntilLoaded();
144+
maxSize = Size.square(stows.maxImageSize.value);
145145
}
146146
final Size reducedSize = EditorImage.resize(naturalSize, maxSize!);
147147
if (naturalSize.width != reducedSize.width && !isThumbnail) {

lib/components/canvas/inner_canvas.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class _InnerCanvasState extends State<InnerCanvas> {
6767
final colorScheme = Theme.of(context).colorScheme;
6868
final Brightness brightness = Theme.of(context).brightness;
6969
final bool invert =
70-
Prefs.editorAutoInvert.value && brightness == Brightness.dark;
70+
stows.editorAutoInvert.value && brightness == Brightness.dark;
7171
final Color backgroundColor =
7272
widget.coreInfo.backgroundColor ?? InnerCanvas.defaultBackgroundColor;
7373

@@ -142,7 +142,7 @@ class _InnerCanvasState extends State<InnerCanvas> {
142142
primaryColor: colorScheme.primary,
143143
page: page,
144144
showPageIndicator: !widget.isPreview &&
145-
(!widget.isPrint || Prefs.printPageIndicators.value),
145+
(!widget.isPrint || stows.printPageIndicators.value),
146146
pageIndex: widget.pageIndex,
147147
totalPages: widget.coreInfo.pages.length,
148148
currentScale: widget.currentScale,

lib/components/home/masonry_files.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class _MasonryFilesState extends State<MasonryFiles> {
6161

6262
return SliverPadding(
6363
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
64-
sliver: Prefs.simplifiedHomeLayout.value
64+
sliver: stows.simplifiedHomeLayout.value
6565
? SliverGrid.builder(
6666
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
6767
crossAxisCount: widget.crossAxisCount,

lib/components/home/preview_card.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class _PreviewCardState extends State<PreviewCard> {
8484
final transitionDuration =
8585
Duration(milliseconds: disableAnimations ? 0 : 300);
8686
final invert =
87-
theme.brightness == Brightness.dark && Prefs.editorAutoInvert.value;
87+
theme.brightness == Brightness.dark && stows.editorAutoInvert.value;
8888

8989
Widget card = MouseRegion(
9090
cursor: SystemMouseCursors.click,

lib/components/home/sync_indicator.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class _SyncIndicatorState extends State<SyncIndicator> {
2525

2626
@override
2727
void initState() {
28-
Prefs.username.addListener(onFileTransfer);
28+
stows.username.addListener(onFileTransfer);
2929
uploaderListener = syncer.uploader.transferStream.listen(onFileTransfer);
3030
downloaderListener =
3131
syncer.downloader.transferStream.listen(onFileTransfer);
@@ -98,7 +98,7 @@ class _SyncIndicatorState extends State<SyncIndicator> {
9898

9999
@override
100100
void dispose() {
101-
Prefs.username.removeListener(onFileTransfer);
101+
stows.username.removeListener(onFileTransfer);
102102
uploaderListener.cancel();
103103
downloaderListener.cancel();
104104
super.dispose();

lib/components/home/syncing_button.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class _SyncingButtonState extends State<SyncingButton> {
2828
queueListener = syncer.downloader.queueStream.listen(_onQueueChanged);
2929
transferListener =
3030
syncer.downloader.transferStream.listen(_onFileTransferred);
31-
Prefs.username.addListener(_onUsernameChanged);
31+
stows.username.addListener(_onUsernameChanged);
3232

3333
super.initState();
3434
}
@@ -66,7 +66,7 @@ class _SyncingButtonState extends State<SyncingButton> {
6666
}
6767

6868
void onPressed() {
69-
assert(Prefs.loggedIn);
69+
assert(stows.loggedIn);
7070

7171
// Don't refresh if we're already refreshing.
7272
if (syncer.downloader.isRefreshing) return;
@@ -85,7 +85,7 @@ class _SyncingButtonState extends State<SyncingButton> {
8585
double? percentage = getPercentage();
8686

8787
return IconButton(
88-
onPressed: Prefs.loggedIn
88+
onPressed: stows.loggedIn
8989
? onPressed
9090
: SyncingButton.forceButtonActive
9191
? () {}
@@ -94,7 +94,7 @@ class _SyncingButtonState extends State<SyncingButton> {
9494
alignment: Alignment.center,
9595
children: [
9696
AnimatedOpacity(
97-
opacity: (Prefs.loggedIn && (percentage ?? 0) < 1) ? 1 : 0,
97+
opacity: (stows.loggedIn && (percentage ?? 0) < 1) ? 1 : 0,
9898
duration: const Duration(milliseconds: 200),
9999
child: _AnimatedCircularProgressIndicator(
100100
duration: const Duration(milliseconds: 200),
@@ -114,7 +114,7 @@ class _SyncingButtonState extends State<SyncingButton> {
114114
void dispose() {
115115
queueListener.cancel();
116116
transferListener.cancel();
117-
Prefs.username.removeListener(_onUsernameChanged);
117+
stows.username.removeListener(_onUsernameChanged);
118118
super.dispose();
119119
}
120120
}

lib/components/navbar/responsive_navbar.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ class ResponsiveNavbar extends StatefulWidget {
2828
class _ResponsiveNavbarState extends State<ResponsiveNavbar> {
2929
@override
3030
void initState() {
31-
Prefs.locale.addListener(onChange);
32-
Prefs.layoutSize.addListener(onChange);
31+
stows.locale.addListener(onChange);
32+
stows.layoutSize.addListener(onChange);
3333
super.initState();
3434
}
3535

@@ -62,7 +62,7 @@ class _ResponsiveNavbarState extends State<ResponsiveNavbar> {
6262

6363
@override
6464
Widget build(BuildContext context) {
65-
ResponsiveNavbar.isLargeScreen = switch (Prefs.layoutSize.value) {
65+
ResponsiveNavbar.isLargeScreen = switch (stows.layoutSize.value) {
6666
LayoutSize.auto => MediaQuery.sizeOf(context).width >= 600,
6767
LayoutSize.phone => false,
6868
LayoutSize.tablet => true,
@@ -98,8 +98,8 @@ class _ResponsiveNavbarState extends State<ResponsiveNavbar> {
9898

9999
@override
100100
void dispose() {
101-
Prefs.locale.removeListener(onChange);
102-
Prefs.layoutSize.removeListener(onChange);
101+
stows.locale.removeListener(onChange);
102+
stows.layoutSize.removeListener(onChange);
103103
super.dispose();
104104
}
105105
}

lib/components/nextcloud/done_login_step.dart

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ class _DoneLoginStepState extends State<DoneLoginStep> {
2626
late final log = Logger('DoneLoginStep');
2727

2828
void _logout() {
29-
Prefs.url.value = '';
30-
Prefs.username.value = '';
31-
Prefs.ncPassword.value = '';
32-
Prefs.ncPasswordIsAnAppPassword.value = false;
33-
Prefs.encPassword.value = '';
34-
Prefs.pfp.value = null;
35-
Prefs.lastStorageQuota.value = null;
36-
Prefs.key.value = '';
37-
Prefs.iv.value = '';
29+
stows.url.value = '';
30+
stows.username.value = '';
31+
stows.ncPassword.value = '';
32+
stows.ncPasswordIsAnAppPassword.value = false;
33+
stows.encPassword.value = '';
34+
stows.pfp.value = null;
35+
stows.lastStorageQuota.value = null;
36+
stows.key.value = '';
37+
stows.iv.value = '';
3838
widget.recheckCurrentStep();
3939
}
4040

@@ -43,12 +43,12 @@ class _DoneLoginStepState extends State<DoneLoginStep> {
4343
final textTheme = Theme.of(context).textTheme;
4444
final screenWidth = MediaQuery.sizeOf(context).width;
4545
final screenHeight = MediaQuery.sizeOf(context).height;
46-
final quota = Prefs.lastStorageQuota.value;
46+
final quota = stows.lastStorageQuota.value;
4747
final serverName =
48-
Prefs.url.value.ifNotEmpty ?? t.login.ncLoginStep.saberNcServer;
49-
late final serverUri = Prefs.url.value.isEmpty
48+
stows.url.value.ifNotEmpty ?? t.login.ncLoginStep.saberNcServer;
49+
late final serverUri = stows.url.value.isEmpty
5050
? NextcloudClientExtension.defaultNextcloudUri
51-
: Uri.parse(Prefs.url.value);
51+
: Uri.parse(stows.url.value);
5252
return ListView(
5353
padding: EdgeInsets.symmetric(
5454
horizontal: screenWidth > width ? (screenWidth - width) / 2 : 16,
@@ -69,16 +69,16 @@ class _DoneLoginStepState extends State<DoneLoginStep> {
6969
],
7070
Row(
7171
children: [
72-
if (Prefs.pfp.value == null)
73-
if (Prefs.url.value.isEmpty)
72+
if (stows.pfp.value == null)
73+
if (stows.url.value.isEmpty)
7474
SvgPicture.asset('assets/icon/icon.svg', width: 32, height: 32)
7575
else
7676
const Icon(Icons.account_circle, size: 32)
7777
else
78-
Image.memory(Prefs.pfp.value!, width: 32, height: 32),
78+
Image.memory(stows.pfp.value!, width: 32, height: 32),
7979
const SizedBox(width: 16),
8080
Expanded(
81-
child: Text(t.login.status.hi(u: Prefs.username.value),
81+
child: Text(t.login.status.hi(u: stows.username.value),
8282
style: textTheme.headlineSmall),
8383
),
8484
],

lib/components/nextcloud/enc_login_step.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class _EncLoginStepState extends State<EncLoginStep> {
6363
height: min(64, screenHeight * 0.05),
6464
),
6565
],
66-
Text(t.login.status.hi(u: Prefs.username.value),
66+
Text(t.login.status.hi(u: stows.username.value),
6767
style: textTheme.headlineSmall),
6868
Text.rich(
6969
t.login.notYou(
@@ -72,9 +72,9 @@ class _EncLoginStepState extends State<EncLoginStep> {
7272
style: TextStyle(color: colorScheme.link),
7373
recognizer: TapGestureRecognizer()
7474
..onTap = () {
75-
Prefs.url.value = '';
76-
Prefs.username.value = '';
77-
Prefs.ncPassword.value = '';
75+
stows.url.value = '';
76+
stows.username.value = '';
77+
stows.ncPassword.value = '';
7878
widget.recheckCurrentStep();
7979
},
8080
),
@@ -146,17 +146,17 @@ class _EncLoginStepState extends State<EncLoginStep> {
146146
if (encPassword.isEmpty) return;
147147

148148
try {
149-
Prefs.encPassword.value = encPassword;
149+
stows.encPassword.value = encPassword;
150150
final client = NextcloudClientExtension.withSavedDetails()!;
151151
_isChecking.value = true;
152152
await client.loadEncryptionKey();
153153
widget.recheckCurrentStep();
154154
} on EncLoginFailure {
155-
Prefs.encPassword.value = '';
155+
stows.encPassword.value = '';
156156

157157
_errorMessage.value = t.login.encLoginStep.wrongEncPassword;
158158
} catch (e) {
159-
Prefs.encPassword.value = '';
159+
stows.encPassword.value = '';
160160
log.severe('Failed to load encryption key: $e', e);
161161

162162
_errorMessage.value = '${t.login.encLoginStep.connectionFailed}\n\n$e';

lib/components/nextcloud/nc_login_step.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,20 +54,20 @@ class _NcLoginStepState extends State<NcLoginStep> {
5454
);
5555
final username = await client.getUsername();
5656

57-
Prefs.url.value = credentials.server ==
57+
stows.url.value = credentials.server ==
5858
NextcloudClientExtension.defaultNextcloudUri.toString()
5959
? ''
6060
: credentials.server;
61-
Prefs.username.value = username;
62-
Prefs.ncPassword.value = credentials.appPassword;
63-
Prefs.ncPasswordIsAnAppPassword.value = true;
64-
Prefs.encPassword.value = '';
61+
stows.username.value = username;
62+
stows.ncPassword.value = credentials.appPassword;
63+
stows.ncPasswordIsAnAppPassword.value = true;
64+
stows.encPassword.value = '';
6565

66-
Prefs.pfp.value = null;
66+
stows.pfp.value = null;
6767
client.core.avatar
6868
.getAvatar(userId: username, size: AvatarGetAvatarSize.$512)
6969
.then((response) => response.body)
70-
.then((pfp) => Prefs.pfp.value = pfp);
70+
.then((pfp) => stows.pfp.value = pfp);
7171

7272
widget.recheckCurrentStep();
7373
});

lib/components/settings/app_info.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class AppInfo extends StatelessWidget {
3737
return TextButton(
3838
onPressed: () => _showAboutDialog(context),
3939
child: ValueListenableBuilder(
40-
valueListenable: Prefs.locale,
40+
valueListenable: stows.locale,
4141
builder: (context, _, __) => Text(info),
4242
),
4343
);

0 commit comments

Comments
 (0)