astronote/lib/endi.dart

166 lines
4.4 KiB
Dart
Raw Normal View History

import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'bloc.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:flushbar/flushbar.dart';
class EndiLog extends StatefulWidget {
@override
_EndiLogState createState() => _EndiLogState();
}
class _EndiLogState extends State<EndiLog> {
TextStyle style = TextStyle(fontFamily: 'Varela Round', fontSize: 20.0);
@override
Widget build(BuildContext context) {
DeepLinkBloc _bloc = Provider.of<DeepLinkBloc>(context);
return StreamBuilder<String>(
stream: _bloc.state,
builder: (context, snapshot) {
if (!snapshot.hasData) {
return Container(
child: Center(child: Text('No deep link was used ')));
} else {
return SingleChildScrollView(
child: Container(
height: MediaQuery.of(context).size.height,
color: Colors.white,
child: Padding(
padding: EdgeInsets.all(50),
child: Column(
children: <Widget>[
// SizedBox(height: 40),
_logoApp(),
_titleApp(),
SizedBox(height: 80),
_emailField(),
SizedBox(height: 30),
_passwordField(),
SizedBox(height: 50),
_logButton(),
SizedBox(height: 70),
_enDIUrl(),
SizedBox(height: 5),
_astrolabeUrl()
],
),
),
),
);
}
});
}
Widget _logoApp() {
return SizedBox(
height: 100.0,
child: Image.asset(
"assets/astrolabe_logo.jpg",
),
);
}
Widget _titleApp() {
return Text(
"AstroNotes",
style: style.copyWith(color: Colors.black, fontSize: 40),
);
}
Widget _emailField() {
return TextField(
style: style,
keyboardType: TextInputType.emailAddress,
decoration: InputDecoration(
contentPadding: EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 15.0),
labelText: "E-mail",
border:
OutlineInputBorder(borderRadius: BorderRadius.circular(32.0))),
);
}
Widget _passwordField() {
return TextField(
style: style,
obscureText: true,
decoration: InputDecoration(
contentPadding: EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 15.0),
labelText: "Mot de passe",
border:
OutlineInputBorder(borderRadius: BorderRadius.circular(32.0))),
);
}
Widget _logButton() {
return Material(
elevation: 5.0,
borderRadius: BorderRadius.circular(30.0),
color: Color(0xFF4A148C),
child: MaterialButton(
// minWidth: MediaQuery.of(context).size.width,
padding: EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 15.0),
onPressed: () {},
child: Text("Connexion",
textAlign: TextAlign.center,
style: style.copyWith(
color: Colors.white, fontWeight: FontWeight.bold)),
));
}
void showErrorFlushbar(BuildContext context) {
Flushbar(
message: "Impossible d'ouvrir le lien",
backgroundColor: Colors.red[300],
duration: Duration(seconds: 3),
// Show it with a cascading operator
)..show(context);
}
void _launchLinkEnDI() async {
const url = "https://endi.coop";
if (await canLaunch(url)) {
await launch(url);
} else {
showErrorFlushbar(context);
}
}
void _launchLinkAstrolabe() async {
const url = "https://astrolabe.coop";
if (await canLaunch(url)) {
await launch(url);
} else {
showErrorFlushbar(context);
}
}
Widget _enDIUrl() {
return InkWell(
onTap: _launchLinkEnDI,
child: Text(
"En collaboration avec enDI",
style: style.copyWith(
color: Colors.black,
fontSize: 15,
decoration: TextDecoration.underline),
),
);
}
Widget _astrolabeUrl() {
return InkWell(
onTap: _launchLinkAstrolabe,
child: Text(
"Développé par Astrolabe",
style: style.copyWith(
color: Colors.black,
fontSize: 15,
decoration: TextDecoration.underline),
),
);
}
}