diff --git a/assets/images/maxio.png b/assets/images/maxio.png new file mode 100644 index 0000000..92adfcb Binary files /dev/null and b/assets/images/maxio.png differ diff --git a/lib/pages/feed_page.dart b/lib/pages/feed_page.dart index 8742d33..ff053c1 100644 --- a/lib/pages/feed_page.dart +++ b/lib/pages/feed_page.dart @@ -22,10 +22,19 @@ class _FeedPageState extends State { return Card( child: ListTile( title: Text(feedItem.text), - subtitle: Text(getTimeString(feedItem.timestamp)), - trailing: Text( - '${feedItem.timestamp.hour}:${feedItem.timestamp.minute}', - style: Theme.of(context).textTheme.bodyLarge!.copyWith(), + trailing: Row( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Text(getTimeString(feedItem.timestamp)), + const Padding( + padding: EdgeInsets.symmetric(horizontal: 15), + ), + Text( + '${feedItem.timestamp.hour}:${feedItem.timestamp.minute}', + style: Theme.of(context).textTheme.bodyLarge!.copyWith(), + ), + ], ), ), ); @@ -46,9 +55,11 @@ String getTimeString(DateTime time) { } else if (duration.inDays > 1) { return '${duration.inDays} days ago'; } else if (duration.inHours > 0) { - return '${duration.inHours} hours ago'; + String text = duration.inHours == 1 ? 'hour' : 'hours'; + return '${duration.inHours} $text ago'; } else if (duration.inMinutes > 0) { - return '${duration.inMinutes} minutes ago'; + String text = duration.inMinutes == 1 ? 'minute' : 'minutes'; + return '${duration.inMinutes} $text ago'; } else { return 'just seconds ago'; } diff --git a/lib/pages/login_page.dart b/lib/pages/login_page.dart index d32325f..1ed5fe9 100644 --- a/lib/pages/login_page.dart +++ b/lib/pages/login_page.dart @@ -1,10 +1,18 @@ import 'package:flutter/material.dart'; - +import 'package:audioplayers/audioplayers.dart'; import '../services/db_helper.dart'; -class LoginPage extends StatelessWidget { +class LoginPage extends StatefulWidget { const LoginPage({super.key}); + @override + State createState() => _LoginPageState(); +} + +class _LoginPageState extends State { + double _height = 0; + final player = AudioPlayer(); + @override Widget build(BuildContext context) { double width = MediaQuery.of(context).size.width / 2; @@ -12,45 +20,71 @@ class LoginPage extends StatelessWidget { TextEditingController username = TextEditingController(); return Scaffold( body: Center( - child: Card( - child: Padding( - padding: const EdgeInsets.all(15.0), - child: SizedBox( - width: width, - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Text( - 'Welcome!', - style: Theme.of(context) - .textTheme - .displayMedium! - .copyWith(fontWeight: FontWeight.bold), - ), - const Padding(padding: EdgeInsets.symmetric(vertical: 5)), - Text('please enter your first name to get started', - style: Theme.of(context).textTheme.bodyLarge), - const Padding(padding: EdgeInsets.symmetric(vertical: 15)), - TextField( - controller: username, - onSubmitted: (value) => DbHelper.login(username.text), - textInputAction: TextInputAction.done, - decoration: const InputDecoration( - label: Text('Your first name'), - border: OutlineInputBorder(), - ), - ), - const Padding(padding: EdgeInsets.symmetric(vertical: 15)), - FloatingActionButton.extended( - onPressed: () => DbHelper.login(username.text), - label: const Text('READY'), - ) - ], + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Padding( + padding: EdgeInsets.only(top: _height > 0 ? 0 : 300), + child: AnimatedContainer( + duration: const Duration(milliseconds: 500), + height: _height, + width: 250, + child: Image.asset('assets/images/maxio.png', height: _height), ), ), - ), + Card( + child: Padding( + padding: const EdgeInsets.all(15.0), + child: SizedBox( + width: width, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + 'Welcome!', + style: Theme.of(context) + .textTheme + .displayMedium! + .copyWith(fontWeight: FontWeight.bold), + ), + const Padding(padding: EdgeInsets.symmetric(vertical: 5)), + Text('please enter your first name to get started', + style: Theme.of(context).textTheme.bodyLarge), + const Padding( + padding: EdgeInsets.symmetric(vertical: 15)), + TextField( + onTap: () => _onTap(), + controller: username, + onSubmitted: (value) => DbHelper.login(username.text), + textInputAction: TextInputAction.done, + decoration: const InputDecoration( + label: Text('Your first name'), + border: OutlineInputBorder(), + ), + ), + const Padding( + padding: EdgeInsets.symmetric(vertical: 15)), + FloatingActionButton.extended( + onPressed: () => DbHelper.login(username.text), + label: const Text('READY'), + ) + ], + ), + ), + ), + ), + const Padding(padding: EdgeInsets.only(top: 300)), + ], ), ), ); } + + Future _onTap() async { + setState(() { + _height = 300; + }); + await player.play(UrlSource( + 'https://vhmrtvhcmvylhrhblyjb.supabase.co/storage/v1/object/public/audio/itsMeMax.mp3')); + } } diff --git a/pubspec.lock b/pubspec.lock index 6861019..8f1b93a 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -17,6 +17,62 @@ packages: url: "https://pub.dev" source: hosted version: "2.11.0" + audioplayers: + dependency: "direct main" + description: + name: audioplayers + sha256: d9f6ca8e9b3e5af5e73d4c814404566f72698ee7ba35487bdf2baa6749e7503f + url: "https://pub.dev" + source: hosted + version: "5.2.0" + audioplayers_android: + dependency: transitive + description: + name: audioplayers_android + sha256: fb01b9481f431fe04ac60f1f97ce8158383f2dc754558820592f795d81ca9d53 + url: "https://pub.dev" + source: hosted + version: "4.0.2" + audioplayers_darwin: + dependency: transitive + description: + name: audioplayers_darwin + sha256: "3034e99a6df8d101da0f5082dcca0a2a99db62ab1d4ddb3277bed3f6f81afe08" + url: "https://pub.dev" + source: hosted + version: "5.0.2" + audioplayers_linux: + dependency: transitive + description: + name: audioplayers_linux + sha256: "60787e73fefc4d2e0b9c02c69885402177e818e4e27ef087074cf27c02246c9e" + url: "https://pub.dev" + source: hosted + version: "3.1.0" + audioplayers_platform_interface: + dependency: transitive + description: + name: audioplayers_platform_interface + sha256: "365c547f1bb9e77d94dd1687903a668d8f7ac3409e48e6e6a3668a1ac2982adb" + url: "https://pub.dev" + source: hosted + version: "6.1.0" + audioplayers_web: + dependency: transitive + description: + name: audioplayers_web + sha256: "22cd0173e54d92bd9b2c80b1204eb1eb159ece87475ab58c9788a70ec43c2a62" + url: "https://pub.dev" + source: hosted + version: "4.1.0" + audioplayers_windows: + dependency: transitive + description: + name: audioplayers_windows + sha256: "9536812c9103563644ada2ef45ae523806b0745f7a78e89d1b5fb1951de90e1a" + url: "https://pub.dev" + source: hosted + version: "3.1.0" boolean_selector: dependency: transitive description: @@ -429,6 +485,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.10.0" + sprintf: + dependency: transitive + description: + name: sprintf + sha256: "1fc9ffe69d4df602376b52949af107d8f5703b77cda567c4d7d86a0693120f23" + url: "https://pub.dev" + source: hosted + version: "7.0.0" stack_trace: dependency: transitive description: @@ -477,6 +541,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.10.22" + synchronized: + dependency: transitive + description: + name: synchronized + sha256: "5fcbd27688af6082f5abd611af56ee575342c30e87541d0245f7ff99faa02c60" + url: "https://pub.dev" + source: hosted + version: "3.1.0" term_glyph: dependency: transitive description: @@ -565,6 +637,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.8" + uuid: + dependency: transitive + description: + name: uuid + sha256: b715b8d3858b6fa9f68f87d20d98830283628014750c2b09b6f516c1da4af2a7 + url: "https://pub.dev" + source: hosted + version: "4.1.0" vector_math: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index b2a66ac..8d19c13 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,6 +15,7 @@ dependencies: shared_preferences: ^2.2.2 provider: ^6.0.5 supabase_flutter: ^1.10.22 + audioplayers: ^5.2.0 dev_dependencies: flutter_test: @@ -23,6 +24,8 @@ dev_dependencies: flutter_lints: ^3.0.0 flutter: uses-material-design: true + assets: + - assets/images/maxio.png fonts: - family: Ubuntu fonts: