Skip to content

Commit

Permalink
feat: Adding heading styles options. #8
Browse files Browse the repository at this point in the history
  • Loading branch information
LuchoTurtle committed Sep 25, 2023
1 parent eadc1ac commit 2170ea9
Showing 1 changed file with 63 additions and 9 deletions.
72 changes: 63 additions & 9 deletions lib/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,34 @@ class HomePageState extends State<HomePage> {
fontSize: 32,
color: Colors.black,
height: 1.15,
fontWeight: FontWeight.w300,
fontWeight: FontWeight.w600,
),
const VerticalSpacing(16, 0),
const VerticalSpacing(0, 0),
null,
),
h2: DefaultTextBlockStyle(
const TextStyle(
fontSize: 24,
color: Colors.black87,
height: 1.15,
fontWeight: FontWeight.w600,
),
const VerticalSpacing(8, 0),
const VerticalSpacing(0, 0),
null,
),
h3: DefaultTextBlockStyle(
const TextStyle(
fontSize: 20,
color: Colors.black87,
height: 1.25,
fontWeight: FontWeight.w600,
),
const VerticalSpacing(8, 0),
const VerticalSpacing(0, 0),
null,
),
sizeSmall: const TextStyle(fontSize: 9),
subscript: const TextStyle(
fontFamily: 'SF-UI-Display',
Expand Down Expand Up @@ -191,12 +213,34 @@ class HomePageState extends State<HomePage> {
fontSize: 32,
color: Colors.black,
height: 1.15,
fontWeight: FontWeight.w300,
fontWeight: FontWeight.w600,
),
const VerticalSpacing(16, 0),
const VerticalSpacing(0, 0),
null,
),
h2: DefaultTextBlockStyle(
const TextStyle(
fontSize: 24,
color: Colors.black87,
height: 1.15,
fontWeight: FontWeight.w600,
),
const VerticalSpacing(8, 0),
const VerticalSpacing(0, 0),
null,
),
h3: DefaultTextBlockStyle(
const TextStyle(
fontSize: 20,
color: Colors.black87,
height: 1.25,
fontWeight: FontWeight.w600,
),
const VerticalSpacing(8, 0),
const VerticalSpacing(0, 0),
null,
),
sizeSmall: const TextStyle(fontSize: 9),
),
embedBuilders: [...defaultEmbedBuildersWeb],
Expand All @@ -215,7 +259,7 @@ class HomePageState extends State<HomePage> {
// `onImagePickCallback` is called after image is picked on mobile platforms
onImagePickCallback: _onImagePickCallback,

// `webImagePickImpl` is called after image is picked on the web
// `webImagePickImpl` is called after image is picked on the web
webImagePickImpl: _webImagePickImpl,

// defining the selector (we only want to open the gallery whenever the person wants to upload an image)
Expand All @@ -240,6 +284,12 @@ class HomePageState extends State<HomePage> {
controller: _controller!,
undo: false,
),
SelectHeaderStyleButton(
controller: _controller!,
axis: Axis.horizontal,
iconSize: toolbarIconSize,
attributes: const [Attribute.h1, Attribute.h2, Attribute.h3],
),
ToggleStyleButton(
attribute: Attribute.bold,
icon: Icons.format_bold,
Expand Down Expand Up @@ -291,12 +341,12 @@ class HomePageState extends State<HomePage> {
/// Renders the image picked by imagePicker from local file storage
/// You can also upload the picked image to any server (eg : AWS s3
/// or Firebase) and then return the uploaded image URL.
///
///
/// It's only called on mobile platforms.
Future<String> _onImagePickCallback(File file) async {
final appDocDir = await getApplicationDocumentsDirectory();
final copiedFile = await file.copy('${appDocDir.path}/${basename(file.path)}');
return copiedFile.path.toString();
final appDocDir = await getApplicationDocumentsDirectory();
final copiedFile = await file.copy('${appDocDir.path}/${basename(file.path)}');
return copiedFile.path.toString();
}

/// Callback that is called after an image is picked whilst on the web platform.
Expand All @@ -323,8 +373,12 @@ class HomePageState extends State<HomePage> {
const apiURL = 'https://imgup.fly.dev/api/images';
final request = http.MultipartRequest('POST', Uri.parse(apiURL));

final httpImage = http.MultipartFile.fromBytes('image', bytes,
contentType: MediaType.parse(lookupMimeType('', headerBytes: bytes)!), filename: platformFile.name,);
final httpImage = http.MultipartFile.fromBytes(
'image',
bytes,
contentType: MediaType.parse(lookupMimeType('', headerBytes: bytes)!),
filename: platformFile.name,
);
request.files.add(httpImage);

// Check the response and handle accordingly
Expand Down

0 comments on commit 2170ea9

Please sign in to comment.