Skip to content

Commit 7c76c89

Browse files
committed
feat: AppConfigを作成
1 parent 7a27b9c commit 7c76c89

File tree

8 files changed

+300
-157
lines changed

8 files changed

+300
-157
lines changed

ios/Podfile.lock

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
PODS:
2+
- DKImagePickerController/Core (4.3.4):
3+
- DKImagePickerController/ImageDataManager
4+
- DKImagePickerController/Resource
5+
- DKImagePickerController/ImageDataManager (4.3.4)
6+
- DKImagePickerController/PhotoGallery (4.3.4):
7+
- DKImagePickerController/Core
8+
- DKPhotoGallery
9+
- DKImagePickerController/Resource (4.3.4)
10+
- DKPhotoGallery (0.0.17):
11+
- DKPhotoGallery/Core (= 0.0.17)
12+
- DKPhotoGallery/Model (= 0.0.17)
13+
- DKPhotoGallery/Preview (= 0.0.17)
14+
- DKPhotoGallery/Resource (= 0.0.17)
15+
- SDWebImage
16+
- SwiftyGif
17+
- DKPhotoGallery/Core (0.0.17):
18+
- DKPhotoGallery/Model
19+
- DKPhotoGallery/Preview
20+
- SDWebImage
21+
- SwiftyGif
22+
- DKPhotoGallery/Model (0.0.17):
23+
- SDWebImage
24+
- SwiftyGif
25+
- DKPhotoGallery/Preview (0.0.17):
26+
- DKPhotoGallery/Model
27+
- DKPhotoGallery/Resource
28+
- SDWebImage
29+
- SwiftyGif
30+
- DKPhotoGallery/Resource (0.0.17):
31+
- SDWebImage
32+
- SwiftyGif
33+
- file_picker (0.0.1):
34+
- DKImagePickerController/PhotoGallery
35+
- Flutter
36+
- Flutter (1.0.0)
37+
- path_provider_foundation (0.0.1):
38+
- Flutter
39+
- FlutterMacOS
40+
- SDWebImage (5.15.0):
41+
- SDWebImage/Core (= 5.15.0)
42+
- SDWebImage/Core (5.15.0)
43+
- shared_preferences_foundation (0.0.1):
44+
- Flutter
45+
- FlutterMacOS
46+
- SwiftyGif (5.4.4)
47+
48+
DEPENDENCIES:
49+
- file_picker (from `.symlinks/plugins/file_picker/ios`)
50+
- Flutter (from `Flutter`)
51+
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/ios`)
52+
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/ios`)
53+
54+
SPEC REPOS:
55+
trunk:
56+
- DKImagePickerController
57+
- DKPhotoGallery
58+
- SDWebImage
59+
- SwiftyGif
60+
61+
EXTERNAL SOURCES:
62+
file_picker:
63+
:path: ".symlinks/plugins/file_picker/ios"
64+
Flutter:
65+
:path: Flutter
66+
path_provider_foundation:
67+
:path: ".symlinks/plugins/path_provider_foundation/ios"
68+
shared_preferences_foundation:
69+
:path: ".symlinks/plugins/shared_preferences_foundation/ios"
70+
71+
SPEC CHECKSUMS:
72+
DKImagePickerController: b512c28220a2b8ac7419f21c491fc8534b7601ac
73+
DKPhotoGallery: fdfad5125a9fdda9cc57df834d49df790dbb4179
74+
file_picker: ce3938a0df3cc1ef404671531facef740d03f920
75+
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
76+
path_provider_foundation: 37748e03f12783f9de2cb2c4eadfaa25fe6d4852
77+
SDWebImage: 9bec4c5cdd9579e1f57104735ee0c37df274d593
78+
shared_preferences_foundation: 297b3ebca31b34ec92be11acd7fb0ba932c822ca
79+
SwiftyGif: 93a1cc87bf3a51916001cf8f3d63835fb64c819f
80+
81+
PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3
82+
83+
COCOAPODS: 1.11.3

ios/Runner.xcodeproj/project.pbxproj

+68
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
1414
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
1515
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
16+
B1A2679828BC81FE388DC9FC /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 526983073F316EBBB3D3F130 /* Pods_Runner.framework */; };
1617
/* End PBXBuildFile section */
1718

1819
/* Begin PBXCopyFilesBuildPhase section */
@@ -32,6 +33,8 @@
3233
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
3334
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
3435
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
36+
526983073F316EBBB3D3F130 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
37+
5C13FD63EBE311DF7770998F /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
3538
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
3639
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
3740
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
@@ -42,13 +45,16 @@
4245
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
4346
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
4447
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
48+
9DC5DA496093F3ED3817780E /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
49+
C7E468A606CC1A7E5F9A7E55 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
4550
/* End PBXFileReference section */
4651

4752
/* Begin PBXFrameworksBuildPhase section */
4853
97C146EB1CF9000F007C117D /* Frameworks */ = {
4954
isa = PBXFrameworksBuildPhase;
5055
buildActionMask = 2147483647;
5156
files = (
57+
B1A2679828BC81FE388DC9FC /* Pods_Runner.framework in Frameworks */,
5258
);
5359
runOnlyForDeploymentPostprocessing = 0;
5460
};
@@ -72,6 +78,8 @@
7278
9740EEB11CF90186004384FC /* Flutter */,
7379
97C146F01CF9000F007C117D /* Runner */,
7480
97C146EF1CF9000F007C117D /* Products */,
81+
E4D759BFA61E73976375F324 /* Pods */,
82+
E4E31F5F4E395D7F7C4039F0 /* Frameworks */,
7583
);
7684
sourceTree = "<group>";
7785
};
@@ -98,19 +106,40 @@
98106
path = Runner;
99107
sourceTree = "<group>";
100108
};
109+
E4D759BFA61E73976375F324 /* Pods */ = {
110+
isa = PBXGroup;
111+
children = (
112+
9DC5DA496093F3ED3817780E /* Pods-Runner.debug.xcconfig */,
113+
5C13FD63EBE311DF7770998F /* Pods-Runner.release.xcconfig */,
114+
C7E468A606CC1A7E5F9A7E55 /* Pods-Runner.profile.xcconfig */,
115+
);
116+
name = Pods;
117+
path = Pods;
118+
sourceTree = "<group>";
119+
};
120+
E4E31F5F4E395D7F7C4039F0 /* Frameworks */ = {
121+
isa = PBXGroup;
122+
children = (
123+
526983073F316EBBB3D3F130 /* Pods_Runner.framework */,
124+
);
125+
name = Frameworks;
126+
sourceTree = "<group>";
127+
};
101128
/* End PBXGroup section */
102129

103130
/* Begin PBXNativeTarget section */
104131
97C146ED1CF9000F007C117D /* Runner */ = {
105132
isa = PBXNativeTarget;
106133
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
107134
buildPhases = (
135+
B26FA86A1E5CDB147519EF14 /* [CP] Check Pods Manifest.lock */,
108136
9740EEB61CF901F6004384FC /* Run Script */,
109137
97C146EA1CF9000F007C117D /* Sources */,
110138
97C146EB1CF9000F007C117D /* Frameworks */,
111139
97C146EC1CF9000F007C117D /* Resources */,
112140
9705A1C41CF9048500538489 /* Embed Frameworks */,
113141
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
142+
95C9BF384B2A6E6E8A2E8455 /* [CP] Embed Pods Frameworks */,
114143
);
115144
buildRules = (
116145
);
@@ -183,6 +212,23 @@
183212
shellPath = /bin/sh;
184213
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
185214
};
215+
95C9BF384B2A6E6E8A2E8455 /* [CP] Embed Pods Frameworks */ = {
216+
isa = PBXShellScriptBuildPhase;
217+
buildActionMask = 2147483647;
218+
files = (
219+
);
220+
inputFileListPaths = (
221+
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
222+
);
223+
name = "[CP] Embed Pods Frameworks";
224+
outputFileListPaths = (
225+
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
226+
);
227+
runOnlyForDeploymentPostprocessing = 0;
228+
shellPath = /bin/sh;
229+
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
230+
showEnvVarsInLog = 0;
231+
};
186232
9740EEB61CF901F6004384FC /* Run Script */ = {
187233
isa = PBXShellScriptBuildPhase;
188234
buildActionMask = 2147483647;
@@ -197,6 +243,28 @@
197243
shellPath = /bin/sh;
198244
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
199245
};
246+
B26FA86A1E5CDB147519EF14 /* [CP] Check Pods Manifest.lock */ = {
247+
isa = PBXShellScriptBuildPhase;
248+
buildActionMask = 2147483647;
249+
files = (
250+
);
251+
inputFileListPaths = (
252+
);
253+
inputPaths = (
254+
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
255+
"${PODS_ROOT}/Manifest.lock",
256+
);
257+
name = "[CP] Check Pods Manifest.lock";
258+
outputFileListPaths = (
259+
);
260+
outputPaths = (
261+
"$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt",
262+
);
263+
runOnlyForDeploymentPostprocessing = 0;
264+
shellPath = /bin/sh;
265+
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
266+
showEnvVarsInLog = 0;
267+
};
200268
/* End PBXShellScriptBuildPhase section */
201269

202270
/* Begin PBXSourcesBuildPhase section */

ios/Runner.xcworkspace/contents.xcworkspacedata

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/repositories/app_config.dart

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import 'package:flutter/foundation.dart';
2+
import 'package:mail_backup/utils/shared_preferences_util.dart';
3+
import 'package:shared_preferences/shared_preferences.dart';
4+
5+
class AppConfig {
6+
String? host;
7+
int? port;
8+
bool? isSecure;
9+
String? userName;
10+
String? password;
11+
12+
static Future<AppConfig> getInstance() async {
13+
AppConfig appConfig = AppConfig();
14+
SharedPreferences sp = await SharedPreferences.getInstance();
15+
try {
16+
appConfig.host = getStringSafe(sp, 'host');
17+
appConfig.port = getIntSafe(sp, 'port');
18+
appConfig.isSecure = getBoolSafe(sp, 'isSecure');
19+
appConfig.password = getStringSafe(sp, 'password');
20+
appConfig.userName = getStringSafe(sp, 'userName');
21+
} on PreferenceNotFound catch (e) {
22+
if (kDebugMode) {
23+
print(e);
24+
}
25+
}
26+
return appConfig;
27+
}
28+
29+
Future<void> save() async {
30+
SharedPreferences sp = await SharedPreferences.getInstance();
31+
await sp.setString('host', host ?? '');
32+
await sp.setString('userName', userName ?? '');
33+
await sp.setString('password', password ?? '');
34+
await sp.setInt('port', port ?? 993);
35+
await sp.setBool('isSecure', isSecure ?? true);
36+
}
37+
}

lib/screens/settings.dart

+19-13
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter/services.dart';
3+
import 'package:mail_backup/repositories/app_config.dart';
34
import 'package:mail_backup/utils/check_imap_connection.dart';
4-
import 'package:shared_preferences/shared_preferences.dart';
5+
6+
import '../utils/preserve_mails.dart';
57

68
class Settings extends StatelessWidget {
79
const Settings({super.key});
@@ -38,6 +40,7 @@ class MainState extends State<Main> {
3840
return Scaffold(
3941
appBar: _appBar(),
4042
body: _body(),
43+
resizeToAvoidBottomInset: false,
4144
);
4245
}
4346

@@ -223,12 +226,13 @@ class MainState extends State<Main> {
223226

224227
Future<void> _saveSettings() async {
225228
double iconSize = MediaQuery.of(context).size.shortestSide * 0.1;
226-
SharedPreferences sp = await SharedPreferences.getInstance();
227-
await sp.setString('host', _mailServerController.text.trim());
228-
await sp.setString('userName', _userNameController.text.trim());
229-
await sp.setString('password', _passwordController.text.trim());
230-
await sp.setInt('port', int.parse(_portNumberController.text.trim()));
231-
await sp.setBool('isSecure', _isSecure);
229+
AppConfig config = await AppConfig.getInstance();
230+
config.host = _mailServerController.text.trim();
231+
config.port = int.parse(_portNumberController.text.trim());
232+
config.userName = _userNameController.text.trim();
233+
config.password = _passwordController.text.trim();
234+
config.isSecure = _isSecure;
235+
await config.save();
232236

233237
await showDialog(
234238
context: context,
@@ -254,11 +258,13 @@ class MainState extends State<Main> {
254258
}
255259

256260
Future<void> _loadSettings() async {
257-
SharedPreferences sp = await SharedPreferences.getInstance();
258-
_mailServerController.text = sp.getString('host') ?? _mailServerController.text;
259-
_userNameController.text = sp.getString('userName') ?? _userNameController.text;
260-
_passwordController.text = sp.getString('password') ?? _passwordController.text;
261-
_portNumberController.text = sp.getInt('port')?.toString() ?? _portNumberController.text;
262-
_isSecure = sp.getBool('isSecure') ?? _isSecure;
261+
AppConfig config = await AppConfig.getInstance();
262+
_mailServerController.text = config.host ?? _mailServerController.text;
263+
_userNameController.text = config.userName ?? _userNameController.text;
264+
_passwordController.text = config.password ?? _passwordController.text;
265+
_portNumberController.text = config.port != null
266+
? config.port.toString()
267+
: _portNumberController.text;
268+
_isSecure = config.isSecure ?? true;
263269
}
264270
}

macos/Podfile.lock

+7
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,28 @@
11
PODS:
22
- FlutterMacOS (1.0.0)
3+
- path_provider_foundation (0.0.1):
4+
- Flutter
5+
- FlutterMacOS
36
- shared_preferences_foundation (0.0.1):
47
- Flutter
58
- FlutterMacOS
69

710
DEPENDENCIES:
811
- FlutterMacOS (from `Flutter/ephemeral`)
12+
- path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/macos`)
913
- shared_preferences_foundation (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/macos`)
1014

1115
EXTERNAL SOURCES:
1216
FlutterMacOS:
1317
:path: Flutter/ephemeral
18+
path_provider_foundation:
19+
:path: Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/macos
1420
shared_preferences_foundation:
1521
:path: Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/macos
1622

1723
SPEC CHECKSUMS:
1824
FlutterMacOS: ae6af50a8ea7d6103d888583d46bd8328a7e9811
25+
path_provider_foundation: 37748e03f12783f9de2cb2c4eadfaa25fe6d4852
1926
shared_preferences_foundation: 297b3ebca31b34ec92be11acd7fb0ba932c822ca
2027

2128
PODFILE CHECKSUM: 6eac6b3292e5142cfc23bdeb71848a40ec51c14c

0 commit comments

Comments
 (0)