diff --git a/lib/main.dart b/lib/main.dart index a35400a..121b620 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -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'), + )); } diff --git a/lib/views/main_view.dart b/lib/views/main_view.dart index 610b4c5..1ea713f 100644 --- a/lib/views/main_view.dart +++ b/lib/views/main_view.dart @@ -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 { @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( - 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) => + >[ + const PopupMenuItem( + value: SampleItem.itemOne, + child: Text('Item 1'), + ), + const PopupMenuItem( + value: SampleItem.itemTwo, + child: Text('Item 2'), + ), + const PopupMenuItem( + 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: [ + 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()}, ), ], ), diff --git a/pubspec.yaml b/pubspec.yaml index b756c5e..8220dc6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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 diff --git a/res/fonts/EurostileRound-Black.ttf b/res/fonts/EurostileRound-Black.ttf new file mode 100644 index 0000000..d249fa9 Binary files /dev/null and b/res/fonts/EurostileRound-Black.ttf differ diff --git a/res/fonts/EurostileRound-BlackItalic.ttf b/res/fonts/EurostileRound-BlackItalic.ttf new file mode 100644 index 0000000..6faabf1 Binary files /dev/null and b/res/fonts/EurostileRound-BlackItalic.ttf differ diff --git a/res/fonts/EurostileRound-Bold.ttf b/res/fonts/EurostileRound-Bold.ttf new file mode 100644 index 0000000..f5dec04 Binary files /dev/null and b/res/fonts/EurostileRound-Bold.ttf differ diff --git a/res/fonts/EurostileRound-BoldItalic.ttf b/res/fonts/EurostileRound-BoldItalic.ttf new file mode 100644 index 0000000..b8510e8 Binary files /dev/null and b/res/fonts/EurostileRound-BoldItalic.ttf differ diff --git a/res/fonts/EurostileRound-Heavy.ttf b/res/fonts/EurostileRound-Heavy.ttf new file mode 100644 index 0000000..cf46f5c Binary files /dev/null and b/res/fonts/EurostileRound-Heavy.ttf differ diff --git a/res/fonts/EurostileRound-HeavyItalic.ttf b/res/fonts/EurostileRound-HeavyItalic.ttf new file mode 100644 index 0000000..34924f9 Binary files /dev/null and b/res/fonts/EurostileRound-HeavyItalic.ttf differ diff --git a/res/fonts/EurostileRound-Italic.ttf b/res/fonts/EurostileRound-Italic.ttf new file mode 100644 index 0000000..4692d5e Binary files /dev/null and b/res/fonts/EurostileRound-Italic.ttf differ diff --git a/res/fonts/EurostileRound-Medium.ttf b/res/fonts/EurostileRound-Medium.ttf new file mode 100644 index 0000000..750cbac Binary files /dev/null and b/res/fonts/EurostileRound-Medium.ttf differ diff --git a/res/fonts/EurostileRound-MediumItalic.ttf b/res/fonts/EurostileRound-MediumItalic.ttf new file mode 100644 index 0000000..722b65c Binary files /dev/null and b/res/fonts/EurostileRound-MediumItalic.ttf differ diff --git a/res/fonts/EurostileRound-Regular.ttf b/res/fonts/EurostileRound-Regular.ttf new file mode 100644 index 0000000..1f4c411 Binary files /dev/null and b/res/fonts/EurostileRound-Regular.ttf differ diff --git a/res/fonts/EurostileRoundCondensed-Heavy.ttf b/res/fonts/EurostileRoundCondensed-Heavy.ttf new file mode 100644 index 0000000..445d151 Binary files /dev/null and b/res/fonts/EurostileRoundCondensed-Heavy.ttf differ diff --git a/res/fonts/EurostileRoundCondensed-HeavyItalic.ttf b/res/fonts/EurostileRoundCondensed-HeavyItalic.ttf new file mode 100644 index 0000000..97c7cfe Binary files /dev/null and b/res/fonts/EurostileRoundCondensed-HeavyItalic.ttf differ diff --git a/res/fonts/EurostileRoundCondensed-Italic.ttf b/res/fonts/EurostileRoundCondensed-Italic.ttf new file mode 100644 index 0000000..45512c6 Binary files /dev/null and b/res/fonts/EurostileRoundCondensed-Italic.ttf differ diff --git a/res/fonts/EurostileRoundCondensed-Regular.ttf b/res/fonts/EurostileRoundCondensed-Regular.ttf new file mode 100644 index 0000000..0800a45 Binary files /dev/null and b/res/fonts/EurostileRoundCondensed-Regular.ttf differ diff --git a/res/fonts/EurostileRoundExtended-Black.ttf b/res/fonts/EurostileRoundExtended-Black.ttf new file mode 100644 index 0000000..0a39deb Binary files /dev/null and b/res/fonts/EurostileRoundExtended-Black.ttf differ diff --git a/res/fonts/EurostileRoundExtended-BlackItalic.ttf b/res/fonts/EurostileRoundExtended-BlackItalic.ttf new file mode 100644 index 0000000..d16d8b9 Binary files /dev/null and b/res/fonts/EurostileRoundExtended-BlackItalic.ttf differ diff --git a/res/fonts/EurostileRoundExtended-Italic.ttf b/res/fonts/EurostileRoundExtended-Italic.ttf new file mode 100644 index 0000000..7a1a68a Binary files /dev/null and b/res/fonts/EurostileRoundExtended-Italic.ttf differ diff --git a/res/fonts/EurostileRoundExtended-Medium.ttf b/res/fonts/EurostileRoundExtended-Medium.ttf new file mode 100644 index 0000000..09304bc Binary files /dev/null and b/res/fonts/EurostileRoundExtended-Medium.ttf differ diff --git a/res/fonts/EurostileRoundExtended-Regular.ttf b/res/fonts/EurostileRoundExtended-Regular.ttf new file mode 100644 index 0000000..3175d6c Binary files /dev/null and b/res/fonts/EurostileRoundExtended-Regular.ttf differ