test
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:oc_front/main.dart';
|
||||
|
||||
class InfoAlertBannerChild extends StatelessWidget {
|
||||
final String text;
|
||||
@@ -9,7 +10,7 @@ class InfoAlertBannerChild extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
constraints: BoxConstraints(maxWidth: MediaQuery.of(context).size.width * 0.8),
|
||||
constraints: BoxConstraints(maxWidth: getMainWidth(context) * 0.8),
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.greenAccent,
|
||||
borderRadius: BorderRadius.all(Radius.circular(5)),
|
||||
@@ -38,9 +39,9 @@ class AlertAlertBannerChild extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
constraints: BoxConstraints(maxWidth: MediaQuery.of(context).size.width * 0.8),
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.redAccent,
|
||||
constraints: BoxConstraints(maxWidth: getMainWidth(context) * 0.8),
|
||||
decoration: BoxDecoration(
|
||||
color: redColor,
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(5),
|
||||
),
|
||||
|
||||
@@ -1,74 +1,105 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_spinkit/flutter_spinkit.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:oc_front/core/services/auth.service.dart';
|
||||
import 'package:oc_front/main.dart';
|
||||
|
||||
class LoginWidget extends StatefulWidget {
|
||||
LoginWidget ({ Key? key }): super(key: key);
|
||||
@override LoginWidgetState createState() => LoginWidgetState();
|
||||
}
|
||||
class LoginWidgetState extends State<LoginWidget> {
|
||||
TextEditingController usernameCtrl = TextEditingController();
|
||||
TextEditingController passwordCtrl = TextEditingController();
|
||||
|
||||
String? error;
|
||||
bool loading = false;
|
||||
|
||||
@override Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
backgroundColor: Colors.white,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(0))),
|
||||
content: Padding(padding: const EdgeInsets.all(20), child: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
const Center(child: Padding( padding: EdgeInsets.only(bottom: 10),
|
||||
child: Icon(Icons.person_search, size: 80, color: Colors.grey,))),
|
||||
const Center(child: Text("WELCOME ON OPENCLOUD", style: TextStyle(fontSize: 25, fontWeight: FontWeight.w600,
|
||||
color: Color.fromRGBO(38, 166, 154, 1)),)),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 20),
|
||||
decoration: BoxDecoration(border: Border(bottom: BorderSide(color: Colors.black))),
|
||||
),
|
||||
return Padding(padding: const EdgeInsets.all(50), child: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
const Center(child: Icon(Icons.person_search, size: 150, color: Colors.grey,)),
|
||||
Center(child: Padding( padding: const EdgeInsets.only(top: 5, bottom: 20),
|
||||
child: Text("WELCOME ON OPENCLOUD", style: TextStyle(fontSize: 25, fontWeight: FontWeight.w600,
|
||||
color: lightColor ) ))),
|
||||
Container( margin: const EdgeInsets.only(bottom: 10), child: Center(child: Row( mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
width: MediaQuery.of(context).size.width / 3,
|
||||
width: getMainWidth(context) / 3,
|
||||
alignment : Alignment.center,
|
||||
child: TextField(
|
||||
controller: usernameCtrl,
|
||||
onChanged: (v) => setState(() {}),
|
||||
decoration: InputDecoration(
|
||||
enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: Colors.grey.shade300), borderRadius: BorderRadius.zero),
|
||||
border: OutlineInputBorder(borderSide: BorderSide(color: Colors.grey.shade300), borderRadius: BorderRadius.zero),
|
||||
focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: Colors.grey.shade300), borderRadius: BorderRadius.zero),
|
||||
enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: midColor), borderRadius: BorderRadius.zero),
|
||||
border: OutlineInputBorder(borderSide: BorderSide(color: midColor), borderRadius: BorderRadius.zero),
|
||||
focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: midColor), borderRadius: BorderRadius.zero),
|
||||
hintText: "username...",
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 20),
|
||||
fillColor: Colors.grey.shade300,
|
||||
fillColor: midColor,
|
||||
filled: true,
|
||||
hintStyle: const TextStyle(fontSize: 12.5, color: Colors.grey)),
|
||||
style: const TextStyle(fontSize: 12.5, color: Colors.grey)),),
|
||||
style: const TextStyle(fontSize: 12.5, color: Colors.black)),),
|
||||
Container(width: 50, height: 50, color: Colors.black, child: const Icon(Icons.person, color: Colors.white))
|
||||
]))),
|
||||
Container( margin: const EdgeInsets.only(bottom: 20), child: Center(child: Row( mainAxisAlignment: MainAxisAlignment.center,
|
||||
Center(child: Row( mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
width: MediaQuery.of(context).size.width / 3,
|
||||
width: getMainWidth(context) / 3,
|
||||
alignment : Alignment.center,
|
||||
child: TextField(
|
||||
controller: passwordCtrl,
|
||||
obscureText: true,
|
||||
onChanged: (value) {
|
||||
setState(() {});
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: Colors.grey.shade300), borderRadius: BorderRadius.zero),
|
||||
enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: Colors.grey.shade300), borderRadius: BorderRadius.zero),
|
||||
border: OutlineInputBorder(borderSide: BorderSide(color: Colors.grey.shade300), borderRadius: BorderRadius.zero),
|
||||
focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: midColor), borderRadius: BorderRadius.zero),
|
||||
enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: midColor), borderRadius: BorderRadius.zero),
|
||||
border: OutlineInputBorder(borderSide: BorderSide(color: midColor), borderRadius: BorderRadius.zero),
|
||||
hintText: "password...",
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 20),
|
||||
fillColor: Colors.grey.shade300,
|
||||
fillColor: midColor,
|
||||
filled: true,
|
||||
hintStyle: const TextStyle(fontSize: 12.5, color: Colors.grey)),
|
||||
style: const TextStyle(fontSize: 12.5, color: Colors.grey)),),
|
||||
style: const TextStyle(fontSize: 12.5, color: Colors.black)),),
|
||||
Container(width: 50, height: 50, color: Colors.black, child: const Icon(Icons.password, color: Colors.white))
|
||||
]))),
|
||||
Row( mainAxisAlignment: MainAxisAlignment.center, children: [
|
||||
Padding( padding: const EdgeInsets.only(right: 10), child:
|
||||
InkWell(onTap: () { context.pop(); },
|
||||
mouseCursor: SystemMouseCursors.click,
|
||||
child: Container(
|
||||
margin: const EdgeInsets.only(top: 20),
|
||||
width: MediaQuery.of(context).size.width / 3,
|
||||
padding: const EdgeInsets.symmetric(vertical: 20),
|
||||
color: const Color.fromRGBO(38, 166, 154, 1),
|
||||
child: const Center( child: Text("LOGIN", style: TextStyle(color: Colors.white, fontSize: 15),))))),
|
||||
])
|
||||
],)));
|
||||
])),
|
||||
Column( children: [
|
||||
Center( child: Padding( padding: EdgeInsets.only(bottom: 10, top: error == null ? 27 : 10), child:
|
||||
error == null ? Container() : Text(error ?? "", style: TextStyle(color: redColor, fontSize: 12.5)))),
|
||||
Row( mainAxisAlignment: MainAxisAlignment.center, children: [
|
||||
Padding( padding: const EdgeInsets.only(right: 10, bottom: 30), child:
|
||||
InkWell(onTap: () async {
|
||||
if (usernameCtrl.text == "" || passwordCtrl.text == "") { return; }
|
||||
error = null;
|
||||
setState(() {
|
||||
loading = true;
|
||||
});
|
||||
await AuthService.login(usernameCtrl.text, passwordCtrl.text).catchError( (e) {
|
||||
setState(() {
|
||||
loading = false;
|
||||
error = "Invalid username or password";
|
||||
});
|
||||
});
|
||||
|
||||
if (error == null) {
|
||||
// ignore: use_build_context_synchronously
|
||||
setState(() {
|
||||
loading = true;
|
||||
});
|
||||
context.pop();
|
||||
}
|
||||
},
|
||||
mouseCursor: SystemMouseCursors.click,
|
||||
child: Container(
|
||||
width: getMainWidth(context) / 3,
|
||||
padding: const EdgeInsets.symmetric(vertical: 20),
|
||||
color: usernameCtrl.text == "" || passwordCtrl.text == "" ? Colors.grey : lightColor,
|
||||
child: Center( child: loading ? SpinKitWave(color: Colors.white, size: 20) : Text("LOGIN", style: TextStyle(
|
||||
color: usernameCtrl.text == "" || passwordCtrl.text == "" ? midColor :Colors.white,
|
||||
fontSize: 15) ))))),
|
||||
])
|
||||
]),
|
||||
],));
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:oc_front/main.dart';
|
||||
import 'package:oc_front/models/response.dart';
|
||||
import 'package:oc_front/core/services/router.dart';
|
||||
import 'package:oc_front/pages/shared.dart';
|
||||
@@ -9,7 +10,7 @@ class ShallowCreationDialogWidget extends StatefulWidget {
|
||||
GlobalKey<ShallowTextInputWidgetState>? formKey;
|
||||
BuildContext context;
|
||||
bool Function()? canClose;
|
||||
SharedWorkspaceType type = SharedWorkspaceType.workspace;
|
||||
CollaborativeAreaType type = CollaborativeAreaType.workspace;
|
||||
Future<List<Shallow>> Function()? all;
|
||||
Future<void> Function(String)? load;
|
||||
Future<void> Function(Map<String,dynamic>)? create;
|
||||
@@ -25,7 +26,7 @@ class ShallowCreationDialogState extends State<ShallowCreationDialogWidget> {
|
||||
GlobalKey<FormFieldState> key = GlobalKey<FormFieldState>();
|
||||
GlobalKey<FormFieldState> key2 = GlobalKey<FormFieldState>();
|
||||
@override Widget build(BuildContext context) {
|
||||
var t = widget.type == SharedWorkspaceType.workspace ? "workspace" : (widget.type == SharedWorkspaceType.workflow ? "workflow" : (widget.type == SharedWorkspaceType.shared_workspace ? "shared workspace" :"peer"));
|
||||
var t = widget.type == CollaborativeAreaType.workspace ? "workspace" : (widget.type == CollaborativeAreaType.workflow ? "workflow" : (widget.type == CollaborativeAreaType.collaborative_area ? "collaborative area" :"peer"));
|
||||
return Container(
|
||||
color: Colors.white,
|
||||
padding: const EdgeInsets.only( top: 0, bottom: 20, left: 20, right: 20),
|
||||
@@ -57,7 +58,8 @@ class ShallowCreationDialogState extends State<ShallowCreationDialogWidget> {
|
||||
ShallowDropdownInputWidget(
|
||||
all: widget.all,
|
||||
type: widget.type,
|
||||
width: MediaQuery.of(context).size.width <= 540 ? MediaQuery.of(context).size.width - 140 : 400,
|
||||
hint: "select a $t",
|
||||
width: getMainWidth(context) <= 540 ? getMainWidth(context) - 140 : 400,
|
||||
load: (e) async {
|
||||
await widget.load!(e);
|
||||
Navigator.pop(widget.context);
|
||||
@@ -71,13 +73,14 @@ class ShallowCreationDialogState extends State<ShallowCreationDialogWidget> {
|
||||
deletion: true,
|
||||
color: Colors.black,
|
||||
hintColor: Colors.grey,
|
||||
filled: Colors.grey.shade300,
|
||||
filled: midColor,
|
||||
),
|
||||
Container( height: 10),
|
||||
ShallowTextInputWidget(
|
||||
widget.create != null ? ShallowTextInputWidget(
|
||||
key: widget.formKey,
|
||||
type: widget.type,
|
||||
width: MediaQuery.of(context).size.width <= 540 ? MediaQuery.of(context).size.width - 140 : 400,
|
||||
hint: "create a new $t",
|
||||
width: getMainWidth(context) <= 540 ? getMainWidth(context) - 140 : 400,
|
||||
load: (e) async {
|
||||
await widget.create!(e);
|
||||
Navigator.pop(widget.context);
|
||||
@@ -86,9 +89,9 @@ class ShallowCreationDialogState extends State<ShallowCreationDialogWidget> {
|
||||
canLoad: (p0) => p0 != null && p0.isNotEmpty,
|
||||
color: Colors.black,
|
||||
hintColor: Colors.grey,
|
||||
filled: Colors.grey.shade300,
|
||||
),
|
||||
...widget.form.map( (e) => Container( margin: const EdgeInsets.only(top: 10), child: e)),
|
||||
filled: midColor,
|
||||
) : Container(),
|
||||
...(widget.create != null ? widget.form.map( (e) => Container( margin: const EdgeInsets.only(top: 10), child: e)) : []),
|
||||
]
|
||||
)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user