From b60fb19ecc64e27928f39ba4e78516305e65c045 Mon Sep 17 00:00:00 2001 From: Inex Code Date: Mon, 30 May 2022 16:49:42 +0300 Subject: [PATCH] some ui fixes --- lib/logic/common_enum/common_enum.dart | 5 +- .../components/brand_header/brand_header.dart | 4 -- .../brand_hero_screen/brand_hero_screen.dart | 3 +- lib/ui/pages/more/more.dart | 1 - lib/ui/pages/providers/providers.dart | 1 - lib/ui/pages/root_route.dart | 67 ++++++++++++++++--- lib/ui/pages/services/services.dart | 1 - lib/ui/pages/users/fab.dart | 36 ---------- lib/ui/pages/users/new_user.dart | 2 +- lib/ui/pages/users/users.dart | 3 - 10 files changed, 61 insertions(+), 62 deletions(-) delete mode 100644 lib/ui/pages/users/fab.dart diff --git a/lib/logic/common_enum/common_enum.dart b/lib/logic/common_enum/common_enum.dart index 94acface..3a1a4d80 100644 --- a/lib/logic/common_enum/common_enum.dart +++ b/lib/logic/common_enum/common_enum.dart @@ -1,6 +1,5 @@ import 'package:easy_localization/easy_localization.dart'; -import 'package:flutter/cupertino.dart'; -import 'package:ionicons/ionicons.dart'; +import 'package:flutter/material.dart'; import 'package:selfprivacy/ui/components/brand_icons/brand_icons.dart'; enum LoadingStatus { @@ -134,7 +133,7 @@ extension ServiceTypesExt on ServiceTypes { case ServiceTypes.git: return BrandIcons.git; case ServiceTypes.vpn: - return Ionicons.shield_checkmark_outline; + return Icons.vpn_lock_outlined; } } diff --git a/lib/ui/components/brand_header/brand_header.dart b/lib/ui/components/brand_header/brand_header.dart index 9f136466..82e73e47 100644 --- a/lib/ui/components/brand_header/brand_header.dart +++ b/lib/ui/components/brand_header/brand_header.dart @@ -1,20 +1,17 @@ import 'package:flutter/material.dart'; import 'package:selfprivacy/ui/components/brand_icons/brand_icons.dart'; import 'package:selfprivacy/ui/components/brand_text/brand_text.dart'; -import 'package:selfprivacy/ui/components/pre_styled_buttons/pre_styled_buttons.dart'; class BrandHeader extends StatelessWidget { const BrandHeader({ Key? key, this.title = '', this.hasBackButton = false, - this.hasFlashButton = false, this.onBackButtonPressed, }) : super(key: key); final String title; final bool hasBackButton; - final bool hasFlashButton; final VoidCallback? onBackButtonPressed; @override @@ -37,7 +34,6 @@ class BrandHeader extends StatelessWidget { ], BrandText.h4(title), const Spacer(), - if (hasFlashButton) PreStyledButtons.flash(), ], ), ); diff --git a/lib/ui/components/brand_hero_screen/brand_hero_screen.dart b/lib/ui/components/brand_hero_screen/brand_hero_screen.dart index 105267a9..33ddcfa8 100644 --- a/lib/ui/components/brand_hero_screen/brand_hero_screen.dart +++ b/lib/ui/components/brand_hero_screen/brand_hero_screen.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:selfprivacy/ui/components/brand_header/brand_header.dart'; +import 'package:selfprivacy/ui/components/pre_styled_buttons/flash_fab.dart'; class BrandHeroScreen extends StatelessWidget { const BrandHeroScreen({ @@ -32,10 +33,10 @@ class BrandHeroScreen extends StatelessWidget { child: BrandHeader( title: headerTitle, hasBackButton: hasBackButton, - hasFlashButton: hasFlashButton, onBackButtonPressed: onBackButtonPressed, ), ), + floatingActionButton: hasFlashButton ? const BrandFab() : null, body: ListView( padding: const EdgeInsets.all(16.0), children: [ diff --git a/lib/ui/pages/more/more.dart b/lib/ui/pages/more/more.dart index 55b6239a..3897c19f 100644 --- a/lib/ui/pages/more/more.dart +++ b/lib/ui/pages/more/more.dart @@ -30,7 +30,6 @@ class MorePage extends StatelessWidget { preferredSize: const Size.fromHeight(52), child: BrandHeader( title: 'basis.more'.tr(), - hasFlashButton: true, ), ), body: ListView( diff --git a/lib/ui/pages/providers/providers.dart b/lib/ui/pages/providers/providers.dart index b3566f2f..2abed128 100644 --- a/lib/ui/pages/providers/providers.dart +++ b/lib/ui/pages/providers/providers.dart @@ -70,7 +70,6 @@ class _ProvidersPageState extends State { preferredSize: const Size.fromHeight(52), child: BrandHeader( title: 'providers.page_title'.tr(), - hasFlashButton: true, ), ), body: ListView( diff --git a/lib/ui/pages/root_route.dart b/lib/ui/pages/root_route.dart index e3ad4ce4..b14ecd52 100644 --- a/lib/ui/pages/root_route.dart +++ b/lib/ui/pages/root_route.dart @@ -16,20 +16,36 @@ class RootPage extends StatefulWidget { State createState() => _RootPageState(); } -class _RootPageState extends State - with SingleTickerProviderStateMixin { +class _RootPageState extends State with TickerProviderStateMixin { late TabController tabController; + late final AnimationController _controller = AnimationController( + duration: const Duration(milliseconds: 400), + vsync: this, + ); + late final Animation _animation = CurvedAnimation( + parent: _controller, + curve: Curves.fastOutSlowIn, + ); + @override void initState() { tabController = TabController(length: 4, vsync: this); + tabController.addListener(() { + setState(() { + tabController.index == 2 + ? _controller.forward() + : _controller.reverse(); + }); + }); super.initState(); } @override void dispose() { - super.dispose(); tabController.dispose(); + _controller.dispose(); + super.dispose(); } var selfprivacyServer = ServerApi(); @@ -37,10 +53,10 @@ class _RootPageState extends State @override Widget build(BuildContext context) { return SafeArea( - child: Scaffold( - body: Provider( - create: (_) => ChangeTab(tabController.animateTo), - child: TabBarView( + child: Provider( + create: (_) => ChangeTab(tabController.animateTo), + child: Scaffold( + body: TabBarView( controller: tabController, children: const [ ProvidersPage(), @@ -49,11 +65,40 @@ class _RootPageState extends State MorePage(), ], ), + bottomNavigationBar: BrandTabBar( + controller: tabController, + ), + floatingActionButton: SizedBox( + height: 104 + 16, + child: Column( + crossAxisAlignment: CrossAxisAlignment.end, + mainAxisAlignment: MainAxisAlignment.end, + children: [ + ScaleTransition( + scale: _animation, + child: FloatingActionButton.small( + heroTag: 'new_user_fab', + onPressed: () { + showModalBottomSheet( + context: context, + isScrollControlled: true, + backgroundColor: Colors.transparent, + builder: (BuildContext context) { + return Padding( + padding: MediaQuery.of(context).viewInsets, + child: NewUser()); + }, + ); + }, + child: const Icon(Icons.person_add_outlined), + ), + ), + const SizedBox(height: 16), + const BrandFab(), + ], + ), + ), ), - bottomNavigationBar: BrandTabBar( - controller: tabController, - ), - floatingActionButton: const BrandFab(), ), ); } diff --git a/lib/ui/pages/services/services.dart b/lib/ui/pages/services/services.dart index e2f3f4ed..c5d781d4 100644 --- a/lib/ui/pages/services/services.dart +++ b/lib/ui/pages/services/services.dart @@ -65,7 +65,6 @@ class _ServicesPageState extends State { preferredSize: const Size.fromHeight(52), child: BrandHeader( title: 'basis.services'.tr(), - hasFlashButton: true, ), ), body: ListView( diff --git a/lib/ui/pages/users/fab.dart b/lib/ui/pages/users/fab.dart deleted file mode 100644 index e6f0ed29..00000000 --- a/lib/ui/pages/users/fab.dart +++ /dev/null @@ -1,36 +0,0 @@ -part of 'users.dart'; - -class _Fab extends StatelessWidget { - const _Fab({Key? key}) : super(key: key); - - @override - Widget build(BuildContext context) { - return SizedBox( - width: 48.0, - height: 48.0, - child: RawMaterialButton( - fillColor: BrandColors.blue, - shape: const CircleBorder(), - elevation: 0.0, - highlightElevation: 2, - child: const Icon( - Icons.add, - color: Colors.white, - size: 34, - ), - onPressed: () { - showModalBottomSheet( - context: context, - isScrollControlled: true, - backgroundColor: Colors.transparent, - builder: (BuildContext context) { - return Padding( - padding: MediaQuery.of(context).viewInsets, - child: _NewUser()); - }, - ); - }, - ), - ); - } -} diff --git a/lib/ui/pages/users/new_user.dart b/lib/ui/pages/users/new_user.dart index 9336d5c2..5b023bad 100644 --- a/lib/ui/pages/users/new_user.dart +++ b/lib/ui/pages/users/new_user.dart @@ -1,6 +1,6 @@ part of 'users.dart'; -class _NewUser extends StatelessWidget { +class NewUser extends StatelessWidget { @override Widget build(BuildContext context) { var config = context.watch().state; diff --git a/lib/ui/pages/users/users.dart b/lib/ui/pages/users/users.dart index 133dfb16..9276b759 100644 --- a/lib/ui/pages/users/users.dart +++ b/lib/ui/pages/users/users.dart @@ -27,7 +27,6 @@ import 'package:share_plus/share_plus.dart'; import '../../../utils/route_transitions/basic.dart'; part 'empty.dart'; -part 'fab.dart'; part 'new_user.dart'; part 'user.dart'; part 'user_details.dart'; @@ -77,10 +76,8 @@ class UsersPage extends StatelessWidget { preferredSize: const Size.fromHeight(52), child: BrandHeader( title: 'basis.users'.tr(), - hasFlashButton: true, ), ), - floatingActionButton: isReady ? const _Fab() : null, body: child, ); }