Skip to content

Instantly share code, notes, and snippets.

View cchana's full-sized avatar

Charanjit Chana cchana

View GitHub Profile
@cchana
cchana / borderless-list-item.swift
Last active February 15, 2024 12:43
How to place a borderless item into a list, removing all padding and spacing around the internal elements. In this example, I there's a groupbox which takes up the entire space of the list row. Question asked and answered on Stack Overflow: https://stackoverflow.com/questions/77982484/how-to-combine-groupbox-or-disclosuregroup-with-a-list-in-a-s…
import SwiftUI
struct ContentView: View {
var body: some View {
NavigationStack {
List {
Section {
GroupBox("Box Title") {
Text("Box Content")
@cchana
cchana / swiftui-map.swift
Last active February 15, 2024 09:50
A very basic example on how to put an Apple Map element into a SwiftUI View
import SwiftUI
import MapKit
struct ContentView: View {
@State var coordinateRegion: MKCoordinateRegion = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: 37.334900, longitude: -122.009020), latitudinalMeters: 1000, longitudinalMeters: 1000)
var body: some View {
Map(coordinateRegion: $coordinateRegion)
.frame(height: 200)
@media screen and (max-width: 700px) {
table {
border-collapse: collapse;
margin-bottom: 50px;
width: 100%;
}
table td {
<html>
<head>
<title>Faux checkboxes and radio buttons</title>
<link type="text/css" rel="stylesheet" href="style.css" />
</head>
<body>
<ul>
<li><label for="checkbox1">Check me</label><input type="checkbox" id="checkbox1" name="checkbox1" /></li>
<li><label for="checkbox2">And me</label><input type="checkbox" id="checkbox2" name="checkbox2" /></li>