Created
May 14, 2021 08:31
-
-
Save userow/d23660552280697e91cb13b54431a449 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MainScreen extends StatelessWidget { | |
void handlePopupClick(BuildContext context, num value) { | |
switch (value) { | |
case 0: | |
RepositoryProvider.of<AuthenticationRepository>(context).logOut(); | |
break; | |
} | |
} | |
@override | |
Widget build(BuildContext context) { | |
PanelController _panelController = new PanelController(); | |
return MultiRepositoryProvider( | |
providers: [ | |
RepositoryProvider<PoiRepository>( | |
create: (context) => PoiRepository(), | |
), | |
RepositoryProvider<HereLocationRepository>( | |
create: (context) => HereLocationRepository(), | |
), | |
], | |
child: BlocProvider( | |
create: (innerContext) => MapBloc( | |
RepositoryProvider.of<PoiRepository>(innerContext), | |
RepositoryProvider.of<HereLocationRepository>(innerContext)), | |
child: Scaffold( | |
body: Stack(children: [ | |
Column(children: [ | |
Expanded( | |
child: BlocBuilder<MenuBloc, MenusState>( | |
buildWhen: (previous, current) => | |
previous.selectedIndex != current.selectedIndex, | |
builder: (context, state) { | |
return getCorrectWidget(state.selectedItem); | |
})), | |
Align( | |
alignment: Alignment.bottomCenter, | |
child: DKVBottomMenu()), | |
]), | |
Padding( | |
padding: EdgeInsets.only(top: 12), | |
child: SafeArea(child: HomeAppBar())), | |
//TODO: Bugfix for HomeAppBar on all screens - use this when there will be ok with UI on other screens | |
BlocBuilder<MenuBloc, MenusState>( | |
buildWhen: (previous, current) => | |
previous.selectedIndex != current.selectedIndex, | |
builder: (context, state) { | |
if (state.selectedItem?.navigation == | |
"/stationfinder") { | |
return Padding( | |
padding: EdgeInsets.only(top: 12), | |
child: SafeArea(child: HomeAppBar())); | |
} else { | |
return Container(width: 0.0, height: 0.0); | |
} | |
}), | |
Align( | |
alignment: Alignment.bottomCenter, | |
child: PoiListWidget()), | |
// Align(alignment: Alignment.bottomCenter, child: PoiWidget()), | |
BlocBuilder<MapBloc, MapState>( | |
buildWhen: (previous, current) => | |
previous.isShowingPoi != current.isShowingPoi, | |
builder: (context, state) { | |
double _minHeight = state.isShowingPoi ?? false | |
? MediaQuery.of(context).size.height * 0.65 | |
: 0.0; | |
var slidingUpPanel = SlidingUpPanel( | |
maxHeight: MediaQuery.of(context).size.height, | |
snapPoint: 0.65, | |
minHeight: _minHeight, | |
// TODO: implement. min = 0 max = MediaQuery.of(context).size.height snapPoint = 0.65 | |
controller: _panelController, | |
backdropEnabled: true, | |
backdropTapClosesPanel: true, | |
backdropColor: DKVColors.grey40, | |
backdropOpacity: 0.8, | |
parallaxEnabled: false, | |
panel: Padding( | |
padding: EdgeInsets.only(top: 12), | |
child: PoiWidget(), | |
), | |
onPanelClosed: () { | |
print("!!!closed panel"); | |
BlocProvider.of<MapBloc>(context) | |
.add(HidePoiEvent()); | |
}, | |
header: Row(children: [ | |
SizedBox( | |
width: 42, | |
height: 1, | |
), | |
Container( | |
height: 46, | |
width: MediaQuery.of(context).size.width - | |
(42 + 83), | |
color: Colors.transparent, | |
), | |
SizedBox( | |
width: 83, | |
height: 1, | |
), | |
])); | |
//!!! not working here!!! | |
// if (state.isShowingPoi == true) { | |
// _panelController.animatePanelToSnapPoint(); | |
// } else { | |
// _panelController.close(); | |
// } | |
return slidingUpPanel; | |
}), | |
Align( | |
alignment: Alignment.bottomCenter, | |
child: MapControlsWidget()), | |
Align(alignment: Alignment.topCenter, child: FilterView()), | |
]), | |
drawer: DDDDrawer()))); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment