mirror of
https://github.com/mitchell/selfpass.git
synced 2025-12-15 21:47:23 +00:00
Initial app scaffolding, including flutter files, 3 screens, and 1 widget
This commit is contained in:
parent
3a62efc6cc
commit
cad969d98c
61 changed files with 1691 additions and 0 deletions
72
lib/screens/authentication.dart
Normal file
72
lib/screens/authentication.dart
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
import 'package:flutter/cupertino.dart';
|
||||
|
||||
class Authentication extends StatefulWidget {
|
||||
@override
|
||||
_AuthenticationState createState() => _AuthenticationState();
|
||||
}
|
||||
|
||||
class _AuthenticationState extends State<Authentication> {
|
||||
static const String _masterpass = 'hunter#2';
|
||||
bool _invalid = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CupertinoPageScaffold(
|
||||
child: Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 50.0),
|
||||
child: Column(
|
||||
children: _buildColumnChildren(context),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> _buildColumnChildren(BuildContext context) {
|
||||
final children = [
|
||||
const Spacer(flex: 4),
|
||||
const Flexible(child: Text('Master password:')),
|
||||
Flexible(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 5.0),
|
||||
child: CupertinoTextField(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: CupertinoColors.black),
|
||||
borderRadius: const BorderRadius.all(Radius.circular(5.0)),
|
||||
),
|
||||
clearButtonMode: OverlayVisibilityMode.editing,
|
||||
textAlign: TextAlign.center,
|
||||
onSubmitted: _makeTextFieldOnSubmittedHandler(context),
|
||||
obscureText: true,
|
||||
),
|
||||
),
|
||||
),
|
||||
];
|
||||
|
||||
if (_invalid) {
|
||||
children.add(const Flexible(
|
||||
child: Text(
|
||||
'invalid masterpass',
|
||||
style: TextStyle(color: CupertinoColors.destructiveRed),
|
||||
),
|
||||
));
|
||||
children.add(const Spacer(flex: 2));
|
||||
} else {
|
||||
children.add(const Spacer(flex: 3));
|
||||
}
|
||||
|
||||
return children;
|
||||
}
|
||||
|
||||
ValueChanged<String> _makeTextFieldOnSubmittedHandler(BuildContext context) {
|
||||
return (String pass) {
|
||||
if (pass != _masterpass) {
|
||||
this.setState(() {
|
||||
_invalid = true;
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
Navigator.of(context).pushReplacementNamed('/home');
|
||||
};
|
||||
}
|
||||
}
|
||||
26
lib/screens/credentials.dart
Normal file
26
lib/screens/credentials.dart
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import 'package:flutter/cupertino.dart';
|
||||
|
||||
import '../widgets/tappable_text_list.dart';
|
||||
|
||||
class Credentials extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CupertinoPageScaffold(
|
||||
child: TappableTextList(tappableText: _buildTappableText(context)),
|
||||
navigationBar: const CupertinoNavigationBar(middle: Text('Credentials')),
|
||||
);
|
||||
}
|
||||
|
||||
static Map<String, GestureTapCallback> _buildTappableText(
|
||||
BuildContext context) {
|
||||
var handleOnTap = () {};
|
||||
|
||||
Map<String, GestureTapCallback> tappableText = {
|
||||
'm@mjfs.us': handleOnTap,
|
||||
'm-mjfs': handleOnTap,
|
||||
'mitchelljfsimon@gmail.com-mitchelljfsimon': handleOnTap,
|
||||
};
|
||||
|
||||
return tappableText;
|
||||
}
|
||||
}
|
||||
29
lib/screens/home.dart
Normal file
29
lib/screens/home.dart
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import 'package:flutter/cupertino.dart';
|
||||
// import 'package:provider/provider.dart';
|
||||
|
||||
// import '../types/abstracts.dart';
|
||||
// import '../types/credential.dart';
|
||||
import '../widgets/tappable_text_list.dart';
|
||||
|
||||
class Home extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CupertinoPageScaffold(
|
||||
child: TappableTextList(tappableText: _buildTappableText(context)),
|
||||
navigationBar:
|
||||
const CupertinoNavigationBar(middle: Text('Credentials Hosts')),
|
||||
);
|
||||
}
|
||||
|
||||
static Map<String, GestureTapCallback> _buildTappableText(
|
||||
BuildContext context) {
|
||||
var handleOnTap = () => Navigator.of(context).pushNamed('/credentials');
|
||||
Map<String, GestureTapCallback> tappableText = {
|
||||
"google.com": handleOnTap,
|
||||
"amazon.com": handleOnTap,
|
||||
"linkedin.com": handleOnTap,
|
||||
};
|
||||
|
||||
return tappableText;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue