Update bulletin view with improved header detection and styling
This commit is contained in:
parent
d5c634adf9
commit
62223de1c6
|
@ -505,7 +505,7 @@
|
||||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||||
CODE_SIGN_ENTITLEMENTS = RTSDA.entitlements;
|
CODE_SIGN_ENTITLEMENTS = RTSDA.entitlements;
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 2;
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
DEVELOPMENT_ASSET_PATHS = "\"Preview Content\"";
|
DEVELOPMENT_ASSET_PATHS = "\"Preview Content\"";
|
||||||
DEVELOPMENT_TEAM = TQMND62F2W;
|
DEVELOPMENT_TEAM = TQMND62F2W;
|
||||||
ENABLE_PREVIEWS = YES;
|
ENABLE_PREVIEWS = YES;
|
||||||
|
@ -531,7 +531,7 @@
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"@executable_path/Frameworks",
|
"@executable_path/Frameworks",
|
||||||
);
|
);
|
||||||
MARKETING_VERSION = 1.2;
|
MARKETING_VERSION = 1.2.1;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.rtsda.appr;
|
PRODUCT_BUNDLE_IDENTIFIER = com.rtsda.appr;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||||
|
@ -548,7 +548,7 @@
|
||||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||||
CODE_SIGN_ENTITLEMENTS = RTSDA.entitlements;
|
CODE_SIGN_ENTITLEMENTS = RTSDA.entitlements;
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 2;
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
DEVELOPMENT_ASSET_PATHS = "\"Preview Content\"";
|
DEVELOPMENT_ASSET_PATHS = "\"Preview Content\"";
|
||||||
DEVELOPMENT_TEAM = TQMND62F2W;
|
DEVELOPMENT_TEAM = TQMND62F2W;
|
||||||
ENABLE_PREVIEWS = YES;
|
ENABLE_PREVIEWS = YES;
|
||||||
|
@ -574,7 +574,7 @@
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"@executable_path/Frameworks",
|
"@executable_path/Frameworks",
|
||||||
);
|
);
|
||||||
MARKETING_VERSION = 1.2;
|
MARKETING_VERSION = 1.2.1;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.rtsda.appr;
|
PRODUCT_BUNDLE_IDENTIFIER = com.rtsda.appr;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||||
|
|
|
@ -353,6 +353,58 @@ struct BulletinContentView: View {
|
||||||
var segments: [ContentSegment] = []
|
var segments: [ContentSegment] = []
|
||||||
let nsLine = cleanedLine as NSString
|
let nsLine = cleanedLine as NSString
|
||||||
|
|
||||||
|
// Check for section headers with specific patterns
|
||||||
|
let headerPatterns = [
|
||||||
|
// Sabbath School headers
|
||||||
|
#"^(Sabbath School):?"#,
|
||||||
|
#"^(Song Service):?"#,
|
||||||
|
#"^(Leadership):?"#,
|
||||||
|
#"^(Lesson Study):?"#,
|
||||||
|
#"^(Mission Story):?"#,
|
||||||
|
#"^(Welcome):?"#,
|
||||||
|
#"^(Opening Song):?"#,
|
||||||
|
#"^(Opening Prayer):?"#,
|
||||||
|
#"^(Mission Spotlight):?"#,
|
||||||
|
#"^(Bible Study):?"#,
|
||||||
|
#"^(Closing Song):?"#,
|
||||||
|
#"^(Closing Prayer):?"#,
|
||||||
|
// Divine Worship headers
|
||||||
|
#"^(Announcements):?"#,
|
||||||
|
#"^(Call To Worship):?"#,
|
||||||
|
#"^(Opening Hymn):?"#,
|
||||||
|
#"^(Prayer & Praises):?"#,
|
||||||
|
#"^(Prayer Song):?"#,
|
||||||
|
#"^(Offering):?"#,
|
||||||
|
#"^(Children's Story):?"#,
|
||||||
|
#"^(Special Music):?"#,
|
||||||
|
#"^(Scripture Reading):?"#,
|
||||||
|
#"^(Sermon):?"#,
|
||||||
|
#"^(Closing Hymn):?"#,
|
||||||
|
#"^(Benediction):?"#
|
||||||
|
]
|
||||||
|
|
||||||
|
for pattern in headerPatterns {
|
||||||
|
let headerRegex = try! NSRegularExpression(pattern: pattern, options: [.caseInsensitive])
|
||||||
|
let headerMatches = headerRegex.matches(in: cleanedLine, range: NSRange(location: 0, length: nsLine.length))
|
||||||
|
|
||||||
|
if !headerMatches.isEmpty {
|
||||||
|
// Add the header
|
||||||
|
let headerText = nsLine.substring(with: headerMatches[0].range(at: 1))
|
||||||
|
.trimmingCharacters(in: .whitespaces)
|
||||||
|
segments.append((id: UUID(), text: headerText, type: .sectionHeader, reference: nil))
|
||||||
|
|
||||||
|
// Add any remaining text after the header
|
||||||
|
if headerMatches[0].range.location + headerMatches[0].range.length < nsLine.length {
|
||||||
|
let remainingText = nsLine.substring(from: headerMatches[0].range.location + headerMatches[0].range.length)
|
||||||
|
.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines.union(CharacterSet(charactersIn: ":")))
|
||||||
|
if !remainingText.isEmpty {
|
||||||
|
segments.append((id: UUID(), text: remainingText, type: .text, reference: nil))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return segments
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Match hymn numbers with surrounding text
|
// Match hymn numbers with surrounding text
|
||||||
let hymnPattern = #"(?:Hymn(?:al)?\s+(?:#\s*)?|#\s*)(\d+)(?:\s+["""]([^"""]*)[""])?.*"#
|
let hymnPattern = #"(?:Hymn(?:al)?\s+(?:#\s*)?|#\s*)(\d+)(?:\s+["""]([^"""]*)[""])?.*"#
|
||||||
let hymnRegex = try! NSRegularExpression(pattern: hymnPattern, options: [.caseInsensitive])
|
let hymnRegex = try! NSRegularExpression(pattern: hymnPattern, options: [.caseInsensitive])
|
||||||
|
@ -485,11 +537,11 @@ struct BulletinContentView: View {
|
||||||
if !content.isEmpty {
|
if !content.isEmpty {
|
||||||
VStack(alignment: .center, spacing: 16) {
|
VStack(alignment: .center, spacing: 16) {
|
||||||
Text(title)
|
Text(title)
|
||||||
.font(.title2)
|
.font(.title)
|
||||||
.fontWeight(.bold)
|
.fontWeight(.bold)
|
||||||
.foregroundColor(.primary)
|
.foregroundColor(.primary)
|
||||||
.frame(maxWidth: .infinity, alignment: .center)
|
.frame(maxWidth: .infinity, alignment: .center)
|
||||||
.padding(.bottom, 4)
|
.padding(.bottom, 8)
|
||||||
|
|
||||||
VStack(alignment: .center, spacing: 12) {
|
VStack(alignment: .center, spacing: 12) {
|
||||||
ForEach(Array(zip(content.components(separatedBy: .newlines).indices, content.components(separatedBy: .newlines))), id: \.0) { index, line in
|
ForEach(Array(zip(content.components(separatedBy: .newlines).indices, content.components(separatedBy: .newlines))), id: \.0) { index, line in
|
||||||
|
@ -545,8 +597,12 @@ struct BulletinContentView: View {
|
||||||
case .sectionHeader:
|
case .sectionHeader:
|
||||||
Text(segment.text)
|
Text(segment.text)
|
||||||
.font(.headline)
|
.font(.headline)
|
||||||
.multilineTextAlignment(.center)
|
.fontWeight(.semibold)
|
||||||
.foregroundColor(.primary)
|
.foregroundColor(.primary)
|
||||||
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
|
.padding(.top, 16)
|
||||||
|
.padding(.bottom, 4)
|
||||||
|
.padding(.horizontal, 8)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue