The first steps of the major update (#1444)
parent
7c5a12b140
commit
45214576f5
29 changed files with 1059 additions and 875 deletions
@ -1,89 +1,89 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8"?> |
<?xml version="1.0" encoding="UTF-8"?> |
||||||
<Scheme |
<Scheme |
||||||
LastUpgradeVersion = "1000" |
LastUpgradeVersion = "1430" |
||||||
version = "1.3"> |
version = "1.3"> |
||||||
<BuildAction |
<BuildAction |
||||||
parallelizeBuildables = "YES" |
parallelizeBuildables = "YES" |
||||||
buildImplicitDependencies = "YES"> |
buildImplicitDependencies = "YES"> |
||||||
<BuildActionEntries> |
<BuildActionEntries> |
||||||
<BuildActionEntry |
<BuildActionEntry |
||||||
buildForTesting = "YES" |
buildForTesting = "YES" |
||||||
buildForRunning = "YES" |
buildForRunning = "YES" |
||||||
buildForProfiling = "YES" |
buildForProfiling = "YES" |
||||||
buildForArchiving = "YES" |
buildForArchiving = "YES" |
||||||
buildForAnalyzing = "YES"> |
buildForAnalyzing = "YES"> |
||||||
<BuildableReference |
<BuildableReference |
||||||
BuildableIdentifier = "primary" |
BuildableIdentifier = "primary" |
||||||
BlueprintIdentifier = "33CC10EC2044A3C60003C045" |
BlueprintIdentifier = "33CC10EC2044A3C60003C045" |
||||||
BuildableName = "app.app" |
BuildableName = "app.app" |
||||||
BlueprintName = "Runner" |
BlueprintName = "Runner" |
||||||
ReferencedContainer = "container:Runner.xcodeproj"> |
ReferencedContainer = "container:Runner.xcodeproj"> |
||||||
</BuildableReference> |
</BuildableReference> |
||||||
</BuildActionEntry> |
</BuildActionEntry> |
||||||
</BuildActionEntries> |
</BuildActionEntries> |
||||||
</BuildAction> |
</BuildAction> |
||||||
<TestAction |
<TestAction |
||||||
buildConfiguration = "Debug" |
buildConfiguration = "Debug" |
||||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" |
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" |
||||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" |
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" |
||||||
shouldUseLaunchSchemeArgsEnv = "YES"> |
shouldUseLaunchSchemeArgsEnv = "YES"> |
||||||
<MacroExpansion> |
<MacroExpansion> |
||||||
<BuildableReference |
<BuildableReference |
||||||
BuildableIdentifier = "primary" |
BuildableIdentifier = "primary" |
||||||
BlueprintIdentifier = "33CC10EC2044A3C60003C045" |
BlueprintIdentifier = "33CC10EC2044A3C60003C045" |
||||||
BuildableName = "app.app" |
BuildableName = "app.app" |
||||||
BlueprintName = "Runner" |
BlueprintName = "Runner" |
||||||
ReferencedContainer = "container:Runner.xcodeproj"> |
ReferencedContainer = "container:Runner.xcodeproj"> |
||||||
</BuildableReference> |
</BuildableReference> |
||||||
</MacroExpansion> |
</MacroExpansion> |
||||||
<AdditionalOptions> |
<AdditionalOptions> |
||||||
</AdditionalOptions> |
</AdditionalOptions> |
||||||
</TestAction> |
</TestAction> |
||||||
<LaunchAction |
<LaunchAction |
||||||
buildConfiguration = "Debug" |
buildConfiguration = "Debug" |
||||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" |
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" |
||||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" |
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" |
||||||
launchStyle = "0" |
launchStyle = "0" |
||||||
useCustomWorkingDirectory = "NO" |
useCustomWorkingDirectory = "NO" |
||||||
ignoresPersistentStateOnLaunch = "NO" |
ignoresPersistentStateOnLaunch = "NO" |
||||||
debugDocumentVersioning = "YES" |
debugDocumentVersioning = "YES" |
||||||
debugServiceExtension = "internal" |
debugServiceExtension = "internal" |
||||||
allowLocationSimulation = "YES"> |
allowLocationSimulation = "YES"> |
||||||
<BuildableProductRunnable |
<BuildableProductRunnable |
||||||
runnableDebuggingMode = "0"> |
runnableDebuggingMode = "0"> |
||||||
<BuildableReference |
<BuildableReference |
||||||
BuildableIdentifier = "primary" |
BuildableIdentifier = "primary" |
||||||
BlueprintIdentifier = "33CC10EC2044A3C60003C045" |
BlueprintIdentifier = "33CC10EC2044A3C60003C045" |
||||||
BuildableName = "app.app" |
BuildableName = "app.app" |
||||||
BlueprintName = "Runner" |
BlueprintName = "Runner" |
||||||
ReferencedContainer = "container:Runner.xcodeproj"> |
ReferencedContainer = "container:Runner.xcodeproj"> |
||||||
</BuildableReference> |
</BuildableReference> |
||||||
</BuildableProductRunnable> |
</BuildableProductRunnable> |
||||||
<AdditionalOptions> |
<AdditionalOptions> |
||||||
</AdditionalOptions> |
</AdditionalOptions> |
||||||
</LaunchAction> |
</LaunchAction> |
||||||
<ProfileAction |
<ProfileAction |
||||||
buildConfiguration = "Profile" |
buildConfiguration = "Profile" |
||||||
shouldUseLaunchSchemeArgsEnv = "YES" |
shouldUseLaunchSchemeArgsEnv = "YES" |
||||||
savedToolIdentifier = "" |
savedToolIdentifier = "" |
||||||
useCustomWorkingDirectory = "NO" |
useCustomWorkingDirectory = "NO" |
||||||
debugDocumentVersioning = "YES"> |
debugDocumentVersioning = "YES"> |
||||||
<BuildableProductRunnable |
<BuildableProductRunnable |
||||||
runnableDebuggingMode = "0"> |
runnableDebuggingMode = "0"> |
||||||
<BuildableReference |
<BuildableReference |
||||||
BuildableIdentifier = "primary" |
BuildableIdentifier = "primary" |
||||||
BlueprintIdentifier = "33CC10EC2044A3C60003C045" |
BlueprintIdentifier = "33CC10EC2044A3C60003C045" |
||||||
BuildableName = "app.app" |
BuildableName = "app.app" |
||||||
BlueprintName = "Runner" |
BlueprintName = "Runner" |
||||||
ReferencedContainer = "container:Runner.xcodeproj"> |
ReferencedContainer = "container:Runner.xcodeproj"> |
||||||
</BuildableReference> |
</BuildableReference> |
||||||
</BuildableProductRunnable> |
</BuildableProductRunnable> |
||||||
</ProfileAction> |
</ProfileAction> |
||||||
<AnalyzeAction |
<AnalyzeAction |
||||||
buildConfiguration = "Debug"> |
buildConfiguration = "Debug"> |
||||||
</AnalyzeAction> |
</AnalyzeAction> |
||||||
<ArchiveAction |
<ArchiveAction |
||||||
buildConfiguration = "Release" |
buildConfiguration = "Release" |
||||||
revealArchiveInOrganizer = "YES"> |
revealArchiveInOrganizer = "YES"> |
||||||
</ArchiveAction> |
</ArchiveAction> |
||||||
</Scheme> |
</Scheme> |
||||||
|
@ -0,0 +1,54 @@ |
|||||||
|
import 'package:flutter/foundation.dart' show immutable; |
||||||
|
import 'package:flutter/material.dart' show Color, Colors; |
||||||
|
|
||||||
|
import '../../flutter_quill.dart'; |
||||||
|
|
||||||
|
// I will start on this in the major-update-2 |
||||||
|
|
||||||
|
@immutable |
||||||
|
class QuillToolbarConfigurations { |
||||||
|
const QuillToolbarConfigurations(); |
||||||
|
} |
||||||
|
|
||||||
|
/// |
||||||
|
@immutable |
||||||
|
class QuillEditorConfigurations { |
||||||
|
const QuillEditorConfigurations(); |
||||||
|
} |
||||||
|
|
||||||
|
/// The shared configurations between [QuillEditorConfigurations] and |
||||||
|
/// [QuillToolbarConfigurations] so we don't duplicate things |
||||||
|
class QuillSharedConfigurations { |
||||||
|
const QuillSharedConfigurations({ |
||||||
|
this.dialogBarrierColor = Colors.black54, |
||||||
|
}); |
||||||
|
|
||||||
|
// This is just example or showcase of this major update to make the library |
||||||
|
// more maintanable, flexible, and customizable |
||||||
|
/// The barrier color of the shown dialogs |
||||||
|
final Color dialogBarrierColor; |
||||||
|
} |
||||||
|
|
||||||
|
@immutable |
||||||
|
class QuillConfigurations { |
||||||
|
const QuillConfigurations({ |
||||||
|
required this.controller, |
||||||
|
this.editorConfigurations = const QuillEditorConfigurations(), |
||||||
|
this.toolbarConfigurations = const QuillToolbarConfigurations(), |
||||||
|
this.sharedConfigurations = const QuillSharedConfigurations(), |
||||||
|
}); |
||||||
|
|
||||||
|
/// Controller object which establishes a link between a rich text document |
||||||
|
/// and this editor. |
||||||
|
/// |
||||||
|
/// The controller is shared between [QuillEditorConfigurations] and |
||||||
|
/// [QuillToolbarConfigurations] but to simplify things we will defined it |
||||||
|
/// here, it should not be null |
||||||
|
final QuillController controller; |
||||||
|
|
||||||
|
final QuillEditorConfigurations editorConfigurations; |
||||||
|
|
||||||
|
final QuillToolbarConfigurations toolbarConfigurations; |
||||||
|
|
||||||
|
final QuillSharedConfigurations sharedConfigurations; |
||||||
|
} |
@ -0,0 +1,37 @@ |
|||||||
|
import 'package:flutter/widgets.dart' show BuildContext; |
||||||
|
|
||||||
|
import '../../../flutter_quill.dart'; |
||||||
|
|
||||||
|
extension BuildContextExt on BuildContext { |
||||||
|
QuillProvider get requireQuillProvider { |
||||||
|
return QuillProvider.ofNotNull(this); |
||||||
|
} |
||||||
|
|
||||||
|
QuillProvider? get quillProvider { |
||||||
|
return QuillProvider.of(this); |
||||||
|
} |
||||||
|
|
||||||
|
QuillController? get quilController { |
||||||
|
return quillProvider?.configurations.controller; |
||||||
|
} |
||||||
|
|
||||||
|
QuillController get requireQuillController { |
||||||
|
return requireQuillProvider.configurations.controller; |
||||||
|
} |
||||||
|
|
||||||
|
QuillConfigurations get requireQuillConfigurations { |
||||||
|
return requireQuillProvider.configurations; |
||||||
|
} |
||||||
|
|
||||||
|
QuillConfigurations? get quillConfigurations { |
||||||
|
return quillProvider?.configurations; |
||||||
|
} |
||||||
|
|
||||||
|
QuillSharedConfigurations? get sharedQuillConfigurations { |
||||||
|
return quillConfigurations?.sharedConfigurations; |
||||||
|
} |
||||||
|
|
||||||
|
QuillSharedConfigurations get requireSharedQuillConfigurations { |
||||||
|
return requireQuillConfigurations.sharedConfigurations; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,50 @@ |
|||||||
|
import 'package:flutter/foundation.dart' show debugPrint, kDebugMode; |
||||||
|
import 'package:flutter/widgets.dart' show InheritedWidget, BuildContext; |
||||||
|
|
||||||
|
import '../../core/quill_configurations.dart'; |
||||||
|
|
||||||
|
class QuillProvider extends InheritedWidget { |
||||||
|
const QuillProvider({ |
||||||
|
required this.configurations, |
||||||
|
required super.child, |
||||||
|
}); |
||||||
|
|
||||||
|
/// Controller object which establishes a link between a rich text document |
||||||
|
/// and this editor. |
||||||
|
/// |
||||||
|
/// Must not be null. |
||||||
|
final QuillConfigurations configurations; |
||||||
|
|
||||||
|
@override |
||||||
|
bool updateShouldNotify(covariant InheritedWidget oldWidget) { |
||||||
|
throw false; |
||||||
|
} |
||||||
|
|
||||||
|
static QuillProvider? of(BuildContext context) { |
||||||
|
return context.dependOnInheritedWidgetOfExactType<QuillProvider>(); |
||||||
|
} |
||||||
|
|
||||||
|
static QuillProvider ofNotNull(BuildContext context) { |
||||||
|
final provider = of(context); |
||||||
|
if (provider == null) { |
||||||
|
if (kDebugMode) { |
||||||
|
debugPrint( |
||||||
|
'The quill provider must be provided in the widget tree.', |
||||||
|
); |
||||||
|
} |
||||||
|
throw ArgumentError.checkNotNull( |
||||||
|
'You are using a widget in the Flutter quill library that require ' |
||||||
|
'The Quill provider widget to be in the parent widget tree ' |
||||||
|
'because ' |
||||||
|
'The provider is $provider. Please make sure to wrap this widget' |
||||||
|
' with' |
||||||
|
' QuillProvider widget. ' |
||||||
|
'You might using QuillEditor and QuillToolbar so make sure to' |
||||||
|
' wrap them with the quill provider widget and setup the required ' |
||||||
|
'configurations', |
||||||
|
'QuillProvider', |
||||||
|
); |
||||||
|
} |
||||||
|
return provider; |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue