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() { void main() {
sqfliteFfiInit(); sqfliteFfiInit();
databaseFactory = databaseFactoryFfi; 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; late TetrioPlayer me;
DB db = DB(); DB db = DB();
TetrioService teto = TetrioService(); TetrioService teto = TetrioService();
const allowedHeightForPlayerIdInPixels = 60.0;
const allowedHeightForPlayerBioInPixels = 30.0;
const givenTextHeightByScreenPercentage = 0.3;
enum SampleItem { itemOne, itemTwo, itemThree }
class MainView extends StatefulWidget { class MainView extends StatefulWidget {
const MainView({Key? key}) : super(key: key); const MainView({Key? key}) : super(key: key);
@ -50,77 +55,205 @@ class _MainViewState extends State<MainView> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( drawer: NavDrawer(),
title: const Text("Tetra Stats"), backgroundColor: Colors.black,
), body: CustomScrollView(
body: Row( slivers: [
mainAxisAlignment: MainAxisAlignment.center, SliverAppBar(
children: [ title: const Text("Tetra Stats"),
Expanded( floating: false,
child: TextField( pinned: true,
onChanged: (String value) { flexibleSpace: Row(
_searchFor = value; mainAxisAlignment: MainAxisAlignment.center,
}, children: [
onSubmitted: (String value) { ClipRRect(
setState(() { borderRadius: BorderRadius.circular(1000),
me = fetchTetrioPlayer(value); child: Image.network(
}); "https://tetr.io/user-content/avatars/6098518e3d5155e6ec429cdc.jpg?rv=1673453211638",
}, fit: BoxFit.fitHeight,
maxLength: 25, height: 256,
)), ),
TextButton( ),
child: const Text("Search"), LayoutBuilder(builder: (context, constraints) {
onPressed: () { return Column(
setState(() { mainAxisSize: MainAxisSize.min,
me = fetchTetrioPlayer(_searchFor); mainAxisAlignment: MainAxisAlignment.center,
}); children: [
}), if (constraints.maxHeight *
FutureBuilder<TetrioPlayer>( givenTextHeightByScreenPercentage >
future: me, allowedHeightForPlayerBioInPixels)
builder: (context, snapshot) { const Text("dan63047",
if (snapshot.hasData) { style: TextStyle(
snapshot.data!.getRecords(); fontFamily: "Eurostile Round Extended",
teto.storeState(snapshot.data!, db); color: Colors.white,
return Flexible( fontSize: 42))
child: Column(children: [ else
Text(snapshot.data!.username.toString()), const Text("dan63047",
Text(snapshot.data!.userId.toString()), style: TextStyle(
Text(snapshot.data!.role.toString()), fontFamily: "Eurostile Round Extended",
Text( color: Colors.white,
"Level ${snapshot.data!.level.toStringAsFixed(2)} (${snapshot.data!.xp} XP)"), fontSize: 36)),
Text("Registered ${snapshot.data!.registrationTime}"), if (constraints.maxHeight *
Text("Bio: ${snapshot.data!.bio}", softWrap: true), givenTextHeightByScreenPercentage >
Text("Country: ${snapshot.data!.country}"), allowedHeightForPlayerIdInPixels)
Text("${snapshot.data!.friendCount} friends"), const Text(
Text( "6098518e3d5155e6ec429cdc",
"Won/PLayed: ${snapshot.data!.gamesWon}/${snapshot.data!.gamesPlayed}"), style: TextStyle(
Text("Gametime: ${snapshot.data!.gameTime}"), fontFamily: "Eurostile Round Condensed",
Text("Supporter tier ${snapshot.data!.supporterTier}"), color: Colors.white,
const Text("\nTetra League", softWrap: true), fontSize: 14),
Text( ),
"${snapshot.data!.tlSeason1.rating.toStringAsFixed(2)} TR"), if (constraints.maxHeight *
Text( givenTextHeightByScreenPercentage >
"${snapshot.data!.tlSeason1.glicko?.toStringAsFixed(2)}±${snapshot.data!.tlSeason1.rd?.toStringAsFixed(2)} GLICKO"), allowedHeightForPlayerBioInPixels)
Text( const Text(
"Rank: ${snapshot.data!.tlSeason1.rank.toUpperCase()} (top ${(snapshot.data!.tlSeason1.percentile * 100).toStringAsFixed(2)}%)"), "osk, please, if my supporter ends, let me use :petthekagari: in the chat",
Text( style: TextStyle(
"Won/Games: ${snapshot.data!.tlSeason1.gamesPlayed}/${snapshot.data!.tlSeason1.gamesWon}"), fontFamily: "Eurostile Round",
Text( color: Colors.white,
"${snapshot.data!.tlSeason1.standing} (№${snapshot.data!.tlSeason1.standingLocal} in country)"), fontSize: 16,
Text( ),
"${snapshot.data!.tlSeason1.apm} APM, ${snapshot.data!.tlSeason1.pps} PPS, ${snapshot.data!.tlSeason1.vs} VS, ${snapshot.data!.tlSeason1.app?.toStringAsFixed(3)} APP"), softWrap: true),
const Text("\n40 Lines", softWrap: true), ],
Text(snapshot.data!.sprint.isNotEmpty );
? snapshot.data!.sprint[0].toString() })
: "No record"), ],
])); ),
} else if (snapshot.hasError) { expandedHeight: 400,
return Text('${snapshot.error}'); backgroundColor: Colors.black,
} actions: [
IconButton(
// By default, show a loading spinner. onPressed: () {},
return const CircularProgressIndicator(); 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, # For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages # 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.