-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add example for custom settings, use git dependencies
- Loading branch information
1 parent
4726045
commit ae9e273
Showing
6 changed files
with
68 additions
and
138 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,18 @@ | ||
import 'package:enough_mail_app/enough_mail_app.dart'; | ||
import 'package:flutter/widgets.dart'; | ||
import 'package:go_router/go_router.dart'; | ||
import 'package:riverpod_annotation/riverpod_annotation.dart'; | ||
|
||
part 'provider.g.dart'; | ||
/// Shows how to override the default settings | ||
class CustomSettingsNotifier extends SettingsNotifier { | ||
/// Creates a new [CustomSettingsNotifier] | ||
CustomSettingsNotifier({ | ||
super.settings, | ||
}); | ||
|
||
@Riverpod(keepAlive: true) | ||
class CustomSettingsUiElements extends _$CustomSettingsUiElements | ||
implements SettingsUiElements { | ||
@override | ||
void build() {} | ||
String getSignatureHtmlGlobal(BuildContext context) => | ||
state.signatureHtml ?? '<p>---<br/>${context.text.signature}</p>'; | ||
|
||
@override | ||
List<UiSettingsElement> generate( | ||
BuildContext context, | ||
) { | ||
final text = context.text; | ||
final standardElements = SettingsUiElements.buildStandardElements(context); | ||
|
||
/// You can remove a standard element easily like this: | ||
// standardElements.removeType(UiSettingsType.welcome); | ||
// You can insert a new element at a specific position like this: | ||
// standardElements.insertAfter(UiSettingsType.accounts, newElement); | ||
|
||
return [ | ||
...standardElements, | ||
UiSettingsElement.divider(), | ||
UiSettingsElement( | ||
title: text.settingsDevelopment, | ||
onTap: () => context.pushNamed(Routes.settingsDevelopment), | ||
), | ||
]; | ||
} | ||
String getSignaturePlainGlobal(BuildContext context) => | ||
state.signaturePlain ?? '---\n${context.text.signature}'; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import 'package:enough_mail_app/enough_mail_app.dart'; | ||
import 'package:flutter/widgets.dart'; | ||
import 'package:go_router/go_router.dart'; | ||
import 'package:riverpod_annotation/riverpod_annotation.dart'; | ||
|
||
part 'provider.g.dart'; | ||
|
||
@Riverpod(keepAlive: true) | ||
class CustomSettingsUiElements extends _$CustomSettingsUiElements | ||
implements SettingsUiElements { | ||
@override | ||
void build() {} | ||
|
||
@override | ||
List<UiSettingsElement> generate( | ||
BuildContext context, | ||
) { | ||
final text = context.text; | ||
final standardElements = SettingsUiElements.buildStandardElements(context); | ||
|
||
/// You can remove a standard element easily like this: | ||
// standardElements.removeType(UiSettingsType.welcome); | ||
// You can insert a new element at a specific position like this: | ||
// standardElements.insertAfter(UiSettingsType.accounts, newElement); | ||
|
||
return [ | ||
...standardElements, | ||
UiSettingsElement.divider(), | ||
UiSettingsElement( | ||
title: text.settingsDevelopment, | ||
onTap: () => context.pushNamed(Routes.settingsDevelopment), | ||
), | ||
]; | ||
} | ||
} |
File renamed without changes.
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
This file was deleted.
Oops, something went wrong.