auth
This commit is contained in:
parent
bb4fab6a11
commit
84cf6a0dda
7 changed files with 226 additions and 5 deletions
|
@ -21,6 +21,9 @@ class _ItemViewState extends State<ItemView> {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(widget.item.name),
|
||||
),
|
||||
body: Column(children: [
|
||||
Row(
|
||||
children: [
|
||||
|
|
72
lib/pages/setup.dart
Normal file
72
lib/pages/setup.dart
Normal file
|
@ -0,0 +1,72 @@
|
|||
import 'package:cdb_ui/api.dart';
|
||||
import 'package:cdb_ui/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class SetupPage extends StatefulWidget {
|
||||
@override
|
||||
_SetupPageState createState() => _SetupPageState();
|
||||
}
|
||||
|
||||
class _SetupPageState extends State<SetupPage> {
|
||||
final TextEditingController _urlController = TextEditingController();
|
||||
final TextEditingController _tokenController = TextEditingController();
|
||||
|
||||
Future<void> _saveSettings() async {
|
||||
String instanceUrl = _urlController.text.trim();
|
||||
String token = _tokenController.text.trim();
|
||||
|
||||
if (instanceUrl.isEmpty || token.isEmpty) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Please fill in all fields')),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
API().save(instanceUrl, token);
|
||||
|
||||
// Indicate that the setup is complete
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Setup Complete!')),
|
||||
);
|
||||
|
||||
// Navigate or close the setup screen
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => MyHomePage(),
|
||||
));
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('Setup Page'),
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
children: [
|
||||
TextField(
|
||||
controller: _urlController,
|
||||
decoration: InputDecoration(labelText: 'Instance URL'),
|
||||
keyboardType: TextInputType.url,
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
TextField(
|
||||
controller: _tokenController,
|
||||
decoration: InputDecoration(labelText: 'Token'),
|
||||
obscureText: true,
|
||||
),
|
||||
SizedBox(height: 32.0),
|
||||
ElevatedButton(
|
||||
onPressed: _saveSettings,
|
||||
child: Text('Complete Setup'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue