|
1 | 1 | import 'package:flutter/material.dart'; |
2 | 2 | import 'package:font_awesome_flutter/font_awesome_flutter.dart'; |
3 | 3 | import 'package:package_info_plus/package_info_plus.dart'; |
| 4 | +import 'package:piwigo_ng/api/ImageAPI.dart'; |
4 | 5 | import 'package:piwigo_ng/constants/SettingsConstants.dart'; |
5 | 6 | import 'package:piwigo_ng/views/LoginViewPage.dart'; |
6 | 7 | import 'package:piwigo_ng/api/API.dart'; |
@@ -32,6 +33,10 @@ class _SettingsPageState extends State<SettingsPage> { |
32 | 33 | _thumbnailDerivative = API.prefs.getString('thumbnail_size'); |
33 | 34 | } |
34 | 35 |
|
| 36 | + String _parseFilePath(String path) { |
| 37 | + return path.replaceFirst(RegExp(r'/storage/emulated/0'), ''); |
| 38 | + } |
| 39 | + |
35 | 40 | @override |
36 | 41 | Widget build(BuildContext context) { |
37 | 42 | ThemeData _theme = Theme.of(context); |
@@ -195,32 +200,74 @@ class _SettingsPageState extends State<SettingsPage> { |
195 | 200 | ), |
196 | 201 | ), |
197 | 202 | SectionItem( |
198 | | - Text(appStrings(context).defaultImageSize320px, style: TextStyle(color: Colors.black, fontSize: 16)), |
199 | | - Row( |
200 | | - mainAxisAlignment: MainAxisAlignment.end, |
201 | | - children: [ |
202 | | - DropdownButton<String>( |
203 | | - value: _fsDerivative == null ? API.prefs.getString('full_screen_image_size') : _fsDerivative, |
204 | | - style: TextStyle(color: Colors.grey.shade600, fontSize: 14), |
205 | | - underline: Container(), |
206 | | - icon: Icon(Icons.chevron_right, color: Colors.grey.shade600, size: 20), |
207 | | - onChanged: (String newValue) { |
| 203 | + Expanded( |
| 204 | + child: Text(appStrings(context).defaultImageSize320px, |
| 205 | + style: TextStyle(color: Colors.black, fontSize: 16), |
| 206 | + ), |
| 207 | + ), |
| 208 | + DropdownButton<String>( |
| 209 | + value: _fsDerivative == null ? API.prefs.getString('full_screen_image_size') : _fsDerivative, |
| 210 | + style: TextStyle(color: Colors.grey.shade600, fontSize: 14), |
| 211 | + underline: const SizedBox(), |
| 212 | + icon: Icon(Icons.chevron_right, color: Colors.grey.shade600, size: 20), |
| 213 | + onChanged: (String newValue) { |
| 214 | + setState(() { |
| 215 | + _fsDerivative = newValue; |
| 216 | + API.prefs.setString('full_screen_image_size', _fsDerivative); |
| 217 | + }); |
| 218 | + }, |
| 219 | + items: API.prefs.getStringList('available_sizes').map<DropdownMenuItem<String>>(( |
| 220 | + String value) { |
| 221 | + return DropdownMenuItem<String>( |
| 222 | + value: value, |
| 223 | + alignment: AlignmentDirectional.centerStart, |
| 224 | + child: Text(photoSize(context, value)), |
| 225 | + ); |
| 226 | + }).toList(), |
| 227 | + ), |
| 228 | + ), |
| 229 | + SectionItem( |
| 230 | + Text(appStrings(context).settings_downloadDestination, style: TextStyle(color: Colors.black, fontSize: 16)), |
| 231 | + Expanded( |
| 232 | + child: GestureDetector( |
| 233 | + behavior: HitTestBehavior.opaque, |
| 234 | + onTap: () async { |
| 235 | + String path = await pickDirectoryPath(); |
| 236 | + if(path != null) { |
208 | 237 | setState(() { |
209 | | - _fsDerivative = newValue; |
210 | | - API.prefs.setString('full_screen_image_size', _fsDerivative); |
| 238 | + API.prefs.setString('download_destination', path); |
211 | 239 | }); |
212 | | - }, |
213 | | - items: API.prefs.getStringList('available_sizes').map<DropdownMenuItem<String>>(( |
214 | | - String value) { |
215 | | - return DropdownMenuItem<String>( |
216 | | - value: value, |
217 | | - child: Text(photoSize(context, value)), |
218 | | - ); |
219 | | - }).toList(), |
| 240 | + } |
| 241 | + }, |
| 242 | + child: Row( |
| 243 | + children: [ |
| 244 | + Expanded( |
| 245 | + child: Text( |
| 246 | + _parseFilePath(API.prefs.getString('download_destination') ?? appStrings(context).none), |
| 247 | + textAlign: TextAlign.end, |
| 248 | + style: TextStyle(color: Colors.grey.shade600, fontSize: 14), |
| 249 | + ), |
| 250 | + ), |
| 251 | + Padding( |
| 252 | + padding: const EdgeInsets.only(left: 8), |
| 253 | + child: Icon(Icons.chevron_right, color: Colors.grey.shade600, size: 20), |
| 254 | + ), |
| 255 | + ], |
220 | 256 | ), |
221 | | - ], |
| 257 | + ), |
| 258 | + ), |
| 259 | + ), |
| 260 | + SectionItem( |
| 261 | + Text(appStrings(context).settings_downloadNotification, style: TextStyle(color: Colors.black, fontSize: 16)), |
| 262 | + Switch( |
| 263 | + value: API.prefs.getBool('download_notification') ?? true, |
| 264 | + activeColor: Theme.of(context).colorScheme.primary, |
| 265 | + onChanged: (bool) { |
| 266 | + setState(() { |
| 267 | + API.prefs.setBool('download_notification', bool); |
| 268 | + }); |
| 269 | + }, |
222 | 270 | ), |
223 | | - isEnd: true, |
224 | 271 | ), |
225 | 272 | ], |
226 | 273 | ), |
@@ -259,7 +306,7 @@ class _SettingsPageState extends State<SettingsPage> { |
259 | 306 | SectionItem( |
260 | 307 | Text(appStrings(context).settings_uploadNotification, style: TextStyle(color: Colors.black, fontSize: 16)), |
261 | 308 | Switch( |
262 | | - value: API.prefs.getBool('upload_notification') ?? false, |
| 309 | + value: API.prefs.getBool('upload_notification') ?? true, |
263 | 310 | activeColor: Theme.of(context).colorScheme.primary, |
264 | 311 | onChanged: (bool) { |
265 | 312 | setState(() { |
|
0 commit comments