Skip to content

Commit

Permalink
Feature/comments pr fab button (#23)
Browse files Browse the repository at this point in the history
* resolve comments

* check format
  • Loading branch information
SolMendiola authored Nov 7, 2022
1 parent 7168ae8 commit 5eeeb03
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 34 deletions.
28 changes: 13 additions & 15 deletions lib/ui/common/custom_scaffold_fab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import 'package:flutter_template/ui/extensions/context_extensions.dart';
import 'package:flutter_template/ui/theme/app_theme.dart';
import 'package:flutter_template/ui/common/fab.dart';

class CustomScaffoldFab extends StatelessWidget {
class MainScaffoldWithFab extends StatelessWidget {
final FabState state;
final IconData? iconSelected;
final IconData iconNotSelected;
final VoidCallback? action;
final Widget? child;

const CustomScaffoldFab({
const MainScaffoldWithFab({
Key? key,
required this.state,
this.iconSelected,
Expand All @@ -20,17 +20,15 @@ class CustomScaffoldFab extends StatelessWidget {
}) : super(key: key);

@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: context.theme.colors.background,
floatingActionButtonLocation: FloatingActionButtonLocation.endDocked,
floatingActionButton: Fab(
state: state,
iconNotSelected: iconNotSelected,
action: action,
iconSelected: iconSelected,
),
body: child,
);
}
Widget build(BuildContext context) => Scaffold(
backgroundColor: context.theme.colors.background,
floatingActionButtonLocation: FloatingActionButtonLocation.endDocked,
floatingActionButton: Fab(
state: state,
iconNotSelected: iconNotSelected,
action: action,
iconSelected: iconSelected,
),
body: child,
);
}
27 changes: 10 additions & 17 deletions lib/ui/home/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@ class HomeScreen extends StatefulWidget {

class _HomeScreenState extends State<HomeScreen> {
final _scaffoldKey = GlobalKey<ScaffoldState>();
var hideFab = false;

@override
void initState() {
super.initState();
}
var _hideFab = false;

@override
Widget build(BuildContext context) {
Expand All @@ -27,7 +22,7 @@ class _HomeScreenState extends State<HomeScreen> {
builder: (context, child, tabsController) {
return Scaffold(
onDrawerChanged: (stateDrawer) => setState(() {
hideFab = stateDrawer;
_hideFab = stateDrawer;
}),
extendBody: true,
extendBodyBehindAppBar: true,
Expand All @@ -45,14 +40,12 @@ class _HomeScreenState extends State<HomeScreen> {
);
}

Widget buildFab(BuildContext context) {
return Visibility(
visible: !hideFab,
child: Fab(
state: FabState.notSelected(),
iconNotSelected: Icons.arrow_forward_ios,
action: () => _scaffoldKey.currentState!.openDrawer(),
),
);
}
Widget buildFab(BuildContext context) => Visibility(
visible: !_hideFab,
child: Fab(
state: FabState.notSelected(),
iconNotSelected: Icons.arrow_forward_ios,
action: () => _scaffoldKey.currentState!.openDrawer(),
),
);
}
1 change: 1 addition & 0 deletions lib/ui/tips/tips_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class TipCubit extends Cubit<TipsBaseState> {
void setCurrentPage(int index) => emit(state.copyWith(currentPage: index));

void changeFavouriteButton(int index) {
//TODO: do this in the repository
final newList = [...state.tips];
var tip = newList[index];
newList[index] = tip.copyWith(favourite: !tip.favourite);
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/tips/tips_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class _TipContentScreenState extends State<_TipContentScreen> {

return BlocBuilder<TipCubit, TipsBaseState>(
builder: (context, state) {
return CustomScaffoldFab(
return MainScaffoldWithFab(
iconNotSelected: Icons.star_border,
state:
state.tips.isNotEmpty && state.tips[state.currentPage].favourite
Expand Down
3 changes: 2 additions & 1 deletion lib/ui/videos/videos.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ class _VideosContentScreen extends StatelessWidget {
return Center(
child: Text(
'VIDEOS',
style: TextStyle(color: context.theme.colors.onPrimary),
style: context.theme.textStyles.headlineMedium!
.copyWith(color: context.theme.colors.onPrimary),
),
);
}
Expand Down

0 comments on commit 5eeeb03

Please sign in to comment.