-
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.
Merge pull request #2 from 0Nom4D/flutter-poc
Merging User Profile Page + Main Page First Previews
- Loading branch information
Showing
14 changed files
with
212 additions
and
165 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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import 'package:draw/draw.dart'; | ||
import 'package:f_redditech/models/api_launcher.dart'; | ||
import 'package:f_redditech/views/loading_page.dart'; | ||
import 'package:f_redditech/views/main_page.dart'; | ||
import 'package:flutter/cupertino.dart'; | ||
|
||
class MainPageController extends StatefulWidget { | ||
MainPageController({Key? key}) : super(key: key); | ||
|
||
@override | ||
_MainPageController createState() => _MainPageController(); | ||
} | ||
|
||
class _MainPageController extends State<MainPageController> { | ||
|
||
ApiLauncher redditApi = ApiLauncher(); | ||
List<Submission>? posts; | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
posts = null; | ||
} | ||
|
||
void retrievePosts() async { | ||
List<Submission>? tmp; | ||
|
||
if (redditApi.isFlowCreated() == false) | ||
await redditApi.createRedditFlow(); | ||
if (posts == null) { | ||
tmp = await redditApi.getFrontPagePosts().then((value) { | ||
return (value); | ||
}); | ||
setState(() { | ||
posts = tmp; | ||
}); | ||
} | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
retrievePosts(); | ||
if (posts == null) | ||
return (LoadingScreen()); | ||
return (MainPage( | ||
posts: posts, | ||
)); | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:draw/draw.dart'; | ||
|
||
class MainPage extends StatefulWidget { | ||
|
||
final List<Submission>? posts; | ||
|
||
MainPage({Key? key, required this.posts}) : super(key: key); | ||
|
||
late final int postsLength; | ||
|
||
@override | ||
_MainPageState createState() => _MainPageState(); | ||
|
||
} | ||
|
||
class _MainPageState extends State<MainPage> { | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
widget.postsLength = 0; | ||
} | ||
|
||
_createdPostCard(Submission newPosts) { | ||
print(newPosts.data!); | ||
return (Card( | ||
child: Column( | ||
mainAxisSize: MainAxisSize.min, | ||
children: [ | ||
ListTile( | ||
leading: CircleAvatar( | ||
radius: 25.0, | ||
), | ||
title: Text(newPosts.title), | ||
subtitle: newPosts.body == null ? Text(""): Text(newPosts.body!), | ||
) | ||
], | ||
) | ||
)); | ||
} | ||
|
||
List<Widget> _listCreation() { | ||
List<Widget> _allCards = []; | ||
|
||
for (int i = 0; i < widget.posts!.length; i++) { | ||
_allCards.add(_createdPostCard(widget.posts![i])); | ||
} | ||
return (_allCards); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
int idx = 0; | ||
|
||
return Scaffold( | ||
appBar: AppBar(), | ||
body: ListView( | ||
children: _listCreation(), | ||
) | ||
); | ||
} | ||
} |
Oops, something went wrong.