Skip to content

Instantly share code, notes, and snippets.

View NiklasOemler's full-sized avatar
👨‍💻
am frickeln

NiklasOemler

👨‍💻
am frickeln
View GitHub Profile
struct OverflowLayout: Layout {
var spacing = CGFloat(10)
func sizeThatFits(proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) -> CGSize {
let containerWidth = proposal.replacingUnspecifiedDimensions().width
let sizes = subviews.map { $0.sizeThatFits(.unspecified) }
return layout(sizes: sizes, containerWidth: containerWidth).size
}
func placeSubviews(in bounds: CGRect, proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) {
@liamnichols
liamnichols / sign_in_with_apple.yml
Created February 21, 2020 14:53
Localisations of the "Sign in with Apple" string taken from Xcode 11.1
SIGN_IN_WITH_APPLE:
- de: Mit Apple anmelden
- he: התחברות באמצעות Apple
- en_AU: Sign in with Apple
- ar: تسجيل الدخول باستخدام Apple
- el: Σύνδεση μέσω Apple
- ja: Appleでサインイン
- en: Sign in with Apple
- uk: Увійти з Apple
- es_419: Iniciar sesión con Apple
@wojteklu
wojteklu / clean_code.md
Last active May 11, 2024 19:59
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

// call when zoom level or page size changes (i.e. after zooming or after rotation)
- (void)updateContentInsetForPageScrollView:(UIScrollView *)pageScrollView {
UIImageView *imageView = (UIImageView *) [pageScrollView viewWithTag:TAG_IMAGE_VIEW];
CGFloat zoomScale = pageScrollView.zoomScale;
CGSize imageSize = imageView.bounds.size;
CGSize zoomedImageSize = CGSizeMake(imageSize.width * zoomScale, imageSize.height * zoomScale);
CGSize pageSize = pageScrollView.bounds.size;