mirror of
https://github.com/mitchell/selfpass.git
synced 2025-12-14 21:27:22 +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
21
lib/main.dart
Normal file
21
lib/main.dart
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import 'package:flutter/cupertino.dart';
|
||||
|
||||
import 'screens/authentication.dart';
|
||||
import 'screens/home.dart';
|
||||
import 'screens/credentials.dart';
|
||||
|
||||
void main() => runApp(Selfpass());
|
||||
|
||||
class Selfpass extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CupertinoApp(
|
||||
title: 'Selfpass',
|
||||
routes: <String, WidgetBuilder>{
|
||||
'/': (BuildContext context) => Authentication(),
|
||||
'/home': (BuildContext context) => Home(),
|
||||
'/credentials': (BuildContext context) => Credentials(),
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
35
lib/widgets/tappable_text_list.dart
Normal file
35
lib/widgets/tappable_text_list.dart
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
import 'package:flutter/cupertino.dart';
|
||||
|
||||
class TappableTextList extends StatelessWidget {
|
||||
final Map<String, GestureTapCallback> tappableText;
|
||||
|
||||
TappableTextList({Key key, this.tappableText}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListView(
|
||||
children: _buildListChildren(context),
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> _buildListChildren(BuildContext context) {
|
||||
List<Widget> widgets = [];
|
||||
|
||||
tappableText.forEach((String text, GestureTapCallback handleOnTap) {
|
||||
widgets.add(GestureDetector(
|
||||
onTap: handleOnTap,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 15.0),
|
||||
decoration: const BoxDecoration(
|
||||
border: Border(
|
||||
bottom: BorderSide(color: CupertinoColors.lightBackgroundGray),
|
||||
),
|
||||
),
|
||||
child: Text(text, textAlign: TextAlign.center),
|
||||
),
|
||||
));
|
||||
});
|
||||
|
||||
return widgets;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue