-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
86 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:get/get.dart'; | ||
import 'package:sydney_webui/controller.dart'; | ||
|
||
class SettingsDialog extends StatelessWidget { | ||
const SettingsDialog({Key? key}) : super(key: key); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final controller = Get.find<Controller>(); | ||
|
||
var apiBaseUrl = controller.sydneyService.baseUrl?.toString() ?? ''; | ||
var apiAccessToken = controller.sydneyService.accessToken; | ||
var apiCookies = controller.sydneyService.cookies; | ||
|
||
return AlertDialog( | ||
title: const Text('Settings'), | ||
content: SingleChildScrollView( | ||
child: ListBody( | ||
children: <Widget>[ | ||
TextFormField( | ||
initialValue: apiBaseUrl, | ||
decoration: const InputDecoration( | ||
labelText: 'API Base URL', | ||
), | ||
onChanged: (value) => apiBaseUrl = value, | ||
), | ||
const SizedBox(height: 8.0), // Adds spacing between fields | ||
TextFormField( | ||
initialValue: apiAccessToken, | ||
decoration: const InputDecoration( | ||
labelText: 'API Access Token', | ||
), | ||
onChanged: (value) => apiAccessToken = value, | ||
), | ||
const SizedBox(height: 8.0), | ||
TextFormField( | ||
initialValue: apiCookies, | ||
decoration: const InputDecoration( | ||
labelText: 'API Cookies', | ||
), | ||
onChanged: (value) => apiCookies = value, | ||
), | ||
], | ||
), | ||
), | ||
actions: <Widget>[ | ||
TextButton( | ||
child: const Text('Cancel'), | ||
onPressed: () { | ||
Get.back(); | ||
}, | ||
), | ||
TextButton( | ||
child: const Text('Save'), | ||
onPressed: () { | ||
controller.sydneyService.baseUrl = Uri.tryParse(apiBaseUrl); | ||
controller.sydneyService.accessToken = apiAccessToken; | ||
controller.sydneyService.cookies = apiCookies; | ||
Get.back(); | ||
}, | ||
), | ||
], | ||
); | ||
} | ||
} |