mirror of
https://github.com/gabehf/Fladder.git
synced 2026-04-24 04:51:51 -07:00
feature: Rework responsive layout (#217)
Co-authored-by: PartyDonut <PartyDonut@users.noreply.github.com>
This commit is contained in:
parent
e07f280124
commit
8012fdcea8
48 changed files with 1468 additions and 1040 deletions
|
|
@ -10,6 +10,8 @@ part 'home_settings_model.g.dart';
|
|||
@freezed
|
||||
class HomeSettingsModel with _$HomeSettingsModel {
|
||||
factory HomeSettingsModel({
|
||||
@Default({...LayoutMode.values}) Set<LayoutMode> screenLayouts,
|
||||
@Default({...ViewSize.values}) Set<ViewSize> layoutStates,
|
||||
@Default(HomeBanner.carousel) HomeBanner homeBanner,
|
||||
@Default(HomeCarouselSettings.combined) HomeCarouselSettings carouselSettings,
|
||||
@Default(HomeNextUp.separate) HomeNextUp nextUp,
|
||||
|
|
@ -18,6 +20,48 @@ class HomeSettingsModel with _$HomeSettingsModel {
|
|||
factory HomeSettingsModel.fromJson(Map<String, dynamic> json) => _$HomeSettingsModelFromJson(json);
|
||||
}
|
||||
|
||||
T selectAvailableOrSmaller<T>(T value, Set<T> availableOptions, List<T> allOptions) {
|
||||
if (availableOptions.contains(value)) {
|
||||
return value;
|
||||
}
|
||||
|
||||
int index = allOptions.indexOf(value);
|
||||
|
||||
for (int i = index - 1; i >= 0; i--) {
|
||||
if (availableOptions.contains(allOptions[i])) {
|
||||
return allOptions[i];
|
||||
}
|
||||
}
|
||||
|
||||
return availableOptions.first;
|
||||
}
|
||||
|
||||
enum ViewSize {
|
||||
phone,
|
||||
tablet,
|
||||
desktop;
|
||||
|
||||
const ViewSize();
|
||||
|
||||
String label(BuildContext context) => switch (this) {
|
||||
ViewSize.phone => context.localized.phone,
|
||||
ViewSize.tablet => context.localized.tablet,
|
||||
ViewSize.desktop => context.localized.desktop,
|
||||
};
|
||||
}
|
||||
|
||||
enum LayoutMode {
|
||||
single,
|
||||
dual;
|
||||
|
||||
const LayoutMode();
|
||||
|
||||
String label(BuildContext context) => switch (this) {
|
||||
LayoutMode.single => context.localized.layoutModeSingle,
|
||||
LayoutMode.dual => context.localized.layoutModeDual,
|
||||
};
|
||||
}
|
||||
|
||||
enum HomeBanner {
|
||||
hide,
|
||||
carousel,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue