First attempt into UI,

lets hope it's gonna be usable
This commit is contained in:
dan63047 2023-05-25 22:21:56 +03:00
parent e119ecf11b
commit ffad0ae6cb
22 changed files with 244 additions and 72 deletions

View File

@ -5,5 +5,8 @@ import 'package:sqflite_common_ffi/sqflite_ffi.dart';
void main() {
sqfliteFfiInit();
databaseFactory = databaseFactoryFfi;
runApp(MaterialApp(home: MainView()));
runApp(MaterialApp(
home: MainView(),
theme: ThemeData(fontFamily: 'Eurostile Round'),
));
}

View File

@ -9,6 +9,11 @@ String _searchFor = "";
late TetrioPlayer me;
DB db = DB();
TetrioService teto = TetrioService();
const allowedHeightForPlayerIdInPixels = 60.0;
const allowedHeightForPlayerBioInPixels = 30.0;
const givenTextHeightByScreenPercentage = 0.3;
enum SampleItem { itemOne, itemTwo, itemThree }
class MainView extends StatefulWidget {
const MainView({Key? key}) : super(key: key);
@ -50,77 +55,205 @@ class _MainViewState extends State<MainView> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Tetra Stats"),
),
body: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(
child: TextField(
onChanged: (String value) {
_searchFor = value;
},
onSubmitted: (String value) {
setState(() {
me = fetchTetrioPlayer(value);
});
},
maxLength: 25,
)),
TextButton(
child: const Text("Search"),
onPressed: () {
setState(() {
me = fetchTetrioPlayer(_searchFor);
});
}),
FutureBuilder<TetrioPlayer>(
future: me,
builder: (context, snapshot) {
if (snapshot.hasData) {
snapshot.data!.getRecords();
teto.storeState(snapshot.data!, db);
return Flexible(
child: Column(children: [
Text(snapshot.data!.username.toString()),
Text(snapshot.data!.userId.toString()),
Text(snapshot.data!.role.toString()),
Text(
"Level ${snapshot.data!.level.toStringAsFixed(2)} (${snapshot.data!.xp} XP)"),
Text("Registered ${snapshot.data!.registrationTime}"),
Text("Bio: ${snapshot.data!.bio}", softWrap: true),
Text("Country: ${snapshot.data!.country}"),
Text("${snapshot.data!.friendCount} friends"),
Text(
"Won/PLayed: ${snapshot.data!.gamesWon}/${snapshot.data!.gamesPlayed}"),
Text("Gametime: ${snapshot.data!.gameTime}"),
Text("Supporter tier ${snapshot.data!.supporterTier}"),
const Text("\nTetra League", softWrap: true),
Text(
"${snapshot.data!.tlSeason1.rating.toStringAsFixed(2)} TR"),
Text(
"${snapshot.data!.tlSeason1.glicko?.toStringAsFixed(2)}±${snapshot.data!.tlSeason1.rd?.toStringAsFixed(2)} GLICKO"),
Text(
"Rank: ${snapshot.data!.tlSeason1.rank.toUpperCase()} (top ${(snapshot.data!.tlSeason1.percentile * 100).toStringAsFixed(2)}%)"),
Text(
"Won/Games: ${snapshot.data!.tlSeason1.gamesPlayed}/${snapshot.data!.tlSeason1.gamesWon}"),
Text(
"${snapshot.data!.tlSeason1.standing} (№${snapshot.data!.tlSeason1.standingLocal} in country)"),
Text(
"${snapshot.data!.tlSeason1.apm} APM, ${snapshot.data!.tlSeason1.pps} PPS, ${snapshot.data!.tlSeason1.vs} VS, ${snapshot.data!.tlSeason1.app?.toStringAsFixed(3)} APP"),
const Text("\n40 Lines", softWrap: true),
Text(snapshot.data!.sprint.isNotEmpty
? snapshot.data!.sprint[0].toString()
: "No record"),
]));
} else if (snapshot.hasError) {
return Text('${snapshot.error}');
}
// By default, show a loading spinner.
return const CircularProgressIndicator();
},
drawer: NavDrawer(),
backgroundColor: Colors.black,
body: CustomScrollView(
slivers: [
SliverAppBar(
title: const Text("Tetra Stats"),
floating: false,
pinned: true,
flexibleSpace: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ClipRRect(
borderRadius: BorderRadius.circular(1000),
child: Image.network(
"https://tetr.io/user-content/avatars/6098518e3d5155e6ec429cdc.jpg?rv=1673453211638",
fit: BoxFit.fitHeight,
height: 256,
),
),
LayoutBuilder(builder: (context, constraints) {
return Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (constraints.maxHeight *
givenTextHeightByScreenPercentage >
allowedHeightForPlayerBioInPixels)
const Text("dan63047",
style: TextStyle(
fontFamily: "Eurostile Round Extended",
color: Colors.white,
fontSize: 42))
else
const Text("dan63047",
style: TextStyle(
fontFamily: "Eurostile Round Extended",
color: Colors.white,
fontSize: 36)),
if (constraints.maxHeight *
givenTextHeightByScreenPercentage >
allowedHeightForPlayerIdInPixels)
const Text(
"6098518e3d5155e6ec429cdc",
style: TextStyle(
fontFamily: "Eurostile Round Condensed",
color: Colors.white,
fontSize: 14),
),
if (constraints.maxHeight *
givenTextHeightByScreenPercentage >
allowedHeightForPlayerBioInPixels)
const Text(
"osk, please, if my supporter ends, let me use :petthekagari: in the chat",
style: TextStyle(
fontFamily: "Eurostile Round",
color: Colors.white,
fontSize: 16,
),
softWrap: true),
],
);
})
],
),
expandedHeight: 400,
backgroundColor: Colors.black,
actions: [
IconButton(
onPressed: () {},
icon: const Icon(Icons.search),
tooltip: "Search player",
),
PopupMenuButton(
itemBuilder: (BuildContext context) =>
<PopupMenuEntry<SampleItem>>[
const PopupMenuItem<SampleItem>(
value: SampleItem.itemOne,
child: Text('Item 1'),
),
const PopupMenuItem<SampleItem>(
value: SampleItem.itemTwo,
child: Text('Item 2'),
),
const PopupMenuItem<SampleItem>(
value: SampleItem.itemThree,
child: Text('Item 3'),
),
],
),
],
),
SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) => ListTile(
title: Text('Item #$index'),
tileColor: Colors.transparent,
textColor: Colors.white,
),
childCount: 1000,
),
),
],
),
);
}
}
class NavDrawer extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Drawer(
child: ListView(
padding: EdgeInsets.zero,
children: <Widget>[
const DrawerHeader(
child: Text(
'Side menu',
style: TextStyle(color: Colors.white, fontSize: 25),
),
decoration: BoxDecoration(
color: Color.fromARGB(255, 40, 44, 41),
image: DecorationImage(
fit: BoxFit.fill,
image: AssetImage('assets/images/cover.jpg'))),
),
ListTile(
leading: const Icon(Icons.input),
title: const Text('Welcome'),
onTap: () => {},
),
ListTile(
leading: const Icon(Icons.verified_user),
title: const Text('Profile'),
onTap: () => {Navigator.of(context).pop()},
),
ListTile(
leading: const Icon(Icons.settings),
title: const Text('Settings'),
onTap: () => {Navigator.of(context).pop()},
),
ListTile(
leading: const Icon(Icons.border_color),
title: const Text('Feedback'),
onTap: () => {Navigator.of(context).pop()},
),
ListTile(
leading: const Icon(Icons.exit_to_app),
title: const Text('Logout'),
onTap: () => {Navigator.of(context).pop()},
),
ListTile(
leading: const Icon(Icons.input),
title: const Text('Welcome'),
onTap: () => {},
),
ListTile(
leading: const Icon(Icons.verified_user),
title: const Text('Profile'),
onTap: () => {Navigator.of(context).pop()},
),
ListTile(
leading: const Icon(Icons.settings),
title: const Text('Settings'),
onTap: () => {Navigator.of(context).pop()},
),
ListTile(
leading: const Icon(Icons.border_color),
title: const Text('Feedback'),
onTap: () => {Navigator.of(context).pop()},
),
ListTile(
leading: const Icon(Icons.exit_to_app),
title: const Text('Logout'),
onTap: () => {Navigator.of(context).pop()},
),
ListTile(
leading: const Icon(Icons.input),
title: const Text('Welcome'),
onTap: () => {},
),
ListTile(
leading: const Icon(Icons.verified_user),
title: const Text('Profile'),
onTap: () => {Navigator.of(context).pop()},
),
ListTile(
leading: const Icon(Icons.settings),
title: const Text('Settings'),
onTap: () => {Navigator.of(context).pop()},
),
ListTile(
leading: const Icon(Icons.border_color),
title: const Text('Feedback'),
onTap: () => {Navigator.of(context).pop()},
),
ListTile(
leading: const Icon(Icons.exit_to_app),
title: const Text('Logout'),
onTap: () => {Navigator.of(context).pop()},
),
],
),

View File

@ -93,3 +93,39 @@ flutter:
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages
fonts:
- family: Eurostile Round
fonts:
- asset: res/fonts/EurostileRound-Black.ttf
- asset: res/fonts/EurostileRound-BlackItalic.ttf
- asset: res/fonts/EurostileRound-Bold.ttf
- asset: res/fonts/EurostileRound-BoldItalic.ttf
- asset: res/fonts/EurostileRound-Heavy.ttf
weight: 900
- asset: res/fonts/EurostileRound-HeavyItalic.ttf
weight: 900
style: italic
- asset: res/fonts/EurostileRound-Italic.ttf
style: italic
- asset: res/fonts/EurostileRound-Medium.ttf
- asset: res/fonts/EurostileRound-MediumItalic.ttf
weight: 500
style: italic
- asset: res/fonts/EurostileRound-Regular.ttf
- family: Eurostile Round Condensed
fonts:
- asset: res/fonts/EurostileRoundCondensed-Heavy.ttf
- asset: res/fonts/EurostileRoundCondensed-HeavyItalic.ttf
- asset: res/fonts/EurostileRoundCondensed-Italic.ttf
- asset: res/fonts/EurostileRoundCondensed-Regular.ttf
- family: Eurostile Round Extended
fonts:
- asset: res/fonts/EurostileRoundExtended-Black.ttf
- asset: res/fonts/EurostileRoundExtended-BlackItalic.ttf
weight: 900
style: italic
- asset: res/fonts/EurostileRoundExtended-Italic.ttf
style: italic
- asset: res/fonts/EurostileRoundExtended-Medium.ttf
weight: 500
- asset: res/fonts/EurostileRoundExtended-Regular.ttf

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.