Skip to content

Commit bda51fc

Browse files
Initial project structure (#2)
1 parent ed2667d commit bda51fc

File tree

69 files changed

+2721
-792
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+2721
-792
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
* text=auto eol=lf
2+
*.strings diff

.gitignore

Lines changed: 74 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,75 @@
1-
# General
1+
# Xcode
2+
#
3+
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
4+
5+
# macOS
26
.DS_Store
3-
Thumbs.db
4-
5-
# IDEs and editors
6-
.idea/
7-
.project
8-
.classpath
9-
.c9/
10-
*.launch
11-
.settings/
12-
*.sublime-workspace
13-
14-
# Visual Studio Code
15-
.vscode/*
16-
!.vscode/settings.json
17-
!.vscode/tasks.json
18-
!.vscode/launch.json
19-
!.vscode/extensions.json
20-
.history/*
21-
22-
# Node
23-
node_modules
24-
npm-debug.log
7+
8+
## User settings
9+
xcuserdata/
10+
11+
## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
12+
*.xcscmblueprint
13+
*.xccheckout
14+
15+
## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
16+
build/
17+
DerivedData/
18+
*.moved-aside
19+
*.pbxuser
20+
!default.pbxuser
21+
*.mode1v3
22+
!default.mode1v3
23+
*.mode2v3
24+
!default.mode2v3
25+
*.perspectivev3
26+
!default.perspectivev3
27+
28+
## UserDefaults testing
29+
*.swift.plist
30+
31+
## Obj-C/Swift specific
32+
*.hmap
33+
34+
## App packaging
35+
*.ipa
36+
*.dSYM.zip
37+
*.dSYM
38+
*dSYMs.zip
39+
40+
## Playgrounds
41+
timeline.xctimeline
42+
playground.xcworkspace
43+
44+
# Swift Package Manager
45+
#
46+
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
47+
# Packages/
48+
# Package.pins
49+
# Package.resolved
50+
# *.xcodeproj
51+
#
52+
# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata
53+
# hence it is not needed unless you have added a package configuration file to your project
54+
# .swiftpm
55+
56+
.build/
57+
58+
# fastlane
59+
#
60+
# It is recommended to not store the screenshots in the git repo.
61+
# Instead, use fastlane to re-generate the screenshots whenever they are needed.
62+
# For more information about the recommended setup visit:
63+
# https://docs.fastlane.tools/best-practices/source-control/#source-control
64+
65+
fastlane/report.xml
66+
fastlane/Preview.html
67+
fastlane/screenshots/**/*.png
68+
fastlane/test_output
69+
fastlane/README.md
70+
71+
# XcodeGen
72+
/*.xcodeproj
73+
74+
# Local xcconfig
75+
Configs/Local.xcconfig

.husky/pre-commit

Lines changed: 0 additions & 1 deletion
This file was deleted.

.swiftformat

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# format options
2+
--indent 4
3+
--ifdef noindent
4+
--swiftversion 5.8.1
5+
--header strip
6+
--funcattributes prev-line
7+
--typeattributes prev-line
8+
--varattributes same-line
9+
10+
# file options
11+
--exclude **/Generated,build,vendor/bundle
12+
13+
# rules
14+
--disable elseOnSameLine,semicolons,unusedArguments,opaqueGenericParameters,wrapMultilineStatementBraces,preferForLoop
15+
--enable blankLineAfterImports,isEmpty,blockComments,docComments,sortSwitchCases

.swiftlint.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
analyzer_rules:
2+
- unused_declaration
3+
- unused_import
4+
5+
disabled_rules:
6+
- todo
7+
- trailing_whitespace # Covered by SwiftFormat
8+
- vertical_whitespace # Covered by SwiftFormat
9+
10+
opt_in_rules:
11+
- anonymous_argument_in_multiline_closure
12+
- attributes
13+
- closure_end_indentation
14+
- closure_spacing
15+
- collection_alignment
16+
- contains_over_filter_count
17+
- contains_over_filter_is_empty
18+
- contains_over_first_not_nil
19+
- contains_over_range_nil_comparison
20+
- empty_collection_literal
21+
- empty_count
22+
- empty_string
23+
- fallthrough
24+
- file_name
25+
- file_name_no_space
26+
- first_where
27+
- identical_operands
28+
- missing_docs
29+
- multiline_arguments
30+
- multiline_parameters
31+
- operator_usage_whitespace
32+
- prefer_zero_over_explicit_init
33+
- sorted_imports
34+
- sorted_first_last
35+
- static_operator
36+
- toggle_bool
37+
- type_contents_order
38+
- unneeded_parentheses_in_closure_argument
39+
- unowned_variable_capture
40+
- yoda_condition
41+
42+
excluded:
43+
- BitwardenShared/UI/Platform/Application/Support/Generated
44+
- BitwardenWatchApp
45+
- BitwardenWatchShared
46+
- build
47+
- vendor/bundle
48+
49+
attributes:
50+
always_on_same_line:
51+
- "@Environment"
52+
53+
cyclomatic_complexity:
54+
ignores_case_statements: true
55+
56+
multiline_arguments:
57+
only_enforce_after_first_closure_on_first_line: true
58+
59+
trailing_comma:
60+
mandatory_comma: true
61+
62+
type_contents_order:
63+
order:
64+
- case
65+
- type_alias
66+
- associated_type
67+
- subtype
68+
- type_property
69+
- instance_property
70+
- ib_inspectable
71+
- ib_outlet
72+
- initializer
73+
- deinitializer
74+
- type_method
75+
- view_life_cycle_method
76+
- ib_action
77+
- other_method
78+
- subscript
79+
80+
identifier_name:
81+
excluded:
82+
- id
83+
84+
inclusive_language:
85+
override_allowed_terms:
86+
- masterPassword
87+
88+
custom_rules:
89+
style_guide_font:
90+
name: "Style Guide Font"
91+
regex: "(.font\\(.system)"
92+
message: "Prefer using a style guide font over the system fonts, for example: \".font(.styleGuide(.body))\""
93+
match_kinds:
94+
- identifier
95+
severity: warning
96+
todo_without_jira:
97+
name: "TODO without JIRA"
98+
regex: "(TODO|TO DO|FIX|FIXME|FIX ME|todo)(?!: BIT-[0-9]{1,})" # "TODO: BIT-123"
99+
message: "All TODOs must be followed by a JIRA reference, for example: \"TODO: BIT-123\""
100+
match_kinds:
101+
- comment
102+
severity: warning
103+
weak_navigator:
104+
name: "Weak Navigator"
105+
regex: "(?<!weak )(var|let) \\w*[nN]avigator: \\w*Navigator"
106+
message: "Navigator references must be weak to avoid memory leaks."
107+
severity: error
108+
excluded:
109+
- ".*Tests\\.swift"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>_XCCurrentVersionName</key>
6+
<string>Authenticator.xcdatamodel</string>
7+
</dict>
8+
</plist>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="1" systemVersion="11A491" minimumToolsVersion="Automatic" sourceLanguage="Swift" usedWithCloudKit="false" userDefinedModelVersionIdentifier="">
3+
<entity name="Item" representedClassName="Item" syncable="YES" codeGenerationType="class">
4+
<attribute name="timestamp" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
5+
</entity>
6+
<elements>
7+
<element name="Item" positionX="-63" positionY="-18" width="128" height="44"/>
8+
</elements>
9+
</model>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import SwiftUI
2+
3+
@main
4+
struct AuthenticatorApp: App {
5+
let persistenceController = PersistenceController.shared
6+
7+
var body: some Scene {
8+
WindowGroup {
9+
ContentView()
10+
.environment(\.managedObjectContext, persistenceController.container.viewContext)
11+
}
12+
}
13+
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import CoreData
2+
import SwiftUI
3+
4+
struct ContentView: View {
5+
@Environment(\.managedObjectContext) private var viewContext
6+
7+
@FetchRequest(
8+
sortDescriptors: [NSSortDescriptor(keyPath: \Item.timestamp, ascending: true)],
9+
animation: .default
10+
)
11+
private var items: FetchedResults<Item>
12+
13+
var body: some View {
14+
NavigationView {
15+
List {
16+
ForEach(items) { item in
17+
NavigationLink {
18+
Text("Item at \(item.timestamp!, formatter: itemFormatter)")
19+
} label: {
20+
Text(item.timestamp!, formatter: itemFormatter)
21+
}
22+
}
23+
.onDelete(perform: deleteItems)
24+
}
25+
.toolbar {
26+
ToolbarItem(placement: .navigationBarTrailing) {
27+
EditButton()
28+
}
29+
ToolbarItem {
30+
Button(action: addItem) {
31+
Label("Add Item", systemImage: "plus")
32+
}
33+
}
34+
}
35+
Text("Select an item")
36+
}
37+
}
38+
39+
private func addItem() {
40+
withAnimation {
41+
let newItem = Item(context: viewContext)
42+
newItem.timestamp = Date()
43+
44+
do {
45+
try viewContext.save()
46+
} catch {
47+
// Replace this implementation with code to handle the error appropriately.
48+
// fatalError() causes the application to generate a crash log and terminate.
49+
// You should not use this function in a shipping application,
50+
// although it may be useful during development.
51+
let nsError = error as NSError
52+
fatalError("Unresolved error \(nsError), \(nsError.userInfo)")
53+
}
54+
}
55+
}
56+
57+
private func deleteItems(offsets: IndexSet) {
58+
withAnimation {
59+
offsets.map { items[$0] }.forEach(viewContext.delete)
60+
61+
do {
62+
try viewContext.save()
63+
} catch {
64+
// Replace this implementation with code to handle the error appropriately.
65+
// fatalError() causes the application to generate a crash log and terminate.
66+
// You should not use this function in a shipping application,
67+
// although it may be useful during development.
68+
let nsError = error as NSError
69+
fatalError("Unresolved error \(nsError), \(nsError.userInfo)")
70+
}
71+
}
72+
}
73+
}
74+
75+
private let itemFormatter: DateFormatter = {
76+
let formatter = DateFormatter()
77+
formatter.dateStyle = .short
78+
formatter.timeStyle = .medium
79+
return formatter
80+
}()
81+
82+
#Preview {
83+
ContentView().environment(\.managedObjectContext, PersistenceController.preview.container.viewContext)
84+
}

0 commit comments

Comments
 (0)