Skip to content

Instantly share code, notes, and snippets.

@jacobaraujo7
Created August 21, 2019 14:20
Show Gist options
  • Save jacobaraujo7/2c0f0f60fb2b287ee82a8adaa7250dda to your computer and use it in GitHub Desktop.
Save jacobaraujo7/2c0f0f60fb2b287ee82a8adaa7250dda to your computer and use it in GitHub Desktop.
import 'package:bloc_pattern/bloc_pattern.dart';
import 'package:flutter/material.dart';
import 'package:sa/src/screens/protections/pages/properties/properties_details/components/coverage_component.dart';
import 'package:sa/src/screens/protections/pages/properties/properties_details/property_details_bloc.dart';
import 'package:sa/src/shared/localization/app_localizations.dart';
import 'package:sa/src/shared/widgets/custom_tabbar/custom_tabbar_header.dart';
import 'package:sa/src/shared/widgets/custom_tabbar/custom_tabbar_widget.dart';
import 'package:sa/src/shared/widgets/sliver_persistent_header/sliver_persistent_header.dart';
import 'components/card_component.dart';
import 'components/icons_component.dart';
import 'components/details_component.dart';
import 'tabs/occurrencies_tab.dart';
import 'tabs/photos_tab.dart';
import 'tabs/history_tab.dart';
class PropertyDetailsPage extends StatefulWidget {
final int index;
const PropertyDetailsPage({Key key, @required this.index})
: assert(index != null),
super(key: key);
@override
_PropertyDetailsPageState createState() => _PropertyDetailsPageState();
}
class _PropertyDetailsPageState extends State<PropertyDetailsPage>
with TickerProviderStateMixin {
PageController controller;
PropertyDetailsBloc get bloc =>
BlocProvider.tag("property_details_page").getBloc<PropertyDetailsBloc>();
AppLocalizations get localization => AppLocalizations.of(context);
final ScrollController _nestedController = ScrollController();
@override
void initState() {
super.initState();
controller = PageController();
}
@override
void dispose() {
controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
centerTitle: true,
title: Text(
"${AppLocalizations.of(context).propertyDetailsPageProtection} ${bloc.propertyModel.property.description}"),
),
body: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
CardComponent(index: widget.index),
SizedBox(height: 15),
Divider(height: 0),
Expanded(
child: NestedScrollView(
controller: _nestedController,
physics: ClampingScrollPhysics(),
headerSliverBuilder: (context, innerBoxIsScrolled) {
return <Widget>[
SliverOverlapAbsorber(
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(
context,
),
child: SliverList(
delegate: SliverChildListDelegate([
SizedBox(height: 5),
DetailsComponent(),
CoverageComponent(),
SizedBox(height: 5),
IconsComponent(index: widget.index),
SizedBox(height: 5),
]),
),
),
SliverPersistentHeader(
pinned: true,
delegate: CustomSliverAppBarDelegate(
child: PreferredSize(
preferredSize: Size(MediaQuery.of(context).size.width, 48),
child: CustomTabbarHeader(
controller: controller,
tabs: <Tab>[
Tab(
text: localization.vehicleProtectionPhotosLabel
.toUpperCase()),
Tab(
text: localization.vehicleProtectionHistoryLabel
.toUpperCase()),
Tab(
text: localization
.vehicleProtectionOcurrenciesLabel
.toUpperCase()),
],
),
)),
),
];
},
body: Container(
child: Column(children: <Widget>[
Expanded(
child: Container(
color: Color(0xFFF5F5F5),
child: CustomTabbarWidget(
isSnnaping: false,
physics: NeverScrollableScrollPhysics(),
controller: controller,
children: <Widget>[
PhotosTab(tabController: controller),
AnimatedBuilder(
animation: _nestedController,
child: HistoryTab(tabController: controller),
builder: (BuildContext context, Widget child) {
var max = (_nestedController?.position?.maxScrollExtent ?? 50) - 50;
return AnimatedPadding(duration: Duration(milliseconds: 300),
padding: EdgeInsets.only(top: _nestedController.offset > max ? 50 : 0),
child: child,
);
},
),
OccurrenciesTab(tabController: controller),
],
),
),
),
]),
),
),
),
],
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment