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 android.annotation.SuppressLint | |
| import android.content.Context | |
| @SuppressLint("ApplySharedPref") | |
| fun String.save(applicationContext: Context, value: Map<String, Any>, clear: Boolean = false, now: Boolean = false) { | |
| val sp = applicationContext.getSharedPreferences(this, Context.MODE_PRIVATE).edit() | |
| if (clear) | |
| sp.clear() | |
| value.keys.forEach { key -> | |
| val v = value[key] |
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 org.json.JSONArray | |
| import org.json.JSONException | |
| import org.json.JSONObject | |
| val String.jsonObject: JSONObject? | |
| get() = try { | |
| JSONObject(this) | |
| } catch (e: JSONException) { | |
| null | |
| } |
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
| val String.creditCardFormatted: String | |
| get() { | |
| val preparedString = replace(" ", "").trim() | |
| val result = StringBuilder() | |
| for (i in preparedString.indices) { | |
| if (i % 4 == 0 && i != 0) { | |
| result.append(" ") | |
| } | |
| result.append(preparedString[i]) | |
| } |
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 java.awt.Color | |
| val String.awtColor: Color? | |
| get() { | |
| val r = substring(1, 3).toIntOrNull(16) ?: return null | |
| val g = substring(3, 5).toIntOrNull(16) ?: return null | |
| val b = substring(5, 7).toIntOrNull(16) ?: return null | |
| return Color(r, g, b) | |
| } |
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 android.graphics.Color | |
| val String.asColor: Int? | |
| get() = try { | |
| Color.parseColor(this) | |
| } catch (e: java.lang.IllegalArgumentException) { | |
| null | |
| } |
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
| platform :ios, '11.0' | |
| inhibit_all_warnings! | |
| target 'Waste-management-app-musafarouk' do | |
| # Add all your pods here | |
| # Supernova Pods |
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 { | |
| var body: some View { | |
| VStack { | |
| MapView() | |
| .edgesIgnoringSafeArea(.top) | |
| .frame(height: 300) | |
| CircleImage() |
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
| let image = SizeLayout<UIImageView>(width: 50, height: 50, config: { imageView in | |
| imageView.image = UIImage(named: "earth.jpg") | |
| }) | |
| let label = LabelLayout(text: "Hello World!", alignment: .center) | |
| let stack = StackLayout( | |
| axis: .horizontal, | |
| spacing: 4, | |
| sublayouts: [image, label]) |