Skip to content

Commit

Permalink
rework timeline settings
Browse files Browse the repository at this point in the history
  • Loading branch information
xal committed Oct 4, 2020
1 parent 3166d82 commit 1b8d868
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 32 deletions.
1 change: 1 addition & 0 deletions lib/app/custom_list/custom_list_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class _CustomListPageState extends State<CustomListPage> {
widget.customList.title,
],
),
actions: [],
),
body: SafeArea(
child: CollapsibleOwnerWidget(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class _TimelinesHomeTabStorageWidgetState
onPressed: () {
goToTimelineSettingsPage(
context,
Timeline: item,
timeline: item,
);
},
),
Expand Down
69 changes: 39 additions & 30 deletions lib/app/timeline/settings/timeline_settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ class TimelineSettingsPage extends StatelessWidget {

void goToTimelineSettingsPage(
BuildContext context, {
@required Timeline Timeline,
@required Timeline timeline,
}) {
Navigator.push(
context,
createTimelineSettingsPageRoute(
context,
timeline: Timeline,
timeline: timeline,
),
);
}
Expand All @@ -61,6 +61,7 @@ MaterialPageRoute createTimelineSettingsPageRoute(
BuildContext context, {
@required Timeline timeline,
}) {
assert(timeline != null);
var localPreferencesService =
ILocalPreferencesService.of(context, listen: false);
var currentAuthInstanceBloc =
Expand All @@ -73,38 +74,46 @@ MaterialPageRoute createTimelineSettingsPageRoute(
localPreferencesService,
userAtHost: currentInstance.userAtHost,
timelineId: timeline.id,
defaultValue: null,
defaultValue: timeline,
);
},
child: DisposableProvider<ITimelineSettingsFormBloc>(
create: (BuildContext context) {
var timelineLocalPreferencesBloc = ITimelineLocalPreferencesBloc.of(
context,
listen: false,
);
var timeline = timelineLocalPreferencesBloc.value;
var timelineSettingsBloc = TimelineSettingsFormBloc(
originalSettings: timeline?.settings,
type: timeline.type,
);
child: Builder(
builder: (context) => FediAsyncInitLoadingWidget(
asyncInitLoadingBloc:
ITimelineLocalPreferencesBloc.of(context, listen: false),
loadingFinishedBuilder: (context) =>
DisposableProvider<ITimelineSettingsFormBloc>(
create: (BuildContext context) {
var timelineLocalPreferencesBloc =
ITimelineLocalPreferencesBloc.of(
context,
listen: false,
);
var currentTimeline = timelineLocalPreferencesBloc.value ?? timeline;
var timelineSettingsBloc = TimelineSettingsFormBloc(
originalSettings: currentTimeline?.settings,
type: currentTimeline.type,
);

timelineSettingsBloc.addDisposable(
streamSubscription:
timelineSettingsBloc.timelineSettingsStream.listen(
(timelineSettings) {
var oldValue = timelineLocalPreferencesBloc.value;
timelineLocalPreferencesBloc.setValue(
oldValue.copyWith(
settings: timelineSettings,
),
);
},
timelineSettingsBloc.addDisposable(
streamSubscription:
timelineSettingsBloc.timelineSettingsStream.listen(
(timelineSettings) {
var oldValue = timelineLocalPreferencesBloc.value;
timelineLocalPreferencesBloc.setValue(
oldValue.copyWith(
settings: timelineSettings,
),
);
},
),
);
return timelineSettingsBloc;
},
child: TimelineSettingsPage(
originalTimeline: timeline,
),
);
return timelineSettingsBloc;
},
child: TimelineSettingsPage(
originalTimeline: timeline,
),
),
),
),
Expand Down
2 changes: 1 addition & 1 deletion lib/app/timeline/settings/timeline_settings_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class TimelineSettingsWidget extends StatelessWidget {

@override
Widget build(BuildContext context) {
var settingsBloc = ITimelineSettingsFormBloc.of(context, listen: true);
var settingsBloc = ITimelineSettingsFormBloc.of(context, listen: false);

var currentAuthInstanceBloc =
ICurrentAuthInstanceBloc.of(context, listen: false);
Expand Down

0 comments on commit 1b8d868

Please sign in to comment.