This file contains hidden or 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
struct FlowLayout: Layout { | |
func sizeThatFits(proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) -> CGSize { | |
let sizes = subviews.map { $0.sizeThatFits(.unspecified) } | |
var totalHeight: CGFloat = 0 | |
var totalWidth: CGFloat = 0 | |
var lineWidth: CGFloat = 0 | |
var lineHeight: CGFloat = 0 |
This file contains hidden or 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
import SwiftUI | |
struct ContentView: View { | |
struct ColorGroup: Hashable { | |
let colors: [ColorInfo] | |
let name: String | |
let description: String | |
} | |
struct ColorInfo: Hashable { |
This file contains hidden or 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
import SwiftUI | |
import Combine | |
struct AlertWithPublisher<P>: ViewModifier where P: Publisher, P.Failure == Never { | |
let publisher: P | |
let alertContent: (P.Output?) -> Alert | |
@State private var isShowingAlert = false | |
@State private var publisherOutput: P.Output? = nil |
This file contains hidden or 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
- (NSInteger)hashWithModulo:(NSInteger)modulo | |
{ | |
int i, sum = 0; | |
for (i = 0; i < self.length; i++) | |
{ | |
sum += [self characterAtIndex:i]; | |
} | |
return (sum % modulo); | |
} |
This file contains hidden or 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
- (NSString *)timeAgo | |
{ | |
NSDate *now = [NSDate date]; | |
double deltaSeconds = fabs([self timeIntervalSinceDate:now]); | |
double deltaMinutes = deltaSeconds / 60.0f; | |
int minutes; | |
if(deltaSeconds < 5) | |
{ |
This file contains hidden or 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
#import "NSString+Abbreviation.h" | |
@implementation NSString (Abbreviation) | |
- (NSString *)abbreviatedWithMiddles:(BOOL)middles | |
{ | |
NSArray *nameParts = [self componentsSeparatedByString:@" "]; | |
if (nameParts && nameParts.count > 0) | |
{ |
This file contains hidden or 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
int array[255] = {0}; | |
NSString *test = @"Test string."; | |
int i = 0; | |
for(i = 0; i < test.length; i++) | |
{ | |
++array[[test characterAtIndex:i]]; | |
} | |
int max = array[0]; |
This file contains hidden or 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
NSDate *fireDate = nil; | |
NSDate *startDate = [card getLatestDateOfActivities:@[ACTIVITY_CARD_CREATED, ACTIVITY_TIME_SET, ACTIVITY_TIME_CHANGED]]; | |
NSDate *endDate = card.time.date; | |
NSTimeInterval deltaHours = (abs([startDate timeIntervalSinceReferenceDate] - [endDate timeIntervalSinceReferenceDate]) / 3600); | |
NSString *invitesNamesSentence = [card getInvitesNamesSentenceWithYourFriendsOption:YES]; | |
NSMutableString *alertBody = [[NSMutableString alloc] initWithFormat:@"%@ wants to meet you ", invitesNamesSentence]; | |