Skip to content

Instantly share code, notes, and snippets.

View diamantidis's full-sized avatar

Ioannis Diamantidis diamantidis

View GitHub Profile
on handleNameRestrictions(theText)
set theNewText to theText
set firstCharacter to text 1 of theText
if isNumber(firstCharacter) then
set theNewText to "number" & theText
end if
return convertReservedKeywords(theNewText)
end handleNameRestrictions
on toCamelCase(theText)
set theNewText to ""
set dotIsFound to false
repeat with aCharacter in theText
if (aCharacter as string) is equal to "." then
set dotIsFound to true
else
if dotIsFound then
set theNewText to (theNewText & toCapitalized(aCharacter)) as string
else
activate application "SF Symbols"
tell application "System Events"
tell process "SF Symbols"
-- Click the “list” radio button.
click radio button 2 of radio group 1 of group 3 of toolbar 1 of window 0
tell outline 1 of scroll area 1 of splitter group 1 of window 0
select (row 1 where value of static text 1 of UI element 1 starts with "All")
import SwiftUI
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public extension Image {
/// Creates an image object containing a system symbol image.
///
/// - Parameter sfSymbol: The name of the `SFSymbol`
/// - Usage
/// ```
/// Image(sfSymbol: .checkmarkCircleFill)
import UIKit
@available(iOS 13.0, *)
public extension UIImage {
/// Creates an image object containing a system symbol image.
///
/// - Parameter sfSymbol: The name of the `SFSymbol`
/// - Usage
/// ```
/// UIImage(sfSymbol: .checkmarkCircleFill)
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return
Padding(
padding: const EdgeInsets.all(16),
child: Text('Hello, World!', style: Theme.of(context).textTheme.headline4)
);
}
}
extension WidgetModifier on Widget {
Widget padding([EdgeInsetsGeometry value = const EdgeInsets.all(16)]) {
return Padding(
padding: value,
child: this,
);
}
}
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Text('Hello, World!', style: Theme.of(context).textTheme.headline4)
.padding();
}
}
extension WidgetModifier on Widget {
// ...
Widget background(Color color) {
return DecoratedBox(
decoration: BoxDecoration(
color: color,
),
child: this,
@diamantidis
diamantidis / main.dart
Created October 10, 2021 08:02
How to use `Scrollable.ensureVisible` to scroll from one widget to another in a `SingleChildScrollView`
import 'package:flutter/material.dart';
class Section {
final GlobalKey key;
final String title;
final String body;
const Section(this.key, this.title, this.body);
}