forked from MinaOTP/MinaOTP-flutter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
58 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,59 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:english_words/english_words.dart'; | ||
|
||
void main() => runApp(new MyApp()); | ||
void main() => runApp(new MinaOTP()); | ||
|
||
class MyApp extends StatelessWidget { | ||
class MinaOTP extends StatelessWidget { | ||
@override | ||
Widget build(BuildContext context) { | ||
return new MaterialApp( | ||
title: 'Welcome to Flutter', | ||
home: new Scaffold( | ||
appBar: new AppBar( | ||
title: new Text('Welcome to Flutter'), | ||
), | ||
body: new Center( | ||
child: new Text('Hello World'), | ||
), | ||
title: 'MinaOTP', | ||
home: new RandomWords(), | ||
); | ||
} | ||
} | ||
|
||
class RandomWords extends StatefulWidget { | ||
@override | ||
createState() => new RandomWordsState(); | ||
} | ||
|
||
class RandomWordsState extends State<RandomWords> { | ||
final _suggestions = <WordPair>[]; | ||
final _biggerFont = const TextStyle(fontSize: 18.0); | ||
|
||
Widget _buildSuggestions() { | ||
return new ListView.builder( | ||
padding: const EdgeInsets.all(16.0), | ||
itemBuilder: (context, i) { | ||
if (i.isOdd) return new Divider(); | ||
|
||
final index = i ~/ 2; | ||
if (index >= _suggestions.length) { | ||
_suggestions.addAll(generateWordPairs().take(10)); | ||
} | ||
|
||
return _buildRow(_suggestions[index]); | ||
} | ||
); | ||
} | ||
|
||
Widget _buildRow(WordPair pair) { | ||
return new ListTile( | ||
title: new Text( | ||
pair.asPascalCase, | ||
style: _biggerFont, | ||
), | ||
); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return new Scaffold( | ||
appBar: new AppBar( | ||
title: new Text('MinaOTP'), | ||
), | ||
body: _buildSuggestions(), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters