Skip to content

Instantly share code, notes, and snippets.

@Composable
fun ApplyButton(
text: String,
modifier: Modifier = Modifier,
applicable: Boolean = false,
spanStyle: SpanStyle,
paragraphStyle: ParagraphStyle,
style: TextStyle,
onClick: () -> Unit
) {
@agammahajan1
agammahajan1 / item_cell.swift
Created September 30, 2021 13:05
Change item cell UI
if UIAccessibility.isVoiceOverRunning {
// add cart button in item cell
}
@agammahajan1
agammahajan1 / cutom-actions.swift
Last active August 29, 2021 21:51
Custom Actions handling in Food item
let addItemAction = UIAccessibilityCustomAction(name: "Add one quantity of this item.") { [weak self] _ in
// add 1 quantity of the item selected
UIAccessibility.post(notification: .announcement, argument: "Item added, total number of items in cart now is \(noOfItems) with a subtotal of \(cartTotal) rupees")
}
let removeItemAction = UIAccessibilityCustomAction(name: "Remove one quantity of this item.") { [weak self] _ in
if itemsInCart {
//remove 1 quantity of the item selected
if noOfItems == 0 {
UIAccessibility.post(notification: .announcement, argument: "Item removed, no items in cart now")
UIAccessibility.post(notification: .announcement,
argument: "Location has changed to JP Nagar")
@agammahajan1
agammahajan1 / images.swift
Created August 29, 2021 21:10
Add alt text to the image view
imageView.isAccessibilityElement = true
imageView.accessibilityLabel = dataSource.accessibility.altText
@agammahajan1
agammahajan1 / grouping.swift
Created August 29, 2021 19:17
Grouping of view
cell.isAccessibilityElement = true
cell.accessibilityLabel = restaurantName + rating + offer
extension URL {
var attributes: [FileAttributeKey : Any]? {
do {
return try FileManager.default.attributesOfItem(atPath: path)
} catch let error as NSError {
print("FileAttribute error: \(error)")
}
return nil
}
static func findCachedVideoURL(forVideoId id: String) -> URL? {
let nsDocumentDirectory = FileManager.SearchPathDirectory.documentDirectory
let nsUserDomainMask = FileManager.SearchPathDomainMask.userDomainMask
let paths = NSSearchPathForDirectoriesInDomains(nsDocumentDirectory, nsUserDomainMask, true)
if let dirPath = paths.first {
let fileURL = URL(fileURLWithPath: dirPath).appendingPathComponent(folderPath).appendingPathComponent(id + ".mp4")
let filePath = fileURL.path
let fileManager = FileManager.default
if fileManager.fileExists(atPath: filePath) {
NewRelicService.sendCustomEvent(with: NewRelicEventType.statusCodes,
func removeVideoIfMaxNumberOfVideosReached() {
if popupVideosDict.count >= maxVideosAllowed {
// remove the least recently used video
let sortedDict = popupVideosDict.keysSortedByValue { (v1, v2) -> Bool in
v1.timeStamp < v2.timeStamp
}
guard let videoId = sortedDict.first else {
return
}
popupVideosDict.removeValue(forKey: videoId)
func cleanExpiredVideos() {
let currentTimeStamp = Date().timeIntervalSince1970
var expiredKeys: [String] = []
for videoData in videosDict where currentTimeStamp - videoData.value.timeStamp >= expiryTime {
// video is expired. delete
if let _ = popupVideosDict[videoData.key] {
expiredKeys.append(videoData.key)
}
}
for key in expiredKeys {